org.objectweb.carol.util.configuration
Class ConfigurationRepository

java.lang.Object
  extended byorg.objectweb.carol.util.configuration.ConfigurationRepository

public class ConfigurationRepository
extends java.lang.Object

This class handle all rmi configuration available at runtime for carol.
Configurations could be added/removed after the startup of carol

Author:
Florent Benoit

Method Summary
static void addConfiguration(ProtocolConfiguration protocolConfiguration)
          Add a configuration
static void addInterceptors(java.lang.String protocolName, java.lang.String interceptorInitializer)
          Add interceptor at runtime for a given protocol
protected static void checkConfigured()
          Checks that carol is initialized
protected static void checkInitialized()
          Check that the configuration is done
static int getActiveConfigurationsNumber()
           
static ProtocolConfiguration getConfiguration(java.lang.String configName)
          Gets a configuration with the given name
static ProtocolConfiguration[] getConfigurations()
           
static ProtocolConfiguration getCurrentConfiguration()
           
static ProtocolConfiguration getDefaultConfiguration()
           
protected static java.util.Properties getDefaultProperties()
          Initialize carol with default configuration file found in jar of carol
static java.util.Properties getProperties()
           
protected static java.util.Properties getPropertiesFromURL(java.net.URL url)
          Gets a properties object based on given URL
static Protocol getProtocol(java.lang.String protocolName)
          Gets a protocol with the given name
static ServerConfiguration getServerConfiguration()
          Gets server configuration (made with carol-default.properties and carol.properties file)
static void init()
          Initialize Carol configurations with an URL of carol properties file found with Classloader
static void init(java.lang.String domainName, java.lang.String serverName)
          Initialize Carol configurations with MBeans
static void init(java.net.URL carolPropertiesFileURL)
          Initialize Carol configurations with the carol.properties URL
static void init(java.net.URL carolPropertiesFileURL, java.lang.String domainName, java.lang.String serverName)
          } Initialize Carol configurations with the carol.properties URL
protected static void initMbeans(java.lang.String domainName, java.lang.String serverName)
          Init the MBean for each configuration
protected static java.util.Properties mergeProperties(java.util.Properties defaultValues, java.util.Properties values)
          Merge content of two properties object (second overwrite first values)
static ProtocolConfiguration newConfiguration(java.lang.String configurationName, java.lang.String protocolName)
          Build a new configuration for a given protocol
static ProtocolConfiguration setCurrentConfiguration(ProtocolConfiguration config)
          Set the current configuration object
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

checkInitialized

protected static void checkInitialized()
Check that the configuration is done


checkConfigured

protected static void checkConfigured()
Checks that carol is initialized


getConfigurations

public static ProtocolConfiguration[] getConfigurations()
Returns:
a list of current configurations

getConfiguration

public static ProtocolConfiguration getConfiguration(java.lang.String configName)
Gets a configuration with the given name

Parameters:
configName - name of the configuration
Returns:
configuration object associated to the given name

getProtocol

public static Protocol getProtocol(java.lang.String protocolName)
Gets a protocol with the given name

Parameters:
protocolName - name of the protocol
Returns:
protocol object associated to the given name

newConfiguration

public static ProtocolConfiguration newConfiguration(java.lang.String configurationName,
                                                     java.lang.String protocolName)
                                              throws ConfigurationException
Build a new configuration for a given protocol

Parameters:
configurationName - the name of the configuration
protocolName - name of the protocol
Returns:
a new configuration object for a given protocol
Throws:
ConfigurationException - if no configuration can be built

setCurrentConfiguration

public static ProtocolConfiguration setCurrentConfiguration(ProtocolConfiguration config)
Set the current configuration object

Parameters:
config - the configuration to set as current configuration
Returns:
previous value of the configuration which was set

getCurrentConfiguration

public static ProtocolConfiguration getCurrentConfiguration()
Returns:
current carol configuration

init

public static void init(java.net.URL carolPropertiesFileURL)
                 throws ConfigurationException
Initialize Carol configurations with the carol.properties URL

Parameters:
carolPropertiesFileURL - URL rerencing the configuration file
Throws:
ConfigurationException - if no properties can be loaded

init

public static void init(java.lang.String domainName,
                        java.lang.String serverName)
                 throws ConfigurationException
Initialize Carol configurations with MBeans

Parameters:
domainName - the name of the JOnAS domain
serverName - the name of the server for creating mbeans
Throws:
ConfigurationException - if no properties can be loaded

init

public static void init(java.net.URL carolPropertiesFileURL,
                        java.lang.String domainName,
                        java.lang.String serverName)
                 throws ConfigurationException
} Initialize Carol configurations with the carol.properties URL

Parameters:
carolPropertiesFileURL - URL rerencing the configuration file
domainName - the name of the JOnAS domain
serverName - the name of the server for creating mbeans
Throws:
ConfigurationException - if no properties can be loaded

addConfiguration

public static void addConfiguration(ProtocolConfiguration protocolConfiguration)
                             throws ConfigurationException
Add a configuration

Parameters:
protocolConfiguration - the configuration to add
Throws:
ConfigurationException - if the configuration exists

getServerConfiguration

public static ServerConfiguration getServerConfiguration()
Gets server configuration (made with carol-default.properties and carol.properties file)

Returns:
server configuration

mergeProperties

protected static java.util.Properties mergeProperties(java.util.Properties defaultValues,
                                                      java.util.Properties values)
Merge content of two properties object (second overwrite first values)

Parameters:
defaultValues - default values
values - new values
Returns:
properties object with merge done

init

public static void init()
                 throws ConfigurationException
Initialize Carol configurations with an URL of carol properties file found with Classloader

Throws:
ConfigurationException - if no properties can be loaded

getDefaultProperties

protected static java.util.Properties getDefaultProperties()
                                                    throws ConfigurationException
Initialize carol with default configuration file found in jar of carol

Returns:
properties object corresponding to carol-default.properties file
Throws:
ConfigurationException - if the properties file cannot be get

getPropertiesFromURL

protected static java.util.Properties getPropertiesFromURL(java.net.URL url)
                                                    throws ConfigurationException
Gets a properties object based on given URL

Parameters:
url - URL from where build properties object
Returns:
properties object with data from the given URL
Throws:
ConfigurationException - if properties cannot be built

getDefaultConfiguration

public static ProtocolConfiguration getDefaultConfiguration()
Returns:
the default Configuration when no thread local is set.

getProperties

public static java.util.Properties getProperties()
Returns:
the properties used by Carol configuration.

getActiveConfigurationsNumber

public static int getActiveConfigurationsNumber()
Returns:
the number of active protocols

addInterceptors

public static void addInterceptors(java.lang.String protocolName,
                                   java.lang.String interceptorInitializer)
                            throws ConfigurationException
Add interceptor at runtime for a given protocol

Parameters:
protocolName - protocol name
interceptorInitializer - Interceptor Intializer class name
Throws:
ConfigurationException - if interceptor cannot be added

initMbeans

protected static void initMbeans(java.lang.String domainName,
                                 java.lang.String serverName)
                          throws ConfigurationException
Init the MBean for each configuration

Parameters:
domainName - the name of the JOnAS domain
serverName - the name of the server for creating mbeans
Throws:
ConfigurationException - if MBeans are not created