public class ExoContainer
extends org.exoplatform.container.AbstractContainer
Container
which allows eXo to apply
the Inversion of Control (also known as IoC) principles.Modifier and Type | Field and Description |
---|---|
protected org.exoplatform.container.ExoContainerContext |
context |
protected static org.exoplatform.services.log.Log |
LOG |
protected ExoContainer |
parent |
protected AtomicBoolean |
stopping |
Constructor and Description |
---|
ExoContainer() |
ExoContainer(ExoContainer parent) |
Modifier and Type | Method and Description |
---|---|
void |
addComponentLifecylePlugin(org.exoplatform.container.component.ComponentLifecyclePlugin plugin) |
void |
addContainerLifecylePlugin(org.exoplatform.container.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() |
org.exoplatform.container.spi.ComponentAdapter<?> |
getComponentAdapter(Object componentKey)
Find a component adapter associated with the specified key.
|
<T> org.exoplatform.container.spi.ComponentAdapter<T> |
getComponentAdapter(Object componentKey,
Class<T> bindType)
This method is equivalent to
getComponentAdapter(Object, Class, boolean) with true for the parameter
autoRegistration |
<T> org.exoplatform.container.spi.ComponentAdapter<T> |
getComponentAdapter(Object componentKey,
Class<T> bindType,
boolean autoRegistration)
Find a component adapter associated with the specified key.
|
<T> org.exoplatform.container.spi.ComponentAdapter<T> |
getComponentAdapterOfType(Class<T> componentType)
This method is equivalent to
getComponentAdapterOfType(Class, boolean) with true for the parameter
autoRegistration |
<T> org.exoplatform.container.spi.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 org.exoplatform.container.xml.Configuration |
getConfiguration()
Gets the
ConfigurationManager from the given ExoContainer if it exists,
then returns the nested Configuration otherwise it returns null |
org.exoplatform.container.ExoContainerContext |
getContext() |
org.exoplatform.container.context.ContextManager |
getContextManager()
Gives the
ContextManager that has been registered |
protected Collection<org.exoplatform.container.xml.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() |
boolean |
isContextManagerLoaded()
Indicates whether or not the
ContextManager has already been loaded |
<T> org.exoplatform.container.spi.ComponentAdapter<T> |
registerComponentImplementation(Class<T> componentImplementation)
Register a component using the componentImplementation as key.
|
<T> org.exoplatform.container.spi.ComponentAdapter<T> |
registerComponentInstance(T componentInstance)
Register an arbitrary object.
|
void |
start() |
void |
start(boolean init)
Starts the container
|
void |
stop() |
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, unregisterComponent
protected final AtomicBoolean stopping
protected static final org.exoplatform.services.log.Log LOG
protected final org.exoplatform.container.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 org.exoplatform.container.ExoContainerContext getContext()
protected void initContainerInternal()
public void dispose()
org.exoplatform.container.AbstractContainer
dispose
in interface org.picocontainer.Disposable
dispose
in class org.exoplatform.container.AbstractContainer
public void start(boolean init)
init
- indicates if the container must be initialized firstpublic void initialize()
org.exoplatform.container.AbstractContainer
initialize
in interface org.exoplatform.container.spi.Container
initialize
in class org.exoplatform.container.AbstractContainer
public void start()
org.exoplatform.container.AbstractContainer
start
in interface org.picocontainer.Startable
start
in class org.exoplatform.container.AbstractContainer
public void stop()
org.exoplatform.container.AbstractContainer
stop
in interface org.picocontainer.Startable
stop
in class org.exoplatform.container.AbstractContainer
public void addComponentLifecylePlugin(org.exoplatform.container.component.ComponentLifecyclePlugin plugin)
public void addContainerLifecylePlugin(org.exoplatform.container.ContainerLifecyclePlugin plugin)
protected org.exoplatform.container.xml.Configuration getConfiguration()
ConfigurationManager
from the given ExoContainer
if it exists,
then returns the nested Configuration
otherwise it returns null
protected Collection<org.exoplatform.container.xml.ExternalComponentPlugins> getExternalComponentPluginsUnused()
ExternalComponentPlugins
that have not been used, null
if there are all used.protected void unregisterAllComponents()
public <T> org.exoplatform.container.spi.ComponentAdapter<T> registerComponentImplementation(Class<T> componentImplementation) throws org.exoplatform.container.spi.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.org.exoplatform.container.spi.ContainerException
- if registration fails.public <T> org.exoplatform.container.spi.ComponentAdapter<T> registerComponentInstance(T componentInstance) throws org.exoplatform.container.spi.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.org.exoplatform.container.spi.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 InitParams
clazz
- the Class of the object to createException
- if any issue occurs while creating the component.public org.exoplatform.container.spi.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 org.exoplatform.container.spi.ContainerException
org.exoplatform.container.spi.ContainerException
public 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 org.exoplatform.container.context.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
autoRegistration
public <T> T getComponentInstanceOfType(Class<T> componentType, boolean autoRegistration)
DefinitionByType
if the parameter
autoRegistration
has been set to true
.getComponentInstanceOfType
in interface org.exoplatform.container.spi.Container
getComponentInstanceOfType
in class org.exoplatform.container.AbstractContainer
componentType
- the type of the component.autoRegistration
- indicates whether the auto registration should be performed or notpublic <T> org.exoplatform.container.spi.ComponentAdapter<T> getComponentAdapterOfType(Class<T> componentType)
getComponentAdapterOfType(Class, boolean)
with true
for the parameter
autoRegistration
componentType
- the type of the component.null
if no component has been
registered for the specified key.public <T> org.exoplatform.container.spi.ComponentAdapter<T> getComponentAdapterOfType(Class<T> componentType, boolean autoRegistration)
DefinitionByType
if the parameter
autoRegistration
has been set to true
.getComponentAdapterOfType
in interface org.exoplatform.container.spi.Container
getComponentAdapterOfType
in class org.exoplatform.container.AbstractContainer
componentType
- 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
autoRegistration
componentKey
- 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 org.exoplatform.container.spi.Container
getComponentInstance
in class org.exoplatform.container.AbstractContainer
componentKey
- 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> org.exoplatform.container.spi.ComponentAdapter<T> getComponentAdapter(Object componentKey, Class<T> bindType)
getComponentAdapter(Object, Class, boolean)
with true
for the parameter
autoRegistration
componentKey
- 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> org.exoplatform.container.spi.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 org.exoplatform.container.spi.Container
getComponentAdapter
in class org.exoplatform.container.AbstractContainer
componentKey
- 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 © 2003–2019 eXo Platform SAS. All rights reserved.