org.idoox.config
Class Configurator

java.lang.Object
  extended byorg.idoox.config.Configurator

public class Configurator
extends java.lang.Object

Configurator represents the whole WSO2 SOA Enablement Server configuration (including configuration of all services) and generates proxy access to the config interfaces. Method newRuntimeConfigurable() can be used to create runtime configuration.

Since:
1.0
See Also:
Configurable
Component:
Core

Constructor Summary
Configurator()
          Constructs new Configurator instance.
 
Method Summary
static void destroy()
          Flushes and destroys the configurator.
static void flush()
          Force flushing of the configurator.
static Configurable getConfigurable(java.lang.Object configProxy)
          Returns configurable for an instance of configured interface.
static Configurable getConfigurable(java.lang.String id)
          Deprecated. Use getConfigurable(String, String) instead.
static Configurable getConfigurable(java.lang.String type, java.lang.String name)
          Returns the configuration of the given interface with type and name of the section.
static Configurable[] getTopEntries(java.lang.String type)
          Returns a list of known entry points with the given type.
static java.lang.String getWaspLocation()
          Returns the location of the system (WSO2 SOA Enablement Server) directory.
static void init(java.util.Map configurationParameters)
          Initializes the configurator.
static void init(java.util.Map configurationParameters, boolean loadApplications)
          Initializes the configurator.
static Configurable newRuntimeConfigurable()
          Creates new configurable which can be used to setup runtime configuration.
static Configurable setDefaultsOnConfigurable(Configurable configurable, Configurable defaults)
          Creates new configurable "above" two configurations - configurable and defaults.
static void update()
          Scans for new config files and imports them to the configurator.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Configurator

public Configurator()
Constructs new Configurator instance. This constructor should not be used (it is provided only to preserve of backward compatibility).

Method Detail

init

public static final void init(java.util.Map configurationParameters)
Initializes the configurator.

Parameters:
configurationParameters - a Map of configuration parameters. It must contain at least the following keys :
  • wasp.impl.class Class that initializes WSO2 SOA Enablement Server
  • wasp.impl.classpath Classpath of WSO2 SOA Enablement Server's implementation
  • wasp.location Location of WSO2 SOA Enablement Server's home directory
  • wasp.config.location Relative path to WSO2 SOA Enablement Server config files from wasp.location
  • wasp.configurator.class Class of configurator
  • wasp.config.include List of additional configs to include, delimited by commas

init

public static final void init(java.util.Map configurationParameters,
                              boolean loadApplications)
Initializes the configurator.

Parameters:
configurationParameters - a Map of configuration parameters.
loadApplications - if true application configs are also loaded

destroy

public static final void destroy()
Flushes and destroys the configurator.


getConfigurable

public static final Configurable getConfigurable(java.lang.String id)
Deprecated. Use getConfigurable(String, String) instead.

Returns the configuration of the given interface with instance id id

Parameters:
id - the id of the demanded instance
Returns:
the configured instance implementing configInterface and Configurable or null if the configurable has not been found

getConfigurable

public static final Configurable getConfigurable(java.lang.String type,
                                                 java.lang.String name)
Returns the configuration of the given interface with type and name of the section.

Parameters:
type - the type of the section to be returned
name - the name of the section to be returned
Returns:
the configuration section associated Configurable instance or null if the configurable has not been found

getConfigurable

public static final Configurable getConfigurable(java.lang.Object configProxy)
Returns configurable for an instance of configured interface.

Parameters:
configProxy - the instance obtained via Configurable.narrow
Returns:
the configurable from which configProxy was narrowed

flush

public static final void flush()
Force flushing of the configurator.


getTopEntries

public static final Configurable[] getTopEntries(java.lang.String type)
Returns a list of known entry points with the given type.

Parameters:
type - the name of the type
Returns:
list of matching configurables

getWaspLocation

public static final java.lang.String getWaspLocation()
Returns the location of the system (WSO2 SOA Enablement Server) directory.

Returns:
location of WSO2 SOA Enablement Server runtime

update

public static final void update()
Scans for new config files and imports them to the configurator.


newRuntimeConfigurable

public static final Configurable newRuntimeConfigurable()

Creates new configurable which can be used to setup runtime configuration. You can use runtime configurable in the same way as persisten one is used. The only difference is that runtime configuration is never stored to disk (it is transient).

You can narrow obtained configurable to interface which represents your configuration. Then you can setup configuration.

 Configurable configurable = Configurator.newRuntimeConfigurable();
 MyConfiguration myConf = (MyConfiguration)configurable.narrow(MyConfiguration.class);
 myConf.setX(123);

Created runtime configuration can be used wherever Configurable is required.

Be careful if you want to reuse runtime configurable in many places, e.g. if you setup one runtime configurable many times and pass it to the system. We recommend creating a new runtime configurable each time you want to represent a different configuration with it.

It is usually necessary to create a new instance of runtime configurable because some parts of the system can register themselves as listeners on the configurable. Such listeners can control any changes made on the configurable. Because runtime configurable can represent any configuration, two different parts of the system may be registered as listeners on one configurable. This can lead to unexpected behavior.

Returns:
new runtime configurable.
Since:
4.5

setDefaultsOnConfigurable

public static final Configurable setDefaultsOnConfigurable(Configurable configurable,
                                                           Configurable defaults)

Creates new configurable "above" two configurations - configurable and defaults.

Newly created configuration contains union of properties of both configurables. Values of properties which are contained in the configurable equals to the values which are stored in the configurable. Values of properties which are not in the configurable equals to the values stored in the defaults.

Simply, value of properties from configuration represented by defaults are used for properties which are not set in the configuration represented by configurable. Therefore values from defaults are used only as default values.

Any changed which you do to the new configuration are performed also on the configurable configuration.

E.g. this function can be used to overide some properties from persistent configuration

 Configurable persistent = ...
 Configurable mySpecialConf = Configurator.newRuntimeConfigurable();
 // set up mySpecialConf
 // ...
 Configurable actualConf = Configurator.setDefaultsOnConfigurable(mySpecialConf,persistent);
 // now you can use actualConf

Parameters:
configurable - configuration
defaults - default configuration
Returns:
new configuration "above" two configurations
Since:
4.5