org.apache.geronimo.system.configuration
Class LocalAttributeManager

java.lang.Object
  extended by org.apache.geronimo.system.configuration.LocalAttributeManager
All Implemented Interfaces:
GBeanLifecycle, ManageableAttributeStore, PersistentConfigurationList, PluginAttributeStore
Direct Known Subclasses:
SwitchableLocalAttributeManager

public class LocalAttributeManager
extends Object
implements PluginAttributeStore, PersistentConfigurationList, GBeanLifecycle

Stores managed attributes in an XML file on the local filesystem.


Field Summary
static GBeanInfo GBEAN_INFO
           
 
Fields inherited from interface org.apache.geronimo.kernel.config.ManageableAttributeStore
ATTRIBUTE_STORE
 
Fields inherited from interface org.apache.geronimo.kernel.config.PersistentConfigurationList
PERSISTENT_CONFIGURATION_LIST
 
Constructor Summary
LocalAttributeManager(String configFile, String configSubstitutionsFile, String configSubstitutionsPrefix, boolean readOnly, ServerInfo serverInfo)
           
 
Method Summary
 void addConfiguration(Artifact configurationName)
          Adds a configuration to the list, but does not mark it as started.
 void addGBean(Artifact configurationName, GBeanData gbeanData, ClassLoader classLoader)
          Adds a GBean to the configuration.
 Collection applyOverrides(Artifact configName, Collection untypedGbeanDatas, ClassLoader classLoader)
          Given a configuration name and a set of GBeanDatas, apply all the saved overrides to that set of GBeans before the caller attempts to load them.
 void doFail()
          Fails the GBean.
 void doStart()
          Starts the GBean.
 void doStop()
          Stops the target.
static GBeanInfo getGBeanInfo()
           
 Artifact[] getListedConfigurations(Artifact query)
          Gets all configurations in the list matching the specified query, whether they are marked at starting or not.
 boolean hasGBeanAttributes(Artifact configName)
          This method checks if there are any custom gbean attributes in the configuration.
 boolean isKernelFullyStarted()
           
 boolean isReadOnly()
           
 void load()
           
 void migrateConfiguration(Artifact oldName, Artifact newName, Configuration configuration)
          Migrates settings from an old version of a configuration to a newer version of the configuration.
 void removeConfiguration(Artifact configName)
          Removes all record of the specified configuration from the configuration list.
 List restore()
           
 void save()
          Saves the current values to persistent storage.
 void setKernelFullyStarted(boolean kernelFullyStarted)
           
 void setModuleGBeans(Artifact moduleName, GBeanOverride[] gbeans)
          Adds a group of settings to the attribute store.
 void setReferencePatterns(Artifact configurationName, AbstractName gbeanName, GReferenceInfo reference, ReferencePatterns patterns)
          Sets the pattern for a GBean reference.
 void setShouldLoad(Artifact configurationName, AbstractName gbeanName, boolean load)
          Sets whether a particular GBean should be loaded for this configuration.
 void setValue(Artifact configurationName, AbstractName gbeanName, GAttributeInfo attribute, Object value, ClassLoader classLoader)
          Sets the stored value for a particular attribute.
 void startConfiguration(Artifact configurationName)
          Indicates that the configuration should be started when the server is started.
 void stopConfiguration(Artifact configName)
          Indicates that the configuration should not be started when the server is started.
 
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

LocalAttributeManager

public LocalAttributeManager(String configFile,
                             String configSubstitutionsFile,
                             String configSubstitutionsPrefix,
                             boolean readOnly,
                             ServerInfo serverInfo)
Method Detail

isReadOnly

public boolean isReadOnly()

applyOverrides

public Collection applyOverrides(Artifact configName,
                                 Collection untypedGbeanDatas,
                                 ClassLoader classLoader)
                          throws InvalidConfigException
Description copied from interface: ManageableAttributeStore
Given a configuration name and a set of GBeanDatas, apply all the saved overrides to that set of GBeans before the caller attempts to load them.

Specified by:
applyOverrides in interface ManageableAttributeStore
Parameters:
configName - The configuration in question
untypedGbeanDatas - The initial GBeanData's for all the GBeans in the configuration
Returns:
The modified GBeanData's
Throws:
InvalidConfigException - If something bad happens

setModuleGBeans

public void setModuleGBeans(Artifact moduleName,
                            GBeanOverride[] gbeans)
Description copied from interface: PluginAttributeStore
Adds a group of settings to the attribute store. This is used by e.g. the plugin installer to add the settings needed for a new plugin.

Specified by:
setModuleGBeans in interface PluginAttributeStore

setValue

public void setValue(Artifact configurationName,
                     AbstractName gbeanName,
                     GAttributeInfo attribute,
                     Object value,
                     ClassLoader classLoader)
Description copied from interface: ManageableAttributeStore
Sets the stored value for a particular attribute. The attribute is identified by the configuration name, GBean ObjectName, and attribute information. Note: it is not possible to store a meaningful value of "null"; that would be treated the same as if no value was stored. Generally, whenever the value for a manageable attribute is changed, this method should be called so that value isn't reversed the next time the GBean is started.

Specified by:
setValue in interface ManageableAttributeStore
Parameters:
configurationName - The name of the configuration holding the GBean in question
gbeanName - The ObjectName of the GBean in question
attribute - The attribute in question
value - The value to save, or null if no value should be saved
classLoader - The configuration's classLoader

setReferencePatterns

public void setReferencePatterns(Artifact configurationName,
                                 AbstractName gbeanName,
                                 GReferenceInfo reference,
                                 ReferencePatterns patterns)
Description copied from interface: ManageableAttributeStore
Sets the pattern for a GBean reference. The reference is identified by the configuration name, GBean ObjectName, and reference information. To "null-out" the reference use setReferencePatterns(configurationName, gbean, reference, Collections.EMPTY_SET).

Specified by:
setReferencePatterns in interface ManageableAttributeStore
Parameters:
configurationName - the name of the configuration holding the GBean in question
gbeanName - the ObjectName of the GBean
reference - the attribute information

setShouldLoad

public void setShouldLoad(Artifact configurationName,
                          AbstractName gbeanName,
                          boolean load)
Description copied from interface: ManageableAttributeStore
Sets whether a particular GBean should be loaded for this configuration. The GBean must already exist in the configuration, this just toggles the flag for whether to stop it from loading when the configuration is loaded.

Specified by:
setShouldLoad in interface ManageableAttributeStore
Parameters:
configurationName - The configuration that the GBean belongs to
gbeanName - The GBean in question
load - True if the GBean should load with the configuration

addGBean

public void addGBean(Artifact configurationName,
                     GBeanData gbeanData,
                     ClassLoader classLoader)
Description copied from interface: ManageableAttributeStore
Adds a GBean to the configuration.

Specified by:
addGBean in interface ManageableAttributeStore
Parameters:
configurationName - the configuration that the GBean belongs to
gbeanData - the GBean to add
classLoader - The configuration classLoader

load

public void load()
          throws IOException
Throws:
IOException

save

public void save()
          throws IOException
Description copied from interface: ManageableAttributeStore
Saves the current values to persistent storage. This should be called when the server is shut down or more often, to make sure that any changes will be reflected the next time the server starts and the store is consulted.

Specified by:
save in interface ManageableAttributeStore
Specified by:
save in interface PersistentConfigurationList
Throws:
IOException

isKernelFullyStarted

public boolean isKernelFullyStarted()
Specified by:
isKernelFullyStarted in interface PersistentConfigurationList

setKernelFullyStarted

public void setKernelFullyStarted(boolean kernelFullyStarted)
Specified by:
setKernelFullyStarted in interface PersistentConfigurationList

restore

public List restore()
             throws IOException
Specified by:
restore in interface PersistentConfigurationList
Throws:
IOException

startConfiguration

public void startConfiguration(Artifact configurationName)
Description copied from interface: PersistentConfigurationList
Indicates that the configuration should be started when the server is started. The configuration should have been previously added with addConfiguration.

Specified by:
startConfiguration in interface PersistentConfigurationList

addConfiguration

public void addConfiguration(Artifact configurationName)
Description copied from interface: PersistentConfigurationList
Adds a configuration to the list, but does not mark it as started.

Specified by:
addConfiguration in interface PersistentConfigurationList

removeConfiguration

public void removeConfiguration(Artifact configName)
Description copied from interface: PersistentConfigurationList
Removes all record of the specified configuration from the configuration list. This is somewhat unusual -- normally you want to remember the settings in case the configuration is deployed again later.

Specified by:
removeConfiguration in interface PersistentConfigurationList

getListedConfigurations

public Artifact[] getListedConfigurations(Artifact query)
Description copied from interface: PersistentConfigurationList
Gets all configurations in the list matching the specified query, whether they are marked at starting or not.

Specified by:
getListedConfigurations in interface PersistentConfigurationList
Parameters:
query - The artifact to search for, normally not fully resolved so there may be multiple matches or matches that are not exactly equal to the argument.
Returns:
The matching artifacts that have data in the config list.

stopConfiguration

public void stopConfiguration(Artifact configName)
Description copied from interface: PersistentConfigurationList
Indicates that the configuration should not be started when the server is started. The configuration should have been previously added with addConfiguration (and presumably started with startConfiguration).

Specified by:
stopConfiguration in interface PersistentConfigurationList

migrateConfiguration

public void migrateConfiguration(Artifact oldName,
                                 Artifact newName,
                                 Configuration configuration)
Description copied from interface: PersistentConfigurationList
Migrates settings from an old version of a configuration to a newer version of the configuration. Used when an updated version is deployed with a newer version number in the name, but the settings used for the previous version should be carried forward.

Specified by:
migrateConfiguration in interface PersistentConfigurationList
Parameters:
oldName - The name that the existing settings are under
newName - The name to move the settings to
configuration - The configuration itself, which can be used to verify that all the settings are still valid as they are migrated.

hasGBeanAttributes

public boolean hasGBeanAttributes(Artifact configName)
This method checks if there are any custom gbean attributes in the configuration.

Specified by:
hasGBeanAttributes in interface PersistentConfigurationList
Parameters:
configName - Name of the configuration
Returns:
true if the configuration contains any custom gbean attributes

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 © 2003-2007 Apache Software Foundation. All Rights Reserved.