org.apache.geronimo.kernel.config
Class Configuration

java.lang.Object
  extended byorg.apache.geronimo.kernel.config.Configuration
All Implemented Interfaces:
org.apache.geronimo.gbean.GBeanLifecycle

public class Configuration
extends Object
implements org.apache.geronimo.gbean.GBeanLifecycle

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:
$Revision: 1.28 $ $Date: 2004/07/22 03:22:53 $

Field Summary
static org.apache.geronimo.gbean.GBeanInfo GBEAN_INFO
           
 
Constructor Summary
Configuration(Kernel kernel, String objectName, URI id, ConfigurationModuleType moduleType, URI parentID, ConfigurationParent parent, List classPath, byte[] gbeanState, Collection repositories, List dependencies)
          Constructor that can be used to create an offline Configuration, typically only used publically during the deployment process for initial configuration.
 
Method Summary
 void doFail()
           
 void doStart()
           
 void doStop()
           
 URL getBaseURL()
          Return the URL that is used to resolve relative classpath locations
 ClassLoader getClassLoader()
           
static org.apache.geronimo.gbean.GBeanInfo getGBeanInfo()
           
 URI getID()
          Return the unique ID
 ConfigurationModuleType getModuleType()
          Gets the type of the configuration (WAR, RAR et cetera)
 URI getParentID()
          Return the unique ID of this Configuration's parent
 byte[] getSavedState()
           
static Map loadGBeans(byte[] gbeanState, ClassLoader cl)
          Load GBeans from the supplied byte array using the supplied ClassLoader
static void loadGMBeanState(org.apache.geronimo.gbean.jmx.GBeanMBean gbean, ObjectInputStream ois)
           
 void setBaseURL(URL baseURL)
          Set the URL that should be used to resolve relative class locations
static byte[] storeGBeans(Map gbeans)
          Return a byte array containing the persisted form of the supplied GBeans
static void storeGMBeanState(org.apache.geronimo.gbean.jmx.GBeanMBean gbean, ObjectOutputStream oos)
           
 
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 org.apache.geronimo.gbean.GBeanInfo GBEAN_INFO
Constructor Detail

Configuration

public Configuration(Kernel kernel,
                     String objectName,
                     URI id,
                     ConfigurationModuleType moduleType,
                     URI parentID,
                     ConfigurationParent parent,
                     List classPath,
                     byte[] gbeanState,
                     Collection repositories,
                     List dependencies)
Constructor that can be used to create an offline Configuration, typically only used publically during the deployment process for initial configuration.

Parameters:
id - the unique ID of this Configuration
moduleType - the module type identifier
parent - the parent Configuration; may be null
classPath - a List of locations that define the codebase for this Configuration
gbeanState - a byte array contain the Java Serialized form of the GBeans in this Configuration
repositories - a Collection of repositories used to resolve dependencies
dependencies - a List of dependencies
Method Detail

doStart

public void doStart()
             throws Exception
Specified by:
doStart in interface org.apache.geronimo.gbean.GBeanLifecycle
Throws:
Exception

doStop

public void doStop()
Specified by:
doStop in interface org.apache.geronimo.gbean.GBeanLifecycle

doFail

public void doFail()
Specified by:
doFail in interface org.apache.geronimo.gbean.GBeanLifecycle

getParentID

public URI getParentID()
Return the unique ID of this Configuration's parent

Returns:
the unique ID of the parent, or null if it does not have one

getID

public URI getID()
Return the unique ID

Returns:
the unique ID

getModuleType

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

Returns:
Type of the configuration.

getBaseURL

public URL getBaseURL()
Return the URL that is used to resolve relative classpath locations

Returns:
the base URL for the classpath

setBaseURL

public void setBaseURL(URL baseURL)
Set the URL that should be used to resolve relative class locations

Parameters:
baseURL - the base URL for the classpath

getClassLoader

public ClassLoader getClassLoader()

getSavedState

public byte[] getSavedState()

loadGBeans

public static Map loadGBeans(byte[] gbeanState,
                             ClassLoader cl)
                      throws InvalidConfigException
Load GBeans from the supplied byte array using the supplied ClassLoader

Parameters:
gbeanState - the serialized form of the GBeans
cl - the ClassLoader used to locate classes needed during deserialization
Returns:
a Map of GBeans loaded from the persisted state
Throws:
InvalidConfigException - if there is a problem deserializing the state

loadGMBeanState

public static void loadGMBeanState(org.apache.geronimo.gbean.jmx.GBeanMBean gbean,
                                   ObjectInputStream ois)
                            throws IOException,
                                   javax.management.AttributeNotFoundException,
                                   javax.management.ReflectionException,
                                   ClassNotFoundException
Throws:
IOException
javax.management.AttributeNotFoundException
javax.management.ReflectionException
ClassNotFoundException

storeGBeans

public static byte[] storeGBeans(Map gbeans)
                          throws InvalidConfigException
Return a byte array containing the persisted form of the supplied GBeans

Parameters:
gbeans - a Map of GBeans to store
Returns:
the persisted GBeans
Throws:
InvalidConfigException - if there is a problem serializing the state

storeGMBeanState

public static void storeGMBeanState(org.apache.geronimo.gbean.jmx.GBeanMBean gbean,
                                    ObjectOutputStream oos)
                             throws IOException,
                                    javax.management.AttributeNotFoundException,
                                    javax.management.ReflectionException
Throws:
IOException
javax.management.AttributeNotFoundException
javax.management.ReflectionException

getGBeanInfo

public static org.apache.geronimo.gbean.GBeanInfo getGBeanInfo()


Copyright © 2003-2005 Apache Software Foundation. All Rights Reserved.