public abstract class AbstractContainer extends Object implements Container
Container.
It implements by default all the methods by delegating the call the the successor.| Modifier and Type | Field and Description |
|---|---|
protected Interceptor |
delegate |
| Modifier | Constructor and Description |
|---|---|
protected |
AbstractContainer() |
protected |
AbstractContainer(Interceptor successor) |
| Modifier and Type | Method and Description |
|---|---|
void |
accept(ContainerVisitor visitor)
Accepts a visitor that should visit the child containers, component adapters and component instances.
|
<T> T |
createComponent(Class<T> clazz,
InitParams params)
Creates a component corresponding to the given
Class with the
given InitParams |
void |
dispose()
Dispose this component.
|
<T> ComponentAdapter<T> |
getComponentAdapter(Object componentKey,
Class<T> bindType,
boolean autoRegistration)
Find a component adapter associated with the specified key.
|
<T> ComponentAdapter<T> |
getComponentAdapterOfType(Class<T> componentType,
boolean autoRegistration)
Find a component adapter associated with the specified type.
|
Collection<ComponentAdapter<?>> |
getComponentAdapters()
Retrieve all the component adapters inside this container.
|
<T> List<ComponentAdapter<T>> |
getComponentAdaptersOfType(Class<T> componentType)
Retrieve all component adapters inside this container that are associated with the specified type.
|
<T> T |
getComponentInstance(Object componentKey,
Class<T> bindType,
boolean autoRegistration)
Retrieve a component instance registered with a specific key.
|
<T> T |
getComponentInstanceOfType(Class<T> componentType,
boolean autoRegistration)
Find a component instance matching the specified type.
|
<T> List<T> |
getComponentInstancesOfType(Class<T> componentType)
Returns a List of components of a certain componentType.
|
ManagementContext |
getManagementContext()
Gives the corresponding
ManagementContext |
MBeanServer |
getMBeanServer()
Provides the
MBeanServer this method is needed for backward compatibility |
ObjectName |
getScopingObjectName()
Gives the ObjectName of the container build from the scoping data
|
Interceptor |
getSuccessor()
Retrieve the successor of this container in the chain of
Interceptor. |
void |
initialize()
Initializes the container
|
<T> ComponentAdapter<T> |
registerComponentImplementation(Object componentKey,
Class<T> componentImplementation)
Register a component.
|
<T> ComponentAdapter<T> |
registerComponentInstance(Object componentKey,
T componentInstance)
Register an arbitrary object as a component in the container.
|
void |
start()
Start this component.
|
void |
stop()
Stop this component.
|
ComponentAdapter<?> |
unregisterComponent(Object componentKey)
Unregister a component by key.
|
protected Interceptor delegate
protected AbstractContainer()
protected AbstractContainer(Interceptor successor)
public void start()
public void stop()
Disposable if you need a single call at the definite end of the lifecycle.public void dispose()
dispose in interface Disposablepublic <T> T getComponentInstance(Object componentKey, Class<T> bindType, boolean autoRegistration)
getComponentInstance in interface ContainercomponentKey - the key that the component was registered with.bindType - the expected type of the instance if one can be found.autoRegistration - indicates whether the auto registration should be performed or notnull if no component has been registered for the specified
key.public <T> T getComponentInstanceOfType(Class<T> componentType, boolean autoRegistration)
getComponentInstanceOfType in interface ContainercomponentType - the type of the component.autoRegistration - indicates whether the auto registration should be performed or notpublic Interceptor getSuccessor()
Interceptor.getSuccessor in interface ContainerInterceptor instance, or null if this container does not have a successor.public <T> ComponentAdapter<T> getComponentAdapter(Object componentKey, Class<T> bindType, boolean autoRegistration)
getComponentAdapter in interface ContainercomponentKey - the key that the component was registered with.bindType - the expected raw type of the adapter if one can be found.autoRegistration - indicates whether the auto registration should be performed or notnull if no component has been registered
for the specified key.public <T> ComponentAdapter<T> getComponentAdapterOfType(Class<T> componentType, boolean autoRegistration)
getComponentAdapterOfType in interface ContainercomponentType - the type of the component.autoRegistration - indicates whether the auto registration should be performed or notnull if no component has been
registered for the specified key.public Collection<ComponentAdapter<?>> getComponentAdapters()
getComponentAdapters in interface ContainerComponentAdapters inside this container. The collection will
not be modifiable.a variant of this method which returns the component adapters inside this
container that are associated with the specified type.public <T> List<ComponentAdapter<T>> getComponentAdaptersOfType(Class<T> componentType)
getComponentAdaptersOfType in interface ContainercomponentType - the type of the components.ComponentAdapters inside this container that are associated with
the specified type. Changes to this collection will not be reflected in the container itself.public <T> List<T> getComponentInstancesOfType(Class<T> componentType) throws ContainerException
getComponentInstancesOfType in interface ContainercomponentType - the searched type.ContainerExceptionpublic void accept(ContainerVisitor visitor)
public <T> ComponentAdapter<T> registerComponentImplementation(Object componentKey, Class<T> componentImplementation) throws ContainerException
registerComponentImplementation in interface ContainercomponentKey - a key that identifies the component. Must be unique within the container. The type
of the key object has no semantic significance unless explicitly specified in the
documentation of the implementing container.componentImplementation - the component's implementation class. This must be a concrete class (ie, a
class that can be instantiated).getXXX() methods of the
Container interface can be used to retrieve a reference to the component later on.ContainerException - if registration of the component fails.public <T> ComponentAdapter<T> registerComponentInstance(Object componentKey, T componentInstance) throws ContainerException
registerComponentInstance in interface ContainercomponentKey - a key that identifies the component. Must be unique within the container. The type of the
key object has no semantic significance unless explicitly specified in the implementing
container.componentInstance - an arbitrary object.getXXX() methods of the
Container interface can be used to retrieve a reference to the component later on.ContainerException - if registration fails.public ComponentAdapter<?> unregisterComponent(Object componentKey)
unregisterComponent in interface ContainercomponentKey - key of the component to unregister.public ManagementContext getManagementContext()
ManagementContextgetManagementContext in interface Containerpublic MBeanServer getMBeanServer()
MBeanServer this method is needed for backward compatibilitygetMBeanServer in interface Containerpublic ObjectName getScopingObjectName()
getScopingObjectName in interface Containerpublic <T> T createComponent(Class<T> clazz, InitParams params) throws Exception
Class with the
given InitParamscreateComponent in interface Containerclazz - the Class of the object to createparams - the parameters to use to create the componentException - if any issue occurs while creating the component.public void initialize()
initialize in interface ContainerCopyright © 2016 eXo Platform SAS. All Rights Reserved.