org.apache.geronimo.kernel.config
Class Configuration

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

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.


Field Summary
static GBeanInfo GBEAN_INFO
           
 
Constructor Summary
Configuration()
          Only used to allow declaration as a reference.
Configuration(Collection parents, ConfigurationData configurationData, ConfigurationResolver configurationResolver, ManageableAttributeStore attributeStore)
          Creates a configuration.
 
Method Summary
 void addGBean(GBeanData gbean)
           
 AbstractName addGBean(String name, GBeanData gbean)
           
 void addToClassPath(String pattern)
           
 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 patterns)
           
 GBeanData findGBeanData(AbstractNameQuery pattern)
           
 GBeanData findGBeanData(Set patterns)
           
 LinkedHashSet findGBeanDatas(Set patterns)
           
 LinkedHashSet findGBeans(AbstractNameQuery pattern)
           
 LinkedHashSet findGBeans(ReferencePatterns referencePatterns)
           
 LinkedHashSet findGBeans(Set patterns)
           
 AbstractName getAbstractName()
           
 List getChildren()
          Gets the nested configurations of this configuration.
 List getClassParents()
          Gets the parent configurations used for class loading.
 List getClassPath()
          Gets the relative class path (URIs) of this configuration.
static AbstractName getConfigurationAbstractName(Artifact configId)
          Converts an Artifact to an AbstractName for a configuration.
 ClassLoader getConfigurationClassLoader()
          Gets the class loader for this configuration.
static Artifact getConfigurationID(ObjectName objectName)
           
 ConfigurationResolver getConfigurationResolver()
          Deprecated. this is only exposed temporarily for configuration manager
 long getCreated()
          Gets the time at which this configuration was created (or deployed).
 LinkedHashSet getDependencies()
          Gets the artifact dependencies of this configuration.
 Configuration getEnclosingConfiguration()
          Gets the enclosing configuration of this one (e.g. the EAR for a WAR), or null if it has none.
 Environment getEnvironment()
          Gets the declaration of the environment in which this configuration runs.
static GBeanInfo getGBeanInfo()
           
 Map 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 getOwnedConfigurations()
          Gets the configurations owned by this configuration.
 List getServiceParents()
          Gets the parent configurations used for service resolution.
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
 

Field Detail

GBEAN_INFO

public static final GBeanInfo GBEAN_INFO
Constructor Detail

Configuration

public Configuration()
Only used to allow declaration as a reference.


Configuration

public Configuration(Collection parents,
                     ConfigurationData configurationData,
                     ConfigurationResolver configurationResolver,
                     ManageableAttributeStore attributeStore)
              throws MissingDependencyException,
                     MalformedURLException,
                     NoSuchConfigException,
                     InvalidConfigException
Creates a configuration.

Parameters:
parents - parents of this configuation (not ordered)
configurationData - the module type, environment and classpath of the configuration
configurationResolver - used to resolve dependecies and paths
Throws:
MissingDependencyException
MalformedURLException
NoSuchConfigException
InvalidConfigException
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.

Throws:
InvalidConfigException

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()

getClassParents

public List getClassParents()
Gets the parent configurations used for class loading.

Returns:
the parents of this configuration used for class loading

getServiceParents

public List getServiceParents()
Gets the parent configurations used for service resolution.

Returns:
the parents of this configuration used for service resolution

getDependencies

public LinkedHashSet getDependencies()
Gets the artifact dependencies of this configuration.

Returns:
the artifact dependencies of this configuration

getEnvironment

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

Returns:
the environment of this configuration

getConfigurationResolver

public ConfigurationResolver getConfigurationResolver()
Deprecated. this is only exposed temporarily for configuration manager


getClassPath

public List getClassPath()
Gets the relative class path (URIs) of this configuration.

Returns:
the relative class path of this configuation

addToClassPath

public void addToClassPath(String pattern)
                    throws IOException
Throws:
IOException

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)

getConfigurationClassLoader

public ClassLoader getConfigurationClassLoader()
Gets the class loader for this configuration.

Specified by:
getConfigurationClassLoader in interface ConfigurationParent
Returns:
the class loader for this configuration

getChildren

public List 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 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 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.


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 patterns)
                       throws GBeanNotFoundException
Throws:
GBeanNotFoundException

findGBeanData

public GBeanData findGBeanData(Set patterns)
                        throws GBeanNotFoundException
Throws:
GBeanNotFoundException

findGBeans

public LinkedHashSet findGBeans(AbstractNameQuery pattern)

findGBeans

public LinkedHashSet findGBeans(ReferencePatterns referencePatterns)

findGBeans

public LinkedHashSet findGBeans(Set patterns)

findGBeanDatas

public LinkedHashSet findGBeanDatas(Set patterns)

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

getGBeanInfo

public static GBeanInfo getGBeanInfo()


Copyright © 2006 Apache Software Foundation. All Rights Reserved.