com.metamatrix.common.config
Class CurrentConfiguration

java.lang.Object
  extended by com.metamatrix.common.config.CurrentConfiguration

public final class CurrentConfiguration
extends java.lang.Object

This class represents a single and universal framework for accessing the current configuration for an application or server VM. The current configuration contains the specification of runtime properties and component deployment information. Depending upon the bootstrap information, this framework may access the configuration information from a central repository or simply from a local file.

This framework can be configured to periodically refresh the cached configuation information, and a separate thread is used to do this in the background. As such, the static shutdown() method should be called by applications when exiting. This method will block until this framework has successfully shutdown and cleaned up all resources, and will return gracefully if the method were already called. Note, however, that any call to this framework to obtain configuration information will restart the framework, requiring another eventual shutdown.

NOTE: This class should NOT use LogManager because it can cause recursive behavior.


Field Summary
static java.lang.String BOOTSTRAP_FILE_NAME
           
static java.lang.String CLUSTER_NAME
           
static java.lang.String CONFIGURATION_NAME
           
static java.lang.String CONFIGURATION_READER_CLASS_PROPERTY_NAME
           
 
Method Summary
 java.util.Properties getBootStrapProperties()
           
 java.lang.String getClusterName()
           
 java.util.Collection getComponentTypes(boolean includeDeprecated)
          Returns a Collection of type ComponentType that represent all the ComponentTypes defined.
 Configuration getConfiguration()
          Get the current configuration that is to be used for deployment.
 ConfigurationModelContainer getConfigurationModel()
          Get the current configuration that is to be used for deployment.
 Host getDefaultHost()
          Returns the Host based on the current running machine.
static CurrentConfiguration getInstance()
           
 java.util.Collection getProductTypes()
          Returns a Collection of type ProductType that represents all the ComponentTypes defined.
 java.util.Properties getProperties()
          Get all of the configuration properties.
 java.util.Properties getResourceProperties(java.lang.String resourceName)
          Get the connection properties for the specified resource.
 java.util.Properties getSystemBootStrapProperties()
           
 void indicateSystemShutdown()
          This will put the system into a state of #STATE_STOPPED.
 void performSystemInitialization(boolean forceInitialization)
          This method should be called only by StartupStateController, which is used by MetaMatrixController to initialize the system configurations during bootstrapping.
 void reset()
          Reset causes not just a refresh, but the bootstrapping process to occur again.
 void verifyBootstrapProperties()
          Returns the instance of CofigurationBootMgr to use to get configuration information.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BOOTSTRAP_FILE_NAME

public static final java.lang.String BOOTSTRAP_FILE_NAME
See Also:
Constant Field Values

CONFIGURATION_READER_CLASS_PROPERTY_NAME

public static final java.lang.String CONFIGURATION_READER_CLASS_PROPERTY_NAME
See Also:
Constant Field Values

CLUSTER_NAME

public static final java.lang.String CLUSTER_NAME
See Also:
Constant Field Values

CONFIGURATION_NAME

public static final java.lang.String CONFIGURATION_NAME
See Also:
Constant Field Values
Method Detail

getInstance

public static CurrentConfiguration getInstance()

getClusterName

public java.lang.String getClusterName()
                                throws ConfigurationException
Throws:
ConfigurationException

getProperties

public java.util.Properties getProperties()
Get all of the configuration properties. The properties that are returned have default properties that are the bootstrap properties.

Returns:
the immutable properties; never null
Throws:
ConfigurationException - if the current configuration and/or bootstrap properties could not be obtained

getResourceProperties

public java.util.Properties getResourceProperties(java.lang.String resourceName)
                                           throws ConfigurationException
Get the connection properties for the specified resource. The resourse name is dependent on the type of resource. For services, excluding connectors, the resource name will be the component type name ComponentType. For other types, they will generally have a predefined static variable called RESOURCE_NAME that will be used to ask for its properties.

Parameters:
resourceName - is the name of the resource to obtain properties for.
Returns:
the immutable properties; never null
Throws:
ConfigurationException - if the current configuration and/or bootstrap properties could not be obtained

getConfiguration

public Configuration getConfiguration()
                               throws ConfigurationException
Get the current configuration that is to be used for deployment.

Returns:
the Configuration used for deployment
Throws:
ConfigurationException - if the current configuration could not be obtained

getConfigurationModel

public ConfigurationModelContainer getConfigurationModel()
                                                  throws ConfigurationException
Get the current configuration that is to be used for deployment.

Returns:
the Configuration used for deployment
Throws:
ConfigurationException - if the current configuration could not be obtained

getComponentTypes

public java.util.Collection getComponentTypes(boolean includeDeprecated)
                                       throws ConfigurationException
Returns a Collection of type ComponentType that represent all the ComponentTypes defined.

Parameters:
includeDeprecated - true if class names that have been deprecated should be included in the returned list, or false if only non-deprecated constants should be returned.
Returns:
List of type ComponentType
Throws:
ConfigurationException - if an error occurred within or during communication with the Configuration Service.
See Also:
com.metamatrix.common.api.ComponentType

getProductTypes

public java.util.Collection getProductTypes()
                                     throws ConfigurationException
Returns a Collection of type ProductType that represents all the ComponentTypes defined.

Returns:
List of type ProductType
Throws:
ConfigurationException - if an error occurred within or during communication with the Configuration Service.
See Also:
#ProductType

getDefaultHost

public Host getDefaultHost()
                    throws ConfigurationException
Returns the Host based on the current running machine.

Returns:
the full Host object
Throws:
ConfigurationException - if an error occurred within or during communication with the Configuration Service, or if there is no object for the given ID.

reset

public final void reset()
                 throws ConfigurationException
Reset causes not just a refresh, but the bootstrapping process to occur again.

Throws:
ConfigurationException

performSystemInitialization

public final void performSystemInitialization(boolean forceInitialization)
                                       throws StartupStateException,
                                              ConfigurationException
This method should be called only by StartupStateController, which is used by MetaMatrixController to initialize the system configurations during bootstrapping. Once bootstrap properties are verified, this method will use the reader to attempt to put the system state into StartupStateController.STATE_STARTING, and then commence with initialization. If the state is already StartupStateController.STATE_STARTING, then another MetaMatrixController is already currently in the process of starting the system, and a StartupStateException will be thrown. If this method returns without an exception, then the system state will be in state StartupStateController.STATE_STARTING, and the calling code should proceed with startup.

Parameters:
forceInitialization - if the system is in a state other than StartupStateController.STATE_STOPPED, and the administrator thinks the system actually crashed and is not really running, he can choose to force the initialization. Otherwise, if the system is in one of these states, an exception will be thrown. This method is package-level so that only StartupStateController can access it.
Throws:
StartupStateException - if the system is not in a state in which initialization can proceed. This exception will indicate the current system state.
ConfigurationException - if the current configuration and/or bootstrap properties could not be obtained

indicateSystemShutdown

public final void indicateSystemShutdown()
                                  throws ConfigurationException
This will put the system into a state of #STATE_STOPPED.

Throws:
ConfigurationException - if the current configuration and/or bootstrap properties could not be obtained

getBootStrapProperties

public java.util.Properties getBootStrapProperties()
                                            throws ConfigurationException
Throws:
ConfigurationException

getSystemBootStrapProperties

public final java.util.Properties getSystemBootStrapProperties()

verifyBootstrapProperties

public final void verifyBootstrapProperties()
                                     throws ConfigurationException
Returns the instance of CofigurationBootMgr to use to get configuration information.

Throws:
ConfigurationException - if the current configuration and/or bootstrap properties could not be obtained


Copyright © 2009. All Rights Reserved.