|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.avalon.fortress.util.ContextManager
You can get two different contexts from the ContextManager: the container context (m_childContext) and the container manager context (m_containerManagerContext)
You can get two different contexts from the ContextManager: the child context and the impl manager context. The former contains all managers, such as the pool manager etc. necessary for a child impl to create additional child containers. The impl manager context contains all of the child context, but also initialization parameters for the impl, such as a Configuration object, a ComponentLocator, etc., that the impl wants, but does not want to pass on to its children.
The container manager context is used to provide the container manager with all the data needed to initialize the container.
The container context is passed directly to the container.
The ContextManager will sometimes create new components, such as a service manager, a pool manager, etc. It will manage these components and dispose of them properly when it itself is disposed .
Field Summary | |
protected static Configuration |
EMPTY_CONFIG
|
protected DefaultContext |
m_childContext
The context of the new impl. |
protected DefaultContext |
m_containerManagerContext
Container manager's context. |
protected SourceResolver |
m_defaultSourceResolver
Source resolver used to read-in the configurations. |
protected InstrumentManager |
m_instrumentManager
The InstrumentManager to be used by the container. |
protected Logger |
m_logger
|
protected LoggerManager |
m_loggerManager
The logger manager in use. |
protected MetaInfoManager |
m_metaInfoManager
The MetaInfoManager to be used by the container. |
protected org.d_haven.mpool.PoolManager |
m_poolManager
The PoolManager to be used by the container. |
protected Logger |
m_primordialLogger
|
protected Context |
m_rootContext
The root context. |
protected org.d_haven.event.Sink |
m_sink
The Sink in use. |
protected org.d_haven.event.command.ThreadManager |
m_threadManager
The ThreadManager to be used by the container. |
Fields inherited from interface org.apache.avalon.fortress.util.ContextManagerConstants |
CONFIGURATION_URI, INSTRUMENT_MANAGER_CONFIGURATION, INSTRUMENT_MANAGER_CONFIGURATION_URI, LOG_CATEGORY, LOGGER_MANAGER_CONFIGURATION, LOGGER_MANAGER_CONFIGURATION_URI, ROLE_MANAGER_CLASS, ROLE_MANAGER_CONFIGURATION, ROLE_MANAGER_CONFIGURATION_URI |
Fields inherited from interface org.apache.avalon.fortress.ContainerManagerConstants |
COMMAND_FAILURE_HANDLER_CLASS, CONFIGURATION, CONTAINER_CLASS, LOGGER, PARAMETERS, SERVICE_MANAGER |
Fields inherited from interface org.apache.avalon.fortress.ContainerConstants |
CONTEXT_DIRECTORY, THREAD_TIMEOUT, THREADS_CPU, WORK_DIRECTORY |
Constructor Summary | |
ContextManager(Context rootContext,
Logger logger)
Create a new ContextManager. |
Method Summary | |
protected void |
assumeOwnership(java.lang.Object object)
Method to assume ownership of one of the managers the ContextManager created. |
protected void |
copyEntry(java.lang.String key)
Copies the specified entry from the rootContext to the
containerManagerContext . |
void |
dispose()
Disposes all items that this ContextManager has created. |
void |
disposeOwned()
Disposes all items ContextManager has assumed ownership over |
protected boolean |
entryPresent(Context context,
java.lang.String key)
Checks if a specified entry in context
has been supplied by the invoker. |
protected java.lang.Object |
get(Context context,
java.lang.String key,
java.lang.Object defaultValue)
Convenience method to obtain a value, or defer to a default if it does not exist. |
Context |
getChildContext()
Finalizes and returns the context. |
protected Configuration |
getConfiguration(java.lang.String configKey,
java.lang.String uriKey)
Get a configuration based on a config and URI key. |
Context |
getContainerManagerContext()
Finalizes and returns the context. |
protected Logger |
getLogger()
Get a reference the Logger. |
void |
initialize()
Initialize the ContextManager . |
protected void |
initializeCommandSink()
Set up the CommandSink to enable asynchronous management. |
protected void |
initializeConfiguration()
Load the configuration file that the Container will need to operate. |
protected void |
initializeContext()
Initialize the context that will be passed into the impl. |
protected void |
initializeDefaultSourceResolver()
Initialize the default source resolver |
protected void |
initializeInstrumentManager()
Will set up an InstrumentManager if none is supplied. |
protected void |
initializeLoggerManager()
Will set up a LogKitLoggerManager if none is supplied. |
protected void |
initializeMetaInfoManager()
|
protected void |
initializePoolManager()
Set up the Pool Manager for the managed pool. |
protected void |
initializeServiceManager()
Get a reference to the initial ComponentLocator used by the ContainerManager to hold the Components used for parsing the config files and setting up the environment. |
protected void |
initializeThreadManager()
|
protected RoleManager |
obtainRoleManager()
Set up a RoleManager for the Container if configuration for it has been supplied. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected static final Configuration EMPTY_CONFIG
protected final Context m_rootContext
protected final DefaultContext m_childContext
protected final DefaultContext m_containerManagerContext
protected Logger m_logger
protected final Logger m_primordialLogger
protected SourceResolver m_defaultSourceResolver
protected LoggerManager m_loggerManager
protected org.d_haven.event.Sink m_sink
protected MetaInfoManager m_metaInfoManager
protected org.d_haven.mpool.PoolManager m_poolManager
protected org.d_haven.event.command.ThreadManager m_threadManager
protected InstrumentManager m_instrumentManager
Constructor Detail |
public ContextManager(Context rootContext, Logger logger)
rootContext
- the default values.logger
- logger to use when creating new components.Method Detail |
protected void assumeOwnership(java.lang.Object object)
ContextManager
created. Ownership means that the
ContextManager
is responsible for destroying the
manager when the ContextManager
is destroyed.
object
- The object being claimed
java.lang.IllegalArgumentException
- if the object is null.public void initialize() throws java.lang.Exception
ContextManager
. This will cause the
ContextManager
to create any managers it needs.
initialize
in interface Initializable
java.lang.Exception
- if there is a problem at any point in the
initialization.protected void initializeConfiguration()
protected void initializeContext() throws java.lang.Exception
java.lang.Exception
- if any of the parameters cannot be copied properly.protected void copyEntry(java.lang.String key) throws ContextException
rootContext
to the
containerManagerContext
.
ContextException
- if the parameter does not existprotected boolean entryPresent(Context context, java.lang.String key)
context
has been supplied by the invoker.
context
- The context to checkkey
- The key name to checkpublic void dispose()
dispose
in interface Disposable
public void disposeOwned()
protected java.lang.Object get(Context context, java.lang.String key, java.lang.Object defaultValue)
context
- The context object we intend to get a value from.key
- The key we want to use to get the value.defaultValue
- The default value we return if the key does not
exist.protected void initializeCommandSink() throws java.lang.Exception
java.lang.Exception
- if the CommandSink
could not be
created.protected void initializePoolManager() throws java.lang.Exception
java.lang.Exception
- if there is an error.protected RoleManager obtainRoleManager() throws java.lang.Exception
java.lang.Exception
- if there is an error.protected void initializeMetaInfoManager() throws java.lang.Exception
java.lang.Exception
protected void initializeDefaultSourceResolver() throws java.lang.Exception
java.lang.Exception
- when there is an error.protected void initializeServiceManager() throws java.lang.Exception
java.lang.Exception
- when there is an error.protected Configuration getConfiguration(java.lang.String configKey, java.lang.String uriKey)
configKey
- Get the Configuration
object directly
from the context.uriKey
- Get the uri from the context.public Context getContainerManagerContext()
Context
public Context getChildContext()
Context
protected Logger getLogger()
Logger
protected void initializeLoggerManager() throws java.lang.Exception
The postcondition is that
childContext.get( LoggerManager.ROLE )
should
return a valid logger manager.
java.lang.Exception
- if it cannot instantiate the LoggerManagerprotected void initializeThreadManager() throws java.lang.Exception
java.lang.Exception
protected void initializeInstrumentManager() throws java.lang.Exception
The postcondition is that
childContext.get( InstrumentManager.ROLE )
should
return a valid instrument manager.
java.lang.Exception
- if it cannot instantiate the InstrumentManager
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |