Class ContainerAdapter
The application descriptor file (coherence-application.xml) contains the
location of a cache configuration file and (optionally) a POF configuration file.
It may also specify the name of a ConfigurableCacheFactory class to be
used to create caches instead of the system-wide default
(Note that this class must implement ExtensibleConfigurableCacheFactory).
After creating an instance of ContainerAdapter. the container should call
activate() to start the application and deactivate() to stop it.
- Since:
- Coherence 12.1.2
- Author:
- cf 2011.05.24
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceA factory for producing aCoherenceinstance.protected classContainerCacheFactoryBuilder creates aConfigurableCacheFactoryinstance using the knowledge from this ContainerAdapter instance.static classA default implementation of aContainerAdapter.CoherenceFactory.static classTheContainerAdapter.DefaultContextrepresents the context for an application. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final StringInternally used "default" URI identifier.protected final ServiceMonitorTheServiceMonitorto use.TheContainerAdapter.ContainerCacheFactoryBuilderused to create aConfigurableCacheFactoryfor the application.protected CoherenceThe Coherence instance.protected ContainerContextThe ContainerContext.protected ContainerAdapter.DefaultContextTheContextfor the application.protected booleanIndicates whether the ContainerAdapter has been activated or not.protected ExtensibleConfigurableCacheFactoryTheConfigurableCacheFactoryfor the application.protected booleanIndicates whether the ServiceMonitor has been exclusively created for this ContainerAdapter.protected LifecycleListenerTheLifecycleListenerused for lifecycle callbacks to the application.protected List<LifecycleListener> TheLifecycleListeners to be notified of lifecycle events for thisContainerAdapter.protected ClassLoaderTheClassLoaderfor the application.protected ClassLoaderThe caller's thread contextClassLoader.protected StringThe URI to the coherence-application.xml file.protected StringThe name of the application.protected XmlElementTheXmlElementrepresenting the application descriptor. -
Constructor Summary
ConstructorsConstructorDescriptionContainerAdapter(ClassLoader loader, String sAppDescriptorURI, String sAppName) Construct the ContainerAdapter.ContainerAdapter(ClassLoader loader, String sAppDescriptorURI, String sAppName, CacheFactoryBuilder builder, XmlElement xmlAppDescriptor, ServiceMonitor serviceMonitor) Construct the ContainerAdapter.ContainerAdapter(ClassLoader loader, String sAppDescriptorURI, String sAppName, XmlElement xmlAppDescriptor) Construct the ContainerAdapter. -
Method Summary
Modifier and TypeMethodDescriptionvoidactivate()Initialize and start the application that is hosted by this ContainerAdapter.voidassociateWithClassLoader(ClassLoader[] aClassLoaders) Associates the application hosted by this ContainerAdapter with specifiedClassLoaders.voidDeactivate the application hosted by this ContainerAdapter.voiddeactivate(boolean fShutdown) Deactivate the application hosted by this ContainerAdapter.protected voidEnsure that the thread context ClassLoader is set to the ContainerAdapter's ClassLoader; save the current thread context ClassLoader if necessary.protected static XmlElementextractFactoryConfig(XmlElement xmlAppDescriptor) Extract theXmlElementrepresenting the factory for theConfigurableCacheFactoryinstance.Return theContextfor the application.Return theCoherenceinstance used by this ContainerAdapter.Return theContainerContextused by this ContainerAdapter.Return the ClassLoader used by this ContainerAdapter.protected List<LifecycleListener> Returns an unmodifiable list ofLifecycleListeners registered for thisContainerAdapter.protected voidRestore the thread contextClassLoaderfor the caller.voidSet theContainerAdapter.CoherenceFactoryto use to createCoherenceinstances.voidSet the ContainerContext associated with this ContainerAdapter instance.
-
Field Details
-
CACHE_URI_DEFAULT
-
f_serviceMonitor
TheServiceMonitorto use. -
m_builder
TheContainerAdapter.ContainerCacheFactoryBuilderused to create aConfigurableCacheFactoryfor the application. -
m_factory
TheConfigurableCacheFactoryfor the application. -
m_coherence
The Coherence instance. -
m_loader
TheClassLoaderfor the application. -
m_sAppDescriptorURI
The URI to the coherence-application.xml file. -
m_xmlAppDescriptor
TheXmlElementrepresenting the application descriptor. -
m_sAppName
The name of the application. -
m_containerCtx
The ContainerContext. -
m_listener
TheLifecycleListenerused for lifecycle callbacks to the application. -
m_listLifecycleListener
TheLifecycleListeners to be notified of lifecycle events for thisContainerAdapter.The
LifecycleListeners will be discovered and loaded using theServiceLoader. -
m_context
TheContextfor the application. -
m_loaderCtx
The caller's thread contextClassLoader. -
m_fActivated
protected boolean m_fActivatedIndicates whether the ContainerAdapter has been activated or not. -
m_fExclusiveMonitor
protected boolean m_fExclusiveMonitorIndicates whether the ServiceMonitor has been exclusively created for this ContainerAdapter.
-
-
Constructor Details
-
ContainerAdapter
Construct the ContainerAdapter.- Parameters:
loader- theClassLoaderfor the applicationsAppDescriptorURI- the URI to coherence-application.xmlsAppName- the name of the application
-
ContainerAdapter
public ContainerAdapter(ClassLoader loader, String sAppDescriptorURI, String sAppName, XmlElement xmlAppDescriptor) Construct the ContainerAdapter.- Parameters:
loader- theClassLoaderfor the applicationsAppDescriptorURI- the URI to coherence-application.xmlsAppName- the name of the applicationxmlAppDescriptor- theXmlElementcontaining the application descriptor; if not null it will be used instead of the configuration specified by sAppDescriptorURI
-
ContainerAdapter
public ContainerAdapter(ClassLoader loader, String sAppDescriptorURI, String sAppName, CacheFactoryBuilder builder, XmlElement xmlAppDescriptor, ServiceMonitor serviceMonitor) Construct the ContainerAdapter.- Parameters:
loader- theClassLoaderfor the applicationsAppDescriptorURI- the URI to the application configuration descriptorsAppName- the name of the applicationbuilder- theCacheFactoryBuilderto usexmlAppDescriptor- theXmlElementcontaining the application descriptor; if not null it will be used instead of the configuration specified by sAppDescriptorURIserviceMonitor- theServiceMonitorto use for the application
-
-
Method Details
-
setContainerContext
Set the ContainerContext associated with this ContainerAdapter instance.This method must be called before the adapter is
activated.- Parameters:
ctx- the ContainerContext reference
-
activate
public void activate()Initialize and start the application that is hosted by this ContainerAdapter.If this method throws an exception, the caller is NOT required to call
deactivate().- Throws:
IllegalStateException- if the application has already been activated
-
deactivate
public void deactivate()Deactivate the application hosted by this ContainerAdapter. This method will shut down any resources / Coherence services that were used by the application.- Throws:
IllegalStateException- if the application is not active
-
deactivate
public void deactivate(boolean fShutdown) Deactivate the application hosted by this ContainerAdapter. IffShutdownis true shutdown any resources / Coherence services that were used by the application otherwise clear local references.- Parameters:
fShutdown- whether to shut down the resources, incl. any services, that were started as a part of this application- Throws:
IllegalStateException- if the application is not active
-
associateWithClassLoader
Associates the application hosted by this ContainerAdapter with specifiedClassLoaders.- Parameters:
aClassLoaders- an array ofClassLoaders to associate this adapter with
-
getContextClassLoader
Return the ClassLoader used by this ContainerAdapter.- Returns:
- the ClassLoader used by this ContainerAdapter
-
getApplicationContext
-
getContainerContext
Return theContainerContextused by this ContainerAdapter.- Returns:
- the
ContainerContextused by this ContainerAdapter.
-
getCoherence
-
setCoherenceFactory
Set theContainerAdapter.CoherenceFactoryto use to createCoherenceinstances.- Parameters:
factory- theContainerAdapter.CoherenceFactoryto use to createCoherenceinstances
-
getLifecycleListeners
Returns an unmodifiable list ofLifecycleListeners registered for thisContainerAdapter.If the list of listeners does not yet exist it will be created and initially populated using the
ServiceLoaderto discover and load listeners.- Returns:
- the list of
LifecycleListeners registered for thisContainerAdapter
-
extractFactoryConfig
Extract theXmlElementrepresenting the factory for theConfigurableCacheFactoryinstance.- Parameters:
xmlAppDescriptor- the application descriptor XML element- Returns:
- the
XmlElementrepresenting the factory or null if no element exists.
-
ensureContextClassLoader
protected void ensureContextClassLoader()Ensure that the thread context ClassLoader is set to the ContainerAdapter's ClassLoader; save the current thread context ClassLoader if necessary. -
restoreContextClassLoader
protected void restoreContextClassLoader()Restore the thread contextClassLoaderfor the caller.
-