org.apache.geronimo.kernel.config
Class Configuration

java.lang.Object
  extended by org.apache.geronimo.kernel.config.Configuration
All Implemented Interfaces:
GBeanLifecycle, ConfigurationParent

@GBean
public class Configuration
extends Object
implements GBeanLifecycle, ConfigurationParent

A Configuration represents a collection of runnable services that can be loaded into a Geronimo Kernel and brought online. The primary components in a Configuration are a codebase, represented by a collection of URLs that is used to locate classes, and a collection of GBean instances that define its state.

The persistent attributes of the Configuration are:

When a configuration is started, it converts the URIs into a set of absolute URLs by resolving them against the specified baseURL (this would typically be the root of the CAR file which contains the configuration) and then constructs a ClassLoader for that codebase. That ClassLoader is then used to de-serialize the persisted GBeans, ensuring the GBeans can be recycled as necessary. Once the GBeans have been restored, they are brought online by registering them with the MBeanServer.

A dependency on the Configuration is created for every GBean it loads. As a result, a startRecursive() operation on the configuration will result in a startRecursive() for all the GBeans it contains. Similarly, if the Configuration is stopped then all of its GBeans will be stopped as well.

Version:
$Rev:385718 $ $Date: 2012-04-28 10:17:12 +0800 (Sat, 28 Apr 2012) $

Constructor Summary
Configuration(ConfigurationData configurationData, DependencyNode dependencyNode, List<Configuration> allServiceParents, ManageableAttributeStore attributeStore, ConfigurationResolver configurationResolver, ConfigurationManager configurationManager)
          Creates a configuration.
 
Method Summary
 void addGBean(GBeanData gbean)
           
 AbstractName addGBean(String name, GBeanData gbean)
           
 boolean containsGBean(AbstractName gbean)
          Determines of this configuration constains the specified GBean.
 void doFail()
          Fails the GBean.
 void doStart()
          Starts the GBean.
 void doStop()
          Stops the target.
 AbstractName findGBean(AbstractNameQuery pattern)
           
 AbstractName findGBean(ReferencePatterns referencePatterns)
           
 AbstractName findGBean(Set<AbstractNameQuery> patterns)
           
 GBeanData findGBeanData(AbstractNameQuery pattern)
           
 GBeanData findGBeanData(Set<AbstractNameQuery> patterns)
           
 LinkedHashSet<GBeanData> findGBeanDatas(Configuration configuration, Set<AbstractNameQuery> patterns)
          Find the gbeanDatas matching the patterns in this configuration only, ignoring parents.
 LinkedHashSet<GBeanData> findGBeanDatas(Set<AbstractNameQuery> patterns)
           
 LinkedHashSet<AbstractName> findGBeans(AbstractNameQuery pattern)
           
 LinkedHashSet<AbstractName> findGBeans(ReferencePatterns referencePatterns)
           
 LinkedHashSet<AbstractName> findGBeans(Set<AbstractNameQuery> patterns)
           
 AbstractName getAbstractName()
           
 org.osgi.framework.Bundle getBundle()
          Gets the class loader for this configuration.
 org.osgi.framework.BundleContext getBundleContext()
           
 List<Configuration> getChildren()
          Gets the nested configurations of this configuration.
static AbstractName getConfigurationAbstractName(Artifact configId)
          Converts an Artifact to an AbstractName for a configuration.
 File getConfigurationDir()
           
static Artifact getConfigurationID(ObjectName objectName)
           
 ConfigurationResolver getConfigurationResolver()
          Provide a way to locate where this configuration is for web apps and persistence units
 long getCreated()
          Gets the time at which this configuration was created (or deployed).
 DependencyNode getDependencyNode()
          Gets the parent configurations used for service resolution.
 Configuration getEnclosingConfiguration()
          Gets the enclosing configuration of this one (e.g.
 Environment getEnvironment()
          Gets the declaration of the environment in which this configuration runs.
 Map<AbstractName,GBeanData> getGBeans()
          Gets an unmodifiable collection of the GBeanDatas for the GBeans in this configuration.
 Artifact getId()
          Return the unique Id
 ConfigurationModuleType getModuleType()
          Gets the type of the configuration (WAR, RAR et cetera)
 String getObjectName()
          Gets the unique name of this configuration within the kernel.
 Set<Artifact> getOwnedConfigurations()
          Gets the configurations owned by this configuration.
static boolean isConfigurationObjectName(ObjectName name)
           
 void removeGBean(AbstractName name)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Configuration

public Configuration(@ParamAttribute(name="configurationData")
                     ConfigurationData configurationData,
                     @ParamAttribute(name="dependencyNode")
                     DependencyNode dependencyNode,
                     @ParamAttribute(name="allServiceParents")
                     List<Configuration> allServiceParents,
                     @ParamAttribute(name="attributeStore")
                     ManageableAttributeStore attributeStore,
                     @ParamAttribute(name="configurationResolver")
                     ConfigurationResolver configurationResolver,
                     @ParamAttribute(name="configurationManager")
                     ConfigurationManager configurationManager)
              throws InvalidConfigException
Creates a configuration. // * @param classLoaderHolder Classloaders for this configuration

Parameters:
configurationData - the module type, environment and classpath of the configuration
dependencyNode - Class and Service parent ids
allServiceParents - ordered list of transitive closure of service parents for gbean searches
attributeStore - Customization info for gbeans
configurationResolver - (there should be a better way) Where this configuration is actually located in file system
Throws:
InvalidConfigException - if this configuration turns out to have a problem.
Method Detail

getConfigurationAbstractName

public static AbstractName getConfigurationAbstractName(Artifact configId)
                                                 throws InvalidConfigException
Converts an Artifact to an AbstractName for a configuration. Does not validate that this is a reasonable or resolved Artifact, or that it corresponds to an actual Configuration.

Parameters:
configId - id for configuration
Returns:
abstract name constructed from supplied id
Throws:
InvalidConfigException - if the ObjectName could not be constructed

isConfigurationObjectName

public static boolean isConfigurationObjectName(ObjectName name)

getConfigurationID

public static Artifact getConfigurationID(ObjectName objectName)

getId

public Artifact getId()
Return the unique Id

Returns:
the unique Id

getObjectName

public String getObjectName()
Gets the unique name of this configuration within the kernel.

Returns:
the unique name of this configuration

getAbstractName

public AbstractName getAbstractName()

getDependencyNode

public DependencyNode getDependencyNode()
Gets the parent configurations used for service resolution.

Returns:
the parents of this configuration used for service resolution

getEnvironment

public Environment getEnvironment()
Gets the declaration of the environment in which this configuration runs.

Returns:
the environment of this configuration

getConfigurationDir

public File getConfigurationDir()

getConfigurationResolver

public ConfigurationResolver getConfigurationResolver()
Provide a way to locate where this configuration is for web apps and persistence units

Returns:
the ConfigurationResolver for this configuration

getModuleType

public ConfigurationModuleType getModuleType()
Gets the type of the configuration (WAR, RAR et cetera)

Returns:
Type of the configuration.

getCreated

public long getCreated()
Gets the time at which this configuration was created (or deployed).

Returns:
the time at which this configuration was created (or deployed)

getBundle

public org.osgi.framework.Bundle getBundle()
Gets the class loader for this configuration.

Specified by:
getBundle in interface ConfigurationParent
Returns:
the bundle for this configuration

getBundleContext

public org.osgi.framework.BundleContext getBundleContext()

getChildren

public List<Configuration> getChildren()
Gets the nested configurations of this configuration. That is, the configurations within this one as a WAR can be within an EAR; not including wholly separate configurations that just depend on this one as a parent.

Returns:
the nested configuration of this configuration

getOwnedConfigurations

public Set<Artifact> getOwnedConfigurations()
Gets the configurations owned by this configuration. This is only used for cascade-uninstall.

Returns:
the configurations owned by this configuration

getGBeans

public Map<AbstractName,GBeanData> getGBeans()
Gets an unmodifiable collection of the GBeanDatas for the GBeans in this configuration.

Returns:
the GBeans in this configuration

containsGBean

public boolean containsGBean(AbstractName gbean)
Determines of this configuration constains the specified GBean.

Parameters:
gbean - the name of the GBean
Returns:
true if this configuration contains the specified GBean; false otherwise

getEnclosingConfiguration

public Configuration getEnclosingConfiguration()
Gets the enclosing configuration of this one (e.g. the EAR for a WAR), or null if it has none.

Returns:
enclosing configuration, if any

addGBean

public AbstractName addGBean(String name,
                             GBeanData gbean)
                      throws GBeanAlreadyExistsException
Throws:
GBeanAlreadyExistsException

addGBean

public void addGBean(GBeanData gbean)
              throws GBeanAlreadyExistsException
Throws:
GBeanAlreadyExistsException

removeGBean

public void removeGBean(AbstractName name)
                 throws GBeanNotFoundException
Throws:
GBeanNotFoundException

findGBean

public AbstractName findGBean(AbstractNameQuery pattern)
                       throws GBeanNotFoundException
Throws:
GBeanNotFoundException

findGBeanData

public GBeanData findGBeanData(AbstractNameQuery pattern)
                        throws GBeanNotFoundException
Throws:
GBeanNotFoundException

findGBean

public AbstractName findGBean(ReferencePatterns referencePatterns)
                       throws GBeanNotFoundException
Throws:
GBeanNotFoundException

findGBean

public AbstractName findGBean(Set<AbstractNameQuery> patterns)
                       throws GBeanNotFoundException
Throws:
GBeanNotFoundException

findGBeanData

public GBeanData findGBeanData(Set<AbstractNameQuery> patterns)
                        throws GBeanNotFoundException
Throws:
GBeanNotFoundException

findGBeans

public LinkedHashSet<AbstractName> findGBeans(AbstractNameQuery pattern)

findGBeans

public LinkedHashSet<AbstractName> findGBeans(ReferencePatterns referencePatterns)

findGBeans

public LinkedHashSet<AbstractName> findGBeans(Set<AbstractNameQuery> patterns)

findGBeanDatas

public LinkedHashSet<GBeanData> findGBeanDatas(Set<AbstractNameQuery> patterns)

findGBeanDatas

public LinkedHashSet<GBeanData> findGBeanDatas(Configuration configuration,
                                               Set<AbstractNameQuery> patterns)
Find the gbeanDatas matching the patterns in this configuration only, ignoring parents.

Parameters:
configuration - configuration to look in
patterns - patterns to look for
Returns:
set of gbeandatas matching one of the patterns from this configuration only, not including parents.

doStart

public void doStart()
             throws Exception
Description copied from interface: GBeanLifecycle
Starts the GBean. This informs the GBean that it is about to transition to the running state.

Specified by:
doStart in interface GBeanLifecycle
Throws:
Exception - if the target failed to start; this will cause a transition to the failed state

doStop

public void doStop()
            throws Exception
Description copied from interface: GBeanLifecycle
Stops the target. This informs the GBean that it is about to transition to the stopped state.

Specified by:
doStop in interface GBeanLifecycle
Throws:
Exception - if the target failed to stop; this will cause a transition to the failed state

doFail

public void doFail()
Description copied from interface: GBeanLifecycle
Fails the GBean. This informs the GBean that it is about to transition to the failed state.

Specified by:
doFail in interface GBeanLifecycle


Copyright © 2003-2013 The Apache Geronimo development community. All Rights Reserved.