Skip navigation links

Oracle® Fusion Middleware Java API Reference for Oracle Coherence
12c (12.1.3.0.0)

E47890-01


com.tangosol.application
Class ContainerAdapter

java.lang.Object
  extended by com.tangosol.application.ContainerAdapter


public class ContainerAdapter
extends java.lang.Object

ContainerAdapter is a facility intended for use by application servers to host Coherence applications. This facility manages the application life cycle and configuration.

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
static class ContainerAdapter.ApplicationScopeResolver
          The ContainerAdapter.ApplicationScopeResolver is a ScopeResolver typically used to make sure the Coherence Services are scoped to the name passed in the constructor.
protected  class ContainerAdapter.ContainerCacheFactoryBuilder
          ContainerCacheFactoryBuilder creates a ConfigurableCacheFactory instance using the knowledge from this ContainerAdapter instance.
static class ContainerAdapter.DefaultContext
          The ContainerAdapter.DefaultContext represents the context for an application.
static class ContainerAdapter.DefaultExtendedContext
          The ContainerAdapter.DefaultContext represents the context for an application.

 

Field Summary
protected static java.lang.String CACHE_URI_DEFAULT
          Internally used "default" URI identifier.
protected  ContainerAdapter.ContainerCacheFactoryBuilder m_builder
          The ContainerAdapter.ContainerCacheFactoryBuilder used to create a ConfigurableCacheFactory for the application.
protected  Context m_context
          The ContainerAdapter.DefaultContext for the application.
protected  boolean m_fActivated
          Indicates whether the ContainerAdapter has been activated or not.
protected  ConfigurableCacheFactory m_factory
          The ConfigurableCacheFactory for the application.
protected  boolean m_fExclusiveMonitor
          Indicates whether the ServiceMonitor has been exclusively created for this ContainerAdapter.
protected  LifecycleListener m_listener
          The LifecycleListener used for lifecycle callbacks to the application.
protected  java.lang.ClassLoader m_loader
          The ClassLoader for the application.
protected  java.lang.ClassLoader m_loaderCtx
          The caller's thread context ClassLoader.
protected  java.util.Map m_mapStartedServices
           
protected  java.lang.String m_sAppDescriptorURI
          The URI to the coherence-application.xml file.
protected  java.lang.String m_sAppName
          The name of the application.
protected  ScopeResolver m_scopeResolver
          The ScopeResolver to use.
protected  ServiceMonitor m_serviceMonitor
          The ServiceMonitor to use.
protected  XmlElement m_xmlAppDescriptor
          The XmlElement representing the application descriptor.

 

Constructor Summary
ContainerAdapter(java.lang.ClassLoader loader, java.lang.String sAppDescriptorURI, java.lang.String sAppName)
          Construct the ContainerAdapter.
ContainerAdapter(java.lang.ClassLoader loader, java.lang.String sAppDescriptorURI, java.lang.String sAppName, CacheFactoryBuilder builder, ScopeResolver scopeResolver, XmlElement xmlAppDescriptor, ServiceMonitor serviceMonitor)
          Construct the ContainerAdapter.
ContainerAdapter(java.lang.ClassLoader loader, java.lang.String sAppDescriptorURI, java.lang.String sAppName, XmlElement xmlAppDescriptor)
          Construct the ContainerAdapter.

 

Method Summary
 void activate()
          Initialize and start the application that is hosted by this ContainerAdapter.
 void associateWithClassLoader(java.lang.ClassLoader[] aClassLoaders)
          Associates the application hosted by this ContainerAdapter with specified ClassLoaders.
 void deactivate()
          Deactivate the application hosted by this ContainerAdapter.
 void deactivate(boolean fShutdown)
          Deactivate the application hosted by this ContainerAdapter.
protected  void ensureContextClassLoader()
          Ensure that the thread context ClassLoader is set to the ContainerAdapter ClassLoader; save the current thread context ClassLoader if necessary.
protected static XmlElement extractFactoryConfig(XmlElement xmlAppDescriptor)
          Extract the XmlElement representing the factory for the ConfigurableCacheFactory instance.
 java.lang.ClassLoader getContextClassLoader()
          Return the ClassLoader used by this ContainerAdapter.
protected  void restoreContextClassLoader()
          Restore the thread context ClassLoader for the caller.

 

Field Detail

CACHE_URI_DEFAULT

protected static final java.lang.String CACHE_URI_DEFAULT
Internally used "default" URI identifier.
See Also:
Constant Field Values

m_serviceMonitor

protected final ServiceMonitor m_serviceMonitor
The ServiceMonitor to use.

m_builder

protected ContainerAdapter.ContainerCacheFactoryBuilder m_builder
The ContainerAdapter.ContainerCacheFactoryBuilder used to create a ConfigurableCacheFactory for the application.

m_factory

protected ConfigurableCacheFactory m_factory
The ConfigurableCacheFactory for the application.

m_loader

protected java.lang.ClassLoader m_loader
The ClassLoader for the application.

m_sAppDescriptorURI

protected java.lang.String m_sAppDescriptorURI
The URI to the coherence-application.xml file.

m_xmlAppDescriptor

protected XmlElement m_xmlAppDescriptor
The XmlElement representing the application descriptor.

m_sAppName

protected java.lang.String m_sAppName
The name of the application.

m_scopeResolver

protected ScopeResolver m_scopeResolver
The ScopeResolver to use.

m_listener

protected LifecycleListener m_listener
The LifecycleListener used for lifecycle callbacks to the application.

m_context

protected Context m_context
The ContainerAdapter.DefaultContext for the application.

m_loaderCtx

protected java.lang.ClassLoader m_loaderCtx
The caller's thread context ClassLoader.

m_fActivated

protected boolean m_fActivated
Indicates whether the ContainerAdapter has been activated or not.

m_fExclusiveMonitor

protected boolean m_fExclusiveMonitor
Indicates whether the ServiceMonitor has been exclusively created for this ContainerAdapter.

m_mapStartedServices

protected java.util.Map m_mapStartedServices

Constructor Detail

ContainerAdapter

public ContainerAdapter(java.lang.ClassLoader loader,
                        java.lang.String sAppDescriptorURI,
                        java.lang.String sAppName)
Construct the ContainerAdapter.
Parameters:
loader - the ClassLoader for the application
sAppDescriptorURI - the URI to coherence-application.xml
sAppName - the name of the application

ContainerAdapter

public ContainerAdapter(java.lang.ClassLoader loader,
                        java.lang.String sAppDescriptorURI,
                        java.lang.String sAppName,
                        XmlElement xmlAppDescriptor)
Construct the ContainerAdapter.
Parameters:
loader - the ClassLoader for the application
sAppDescriptorURI - the URI to coherence-application.xml
sAppName - the name of the application
xmlAppDescriptor - the XmlElement containing the application descriptor; if not null it will be used instead of the configuration specified by sAppDescriptorURI

ContainerAdapter

public ContainerAdapter(java.lang.ClassLoader loader,
                        java.lang.String sAppDescriptorURI,
                        java.lang.String sAppName,
                        CacheFactoryBuilder builder,
                        ScopeResolver scopeResolver,
                        XmlElement xmlAppDescriptor,
                        ServiceMonitor serviceMonitor)
Construct the ContainerAdapter.
Parameters:
loader - the ClassLoader for the application
sAppDescriptorURI - the URI to the application configuration descriptor
sAppName - the name of the application
builder - the CacheFactoryBuilder to use
scopeResolver - the ScopeResolver to use for services used by this application
xmlAppDescriptor - the XmlElement containing the application descriptor; if not null it will be used instead of the configuration specified by sAppDescriptorURI
serviceMonitor - the ServiceMonitor to use for the application

Method Detail

activate

public void activate()
Initialize and start the application that is hosted by this ContainerAdapter. If activate throws an exception, the caller is NOT required to call deactivate().
Throws:
java.lang.IllegalStateException - if the application has already been activated

deactivate

public void deactivate()
Deactivate the application hosted by this ContainerAdapter. This method will shutdown any resources / Coherence services that were used by the application.
Throws:
java.lang.IllegalStateException - if the application is not active

deactivate

public void deactivate(boolean fShutdown)
Deactivate the application hosted by this ContainerAdapter. If fShutdown is true shutdown any resources / Coherence services that were used by the application otherwise clear local references.
Parameters:
fShutdown - whether to shutdown the resources, incl. any services, that were started as a part of this application
Throws:
java.lang.IllegalStateException - if the application is not active

associateWithClassLoader

public void associateWithClassLoader(java.lang.ClassLoader[] aClassLoaders)
Associates the application hosted by this ContainerAdapter with specified ClassLoaders.
Parameters:
aClassLoaders - an array of ClassLoaders to associate this adapter with

getContextClassLoader

public java.lang.ClassLoader getContextClassLoader()
Return the ClassLoader used by this ContainerAdapter.
Returns:
the ClassLoader used by this ContainerAdapter

extractFactoryConfig

protected static XmlElement extractFactoryConfig(XmlElement xmlAppDescriptor)
Extract the XmlElement representing the factory for the ConfigurableCacheFactory instance.
Parameters:
xmlAppDescriptor - the application descriptor XML element
Returns:
the XmlElement representing the factory or null if no element exists.

ensureContextClassLoader

protected void ensureContextClassLoader()
Ensure that the thread context ClassLoader is set to the ContainerAdapter ClassLoader; save the current thread context ClassLoader if necessary.

restoreContextClassLoader

protected void restoreContextClassLoader()
Restore the thread context ClassLoader for the caller.

Skip navigation links

Oracle® Fusion Middleware Java API Reference for Oracle Coherence
12c (12.1.3.0.0)

E47890-01


Copyright © 2000, 2014, Oracle and/or its affiliates. All rights reserved.