public class ExoContainer extends AbstractContainer
Container which allows eXo to apply
the Inversion of Control (also known as IoC) principles.| Modifier and Type | Field and Description |
|---|---|
protected ExoContainerContext |
context |
protected static Log |
LOG |
protected ExoContainer |
parent |
protected AtomicBoolean |
stopping |
delegate| Constructor and Description |
|---|
ExoContainer() |
ExoContainer(ExoContainer parent) |
| Modifier and Type | Method and Description |
|---|---|
void |
addComponentLifecylePlugin(ComponentLifecyclePlugin plugin) |
void |
addContainerLifecylePlugin(ContainerLifecyclePlugin plugin) |
boolean |
canBeDisposed()
Indicates whether or not the container can be disposed
|
protected boolean |
canBeInitialized()
Indicates whether or not the container can be initialized
|
boolean |
canBeStarted()
Indicates whether or not the container can be started
|
boolean |
canBeStopped()
Indicates whether or not the container can be stopped
|
<T> T |
createComponent(Class<T> clazz)
Creates a component corresponding to the given
Class with no parameters
This is equivalent to call AbstractContainer.createComponent(Class, InitParams) with
null as InitParams |
void |
dispose()
Dispose this component.
|
ComponentAdapter<?> |
getComponentAdapter(Object componentKey)
Find a component adapter associated with the specified key.
|
<T> ComponentAdapter<T> |
getComponentAdapter(Object componentKey,
Class<T> bindType)
This method is equivalent to
getComponentAdapter(Object, Class, boolean) with true for the parameter
autoRegistration |
<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)
This method is equivalent to
getComponentAdapterOfType(Class, boolean) with true for the parameter
autoRegistration |
<T> ComponentAdapter<T> |
getComponentAdapterOfType(Class<T> componentType,
boolean autoRegistration)
Find a component adapter associated with the specified type.
|
Object |
getComponentInstance(Object componentKey)
Retrieve a component instance registered with a specific key.
|
<T> T |
getComponentInstance(Object componentKey,
Class<T> bindType)
This method is equivalent to
getComponentInstance(Object, Class, boolean) with true for the parameter
autoRegistration |
<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)
This method is equivalent to
getComponentInstanceOfType(Class, boolean) with true for the parameter
autoRegistration |
<T> T |
getComponentInstanceOfType(Class<T> componentType,
boolean autoRegistration)
Find a component instance matching the specified type.
|
protected Configuration |
getConfiguration()
Gets the
ConfigurationManager from the given ExoContainer if it exists,
then returns the nested Configuration otherwise it returns null |
ExoContainerContext |
getContext() |
ContextManager |
getContextManager()
Gives the
ContextManager that has been registered |
protected Collection<ExternalComponentPlugins> |
getExternalComponentPluginsUnused()
Gives all the
ExternalComponentPlugins that have not been used, null
if there are all used. |
ExoContainer |
getParent()
Gives the parent container of this container.
|
static Set<String> |
getProfiles()
Returns an unmodifiable set of profiles defined by the value returned by invoking
PropertyManager.getProperty(String) with the PropertyManager.RUNTIME_PROFILES
property. |
Set<String> |
getRegisteredComponentNames() |
static boolean |
hasProfile(String profileName)
Indicates whether or not a given profile exists
|
protected void |
initContainerInternal() |
void |
initialize()
Initializes the container
|
boolean |
isContextManagerLoaded()
Indicates whether or not the
ContextManager has already been loaded |
<T> ComponentAdapter<T> |
registerComponentImplementation(Class<T> componentImplementation)
Register a component using the componentImplementation as key.
|
<T> ComponentAdapter<T> |
registerComponentInstance(T componentInstance)
Register an arbitrary object.
|
void |
start()
Start this component.
|
void |
start(boolean init)
Starts the container
|
void |
stop()
Stop this component.
|
protected void |
unregisterAllComponents()
Unregister all components from container to avoid keeping instances in memory.
|
accept, createComponent, getComponentAdapters, getComponentAdaptersOfType, getComponentInstancesOfType, getManagementContext, getMBeanServer, getScopingObjectName, getSuccessor, registerComponentImplementation, registerComponentInstance, unregisterComponentprotected final AtomicBoolean stopping
protected static final Log LOG
protected final ExoContainerContext context
protected final ExoContainer parent
public ExoContainer()
public ExoContainer(ExoContainer parent)
public static Set<String> getProfiles()
PropertyManager.getProperty(String) with the PropertyManager.RUNTIME_PROFILES
property.public static boolean hasProfile(String profileName)
profileName - the name of the profile to checktrue if the profile exists, false otherwise.public ExoContainerContext getContext()
protected void initContainerInternal()
public void dispose()
AbstractContainerdispose in interface Disposabledispose in class AbstractContainerpublic void start(boolean init)
init - indicates if the container must be initialized firstpublic void initialize()
AbstractContainerinitialize in interface Containerinitialize in class AbstractContainerpublic void start()
AbstractContainerstart in interface Startablestart in class AbstractContainerpublic void stop()
AbstractContainerDisposable if you need a single call at the definite end of the lifecycle.stop in interface Startablestop in class AbstractContainerpublic void addComponentLifecylePlugin(ComponentLifecyclePlugin plugin)
public void addContainerLifecylePlugin(ContainerLifecyclePlugin plugin)
protected Configuration getConfiguration()
ConfigurationManager from the given ExoContainer if it exists,
then returns the nested Configuration otherwise it returns nullprotected Collection<ExternalComponentPlugins> getExternalComponentPluginsUnused()
ExternalComponentPlugins that have not been used, null
if there are all used.protected void unregisterAllComponents()
public <T> ComponentAdapter<T> registerComponentImplementation(Class<T> componentImplementation) throws ContainerException
registerComponentImplementation(componentImplementation, componentImplementation).componentImplementation - the concrete component class.getXXX() methods of the
Container interface can be used to retrieve a reference to the component later on.ContainerException - if registration fails.public <T> ComponentAdapter<T> registerComponentInstance(T componentInstance) throws ContainerException
registerComponentImplementation(componentImplementation, componentImplementation).componentInstance - the instance of the component to registergetXXX() methods of the
Container interface can be used to retrieve a reference to the component later on.ContainerException - if registration fails.public <T> T createComponent(Class<T> clazz) throws Exception
Class with no parameters
This is equivalent to call AbstractContainer.createComponent(Class, InitParams) with
null as InitParamsclazz - the Class of the object to createException - if any issue occurs while creating the component.public ComponentAdapter<?> getComponentAdapter(Object componentKey)
componentKey - the key that the component was registered with.null if no component has been registered
for the specified key.public Object getComponentInstance(Object componentKey)
componentKey - the key that the component was registered with.null if no component has been registered for the specified
key.public Set<String> getRegisteredComponentNames() throws ContainerException
ContainerExceptionpublic ExoContainer getParent()
ExoContainer instance, or null if this container does not have a parent.public boolean canBeStarted()
true if it can be started, false otherwise.public boolean canBeStopped()
true if it can be stopped, false otherwise.public boolean canBeDisposed()
true if it can be disposed, false otherwise.protected boolean canBeInitialized()
true if it can be initialized, false otherwise.public ContextManager getContextManager()
ContextManager that has been registeredContextManager related to this container, null otherwise.public boolean isContextManagerLoaded()
ContextManager has already been loadedtrue if the ContextManager has been loaded,
false otherwise.public <T> T getComponentInstanceOfType(Class<T> componentType)
getComponentInstanceOfType(Class, boolean) with true for the parameter
autoRegistrationpublic <T> T getComponentInstanceOfType(Class<T> componentType, boolean autoRegistration)
DefinitionByType if the parameter
autoRegistration has been set to true.getComponentInstanceOfType in interface ContainergetComponentInstanceOfType in class AbstractContainercomponentType - the type of the component.autoRegistration - indicates whether the auto registration should be performed or notpublic <T> ComponentAdapter<T> getComponentAdapterOfType(Class<T> componentType)
getComponentAdapterOfType(Class, boolean) with true for the parameter
autoRegistrationcomponentType - the type of the component.null if no component has been
registered for the specified key.public <T> ComponentAdapter<T> getComponentAdapterOfType(Class<T> componentType, boolean autoRegistration)
DefinitionByType if the parameter
autoRegistration has been set to true.getComponentAdapterOfType in interface ContainergetComponentAdapterOfType in class AbstractContainercomponentType - 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 <T> T getComponentInstance(Object componentKey, Class<T> bindType)
getComponentInstance(Object, Class, boolean) with true for the parameter
autoRegistrationcomponentKey - the key that the component was registered with.bindType - the expected type of the instance if one can be found.null if no component has been registered for the specified
key.public <T> T getComponentInstance(Object componentKey, Class<T> bindType, boolean autoRegistration)
autoRegistration has been set to true, it will try to auto register the
component according to the content of:
DefinitionByType if the componentKey is a
classDefinitionByName if the componentKey is a
stringDefinitionByQualifier if the componentKey
is a qualifiergetComponentInstance in interface ContainergetComponentInstance in class AbstractContainercomponentKey - 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> ComponentAdapter<T> getComponentAdapter(Object componentKey, Class<T> bindType)
getComponentAdapter(Object, Class, boolean) with true for the parameter
autoRegistrationcomponentKey - the key that the component was registered with.bindType - the expected raw type of the adapter if one can be found.null if no component has been registered
for the specified key.public <T> ComponentAdapter<T> getComponentAdapter(Object componentKey, Class<T> bindType, boolean autoRegistration)
autoRegistration has been set to true, it will try to auto
register the component according to the content of:
DefinitionByType if the componentKey is a
classDefinitionByName if the componentKey is a
stringDefinitionByQualifier if the componentKey
is a qualifiergetComponentAdapter in interface ContainergetComponentAdapter in class AbstractContainercomponentKey - 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.Copyright © 2019 eXo Platform SAS. All Rights Reserved.