com.ibm.commons.extension
Class ExtensionManager

java.lang.Object
  extended by com.ibm.commons.extension.ExtensionManager

public class ExtensionManager
extends java.lang.Object

Extension Manager.

This class is used to manage the extension in an independant manner. It can use services like extension or Eclipse extension points, depending on the running platform.

As the runtime can be shared by multiple J2EE applications, some extensions can be defined globally (e.g. for all the applications) or on a per application basis.


Nested Class Summary
static interface ExtensionManager.ApplicationClassLoader
          Interface that defines an application classloader.
 
Constructor Summary
ExtensionManager()
           
 
Method Summary
static java.util.List<java.lang.Object> findApplicationServices(java.lang.ClassLoader loader, java.lang.String serviceType)
          Find the available implementations of a service for a particular Application.
static java.util.List<java.lang.Object> findApplicationServices(java.util.Map<java.lang.String,java.util.List<java.lang.Object>> services, java.lang.ClassLoader loader, java.lang.String serviceType)
          Find the available implementations of a service for a particular Application.
static java.util.List<java.lang.Object> findServices(java.util.List<java.lang.Object> list, java.lang.Class<?> clazz, java.lang.String serviceType)
          Find the globally available implementations of a service.
static java.util.List<java.lang.Object> findServices(java.util.List<java.lang.Object> list, java.lang.ClassLoader loader, java.lang.String serviceType)
          Find the globally available implementations of a service.
static
<T> java.util.List<T>
findServices(java.util.List<T> existingList, java.lang.ClassLoader loader, java.lang.String serviceType, java.lang.Class<T> requiredType)
          Find the globally available implementations of a service.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ExtensionManager

public ExtensionManager()
Method Detail

findApplicationServices

public static java.util.List<java.lang.Object> findApplicationServices(java.lang.ClassLoader loader,
                                                                       java.lang.String serviceType)
Find the available implementations of a service for a particular Application.

This includes both the globally available services as well as the one defined in the application class loader as well. The global services are generally read from the Eclipse extension points while the per application are read using the services definition (until OSGi will be available everywhere....)

The result is a list of service implementations (concrete classes)

Parameters:
loader - the class loader used to load the services
serviceType - the name of the service to load
Returns:
a List of services implementation

findApplicationServices

public static java.util.List<java.lang.Object> findApplicationServices(java.util.Map<java.lang.String,java.util.List<java.lang.Object>> services,
                                                                       java.lang.ClassLoader loader,
                                                                       java.lang.String serviceType)
Find the available implementations of a service for a particular Application.

Similar to com.ibm.commons.extension.ExtensionManager.findApplicationServices(ClassLoader, String) but it also manages a cache which prevents the resources to be read if not necessary.

Parameters:
services - the Map that holds the cache. Must be one instance per Application
loader - the class loader used to load the services
serviceType - the name of the service to load
Returns:
a List of services implementation

findServices

public static java.util.List<java.lang.Object> findServices(java.util.List<java.lang.Object> list,
                                                            java.lang.Class<?> clazz,
                                                            java.lang.String serviceType)
Find the globally available implementations of a service.

The list only contained the services that are shared, and not the application specific ones.

Parameters:
list - an optional list containing the services. If not null, then it is returned
clazz - the class to get the class loader for loading the services
serviceType - the name of the service to load
Returns:
a List of services implementation

findServices

public static java.util.List<java.lang.Object> findServices(java.util.List<java.lang.Object> list,
                                                            java.lang.ClassLoader loader,
                                                            java.lang.String serviceType)
Find the globally available implementations of a service.

The list only contained the services that are shared, and not the application specific ones.

Parameters:
list - an optional list containing the services. If not null, then it is returned
classloader - The class loader to look for the services
serviceType - the name of the service to load
Returns:
a List of services implementation

findServices

public static <T> java.util.List<T> findServices(java.util.List<T> existingList,
                                                 java.lang.ClassLoader loader,
                                                 java.lang.String serviceType,
                                                 java.lang.Class<T> requiredType)
Find the globally available implementations of a service.

This is the type safety implementation of the method using generics. The content of the list is checked to ensure that all the implementations belong to the correct type.

Type Parameters:
T -
Parameters:
existingList - already loaded service list; the services will only be loaded if list is null.
loader - ClassLoader to use when loading the classes in a non-OSGI environment.
serviceType - service id.
requiredType - Class to be implemented by all contributing services. Services which do not implement that class will generate a warning and will not be included in the result List. When null no class validation is performed.
Returns: