jp.go.aist.rtm.RTC
Class ConfigAdmin

java.lang.Object
  extended by jp.go.aist.rtm.RTC.ConfigAdmin

public class ConfigAdmin
extends java.lang.Object

Class to manage various configuration information.

Now terms for this class are defined as follows.

The following two configuration informations are stored in this class. Basically, the purpose of this class is to set one of the configuration-set in the list of (1) into parameter variables of (2). Usually, configuration parameter variables manipulation is performed with two-phases of configuration-set setting and parameter variables setting. The configuration-set manipulations are performed by the following functions. Modification, addition, deletion, acquisition and activation of configuration-set are performed by these functions. In order to reflect configuration-set, which is manipulated by these functions, on parameter variables that are used from RTC activities, the following update() functions are used . Callback functors can be given to hook configuration operation. Operations to be hooked are as follows.


Nested Class Summary
(package private)  class ConfigAdmin.OnActivateSetCallback
           OnActivateSetCallback class
(package private)  class ConfigAdmin.OnAddConfigurationAddCallback
           OnAddConfigurationAddCallback class
(package private)  class ConfigAdmin.OnRemoveConfigurationSetCallback
           OnRemoveConfigurationSetCallback class
(package private)  class ConfigAdmin.OnSetConfigurationSetCallback
           OnSetConfigurationSetCallback class
(package private)  class ConfigAdmin.OnUpdateCallback
           OnUpdateCallback class
(package private)  class ConfigAdmin.OnUpdateParamCallback
           OnUpdateParamCallback class
 
Constructor Summary
ConfigAdmin(Properties configsets)
           Constructor
 
Method Summary
 boolean activateConfigurationSet(java.lang.String config_id)
           Activate the configuration set
 boolean addConfigurationSet(Properties config_set)
           Add the configuration value to configuration set
 boolean bindParameter(java.lang.String param_name, ValueHolder var, java.lang.String def_val)
           Setup for configuration parameters
 void destruct()
           Virtual Destructor
protected  void finalize()
           finalize
 Properties getActiveConfigurationSet()
           Get the active configuration set
 java.lang.String getActiveId()
           Get ID of active configuration set
 Properties getConfigurationSet(java.lang.String config_id)
           Get a configuration set by specified ID
 java.util.Vector<Properties> getConfigurationSets()
           Get all configuration sets
 boolean haveConfig(java.lang.String config_id)
           Check the existence of configuration set
 boolean isActive()
           Confirm to activate configuration set
 boolean isChanged()
           Confirm to change configuration parameters
 boolean isExist(java.lang.String param_name)
           Check the existence of configuration parameters
 void onActivateSet(java.lang.String config_id)
           Called when the configuration set is made active
 void onAddConfigurationSet(Properties config_set)
           Called when a set value is added to the configuration set
 void onRemoveConfigurationSet(java.lang.String config_id)
           Called when the configuration set has been deleted
 void onSetConfigurationSet(Properties config_set)
           Called when the property is added to the configuration set
 void onUpdate(java.lang.String config_set)
           When the configuration parameter is updated, it is called.
 void onUpdateParam(java.lang.String config_set, java.lang.String config_param)
           When the configuration parameter is updated, it is called.
 boolean removeConfigurationSet(java.lang.String config_id)
           Remove the configuration set
 boolean setConfigurationSetValues(java.lang.String config_id, Properties config_set)
           Add to configuration set from specified property
 void setOnActivateSet(OnActivateSetCallbackFunc cb)
           Set callback that is called by OnActivateSet.
 void setOnAddConfigurationSet(OnAddConfigurationAddCallbackFunc cb)
           Set callback that is called by OnSetConfiguration.
 void setOnRemoveConfigurationSet(OnRemoveConfigurationSetCallbackFunc cb)
           Set callback that is called by OnRemoveConfigurationSet.
 void setOnSetConfigurationSet(OnSetConfigurationSetCallbackFunc cb)
           Set callback that is called by OnSetConfiguration.
 void setOnUpdate(OnUpdateCallbackFunc cb)
           Set callback that is called by OnUpdate.
 void setOnUpdateParam(OnUpdateParamCallbackFunc cb)
           Set callback that is called by OnUpdateParam.
 void update()
           Update the values of configuration parameters (Active configuration set)
 void update(java.lang.String config_set)
           Update configuration parameter (By ID)
 void update(java.lang.String config_set, java.lang.String config_param)
           Update the values of configuration parameters (By name)
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ConfigAdmin

public ConfigAdmin(Properties configsets)
Constructor

Parameters:
configsets - The target property name for setup
Method Detail

destruct

public void destruct()
Virtual Destructor


finalize

protected void finalize()
                 throws java.lang.Throwable
finalize

Overrides:
finalize in class java.lang.Object
Throws:
java.lang.Throwable

bindParameter

public boolean bindParameter(java.lang.String param_name,
                             ValueHolder var,
                             java.lang.String def_val)
Setup for configuration parameters

Bind configuration parameter to its variable. Return false, if configuration parameter of specified name has already existed.

Parameters:
param_name - Configuration parameter name
var - Configuration parameter variable
def_val - Default value of configuration parameter
Returns:
Setup result (Successful:true, Failed:false)

update

public void update(java.lang.String config_set)
Update configuration parameter (By ID)

This operation updates configuration variables by the configuration-set with specified ID. This operation does not change current active configuration-set. Since this operation causes inconsistency between current active configuration set and actual values of configuration variables, user should carefully use it. This operation ends without doing anything, if the configuration-set does not exist.

Parameters:
config_set - The target configuration set's ID to setup

update

public void update()
Update the values of configuration parameters (Active configuration set)

When configuration set is updated, update the configuration parameter value to the value that is set to the current active configuration. This update will be executed, only when an active configuration set exists and the content of the configuration set has been updated from the last update.


update

public void update(java.lang.String config_set,
                   java.lang.String config_param)
Update the values of configuration parameters (By name)

This operation updates a configuration variable by the specified configuration parameter in the configuration-set. This operation does not change current active configuration-set. Since this operation causes inconsistency between current active configuration set and actual values of configuration variables, user should carefully use it. This operation ends without doing anything, if the configuration-set or the configuration parameter do not exist.

Parameters:
config_set - configuration-set ID.
config_param - configuration parameter name.

isExist

public boolean isExist(java.lang.String param_name)
Check the existence of configuration parameters

Check the existence of configuration parameters of specified name.

Parameters:
param_name - Configuration parameter name
Returns:
Result of existance confirmation (Parameters exist:true, else:false)

isChanged

public boolean isChanged()
Confirm to change configuration parameters

Confirm that configuration parameters have changed.

Returns:
Result of change confirmation (There is a change:true、No change:false)

getActiveId

public final java.lang.String getActiveId()
Get ID of active configuration set

Get ID of the current active configuration set.

Returns:
The active configuration set ID

haveConfig

public final boolean haveConfig(java.lang.String config_id)
Check the existence of configuration set

Check the existence of specified configuration set.

Parameters:
config_id - ID of target configuration set for confirmation
Returns:
Result of existence confirmation (Specified ConfigSet exists:true, else:false)

isActive

public boolean isActive()
Confirm to activate configuration set

Confirm that configuration set has been activated.

Returns:
Result of state confirmation (Active state:true, Inactive state:false)

getConfigurationSets

public final java.util.Vector<Properties> getConfigurationSets()
Get all configuration sets

Get all specified configuration sets

Returns:
All configuration sets

getConfigurationSet

public final Properties getConfigurationSet(java.lang.String config_id)
Get a configuration set by specified ID

Get a configuration set that was specified by ID Return empty configuration set, if a configuration set of specified ID doesn't exist.

Parameters:
config_id - ID of the target configuration set for getting
Returns:
The configuration set

setConfigurationSetValues

public boolean setConfigurationSetValues(java.lang.String config_id,
                                         Properties config_set)
Add to configuration set from specified property

Add specified property to configuration set that was specified by ID. Return false if configuration set, that matches specified ID, doesn't exist.

Parameters:
config_id - ID of the target configuration set for add
config_set - Property to add
Returns:
Add result (Successful:true, Failed:false)

getActiveConfigurationSet

public final Properties getActiveConfigurationSet()
Get the active configuration set

Get the current active configuration set. Return empty configuration set, if an active configuration set doesn't exist.

Returns:
The active configuration set

addConfigurationSet

public boolean addConfigurationSet(Properties config_set)
Add the configuration value to configuration set

Add the configuration value to configuration set

Parameters:
config_set - Property to add
Returns:
Add Result (Successful:true, Failed:false)

removeConfigurationSet

public boolean removeConfigurationSet(java.lang.String config_id)
Remove the configuration set

Remove the configuration set of specified ID Return empty configuration set, if a configuration set of specified ID doesn't exist. The configuration-sets that can be removed by this function are only configuration-sets newly added by the addConfigurationSet() function. The configuration that can be removed by this function is only newly added configuration-set by addConfigurationSet() function. The "default" configuration-set and configurationi-sets that is loaded from configuration file cannot be removed. If the specified configuration is active currently, any configurations are not deleted. Callback functions that are set by addOnRemovedConfigurationSet() will be called if a configuration-set is deleted actually by this function.

Parameters:
config_id - ID of the target configuration set for remove
Returns:
Remove result (Successful:true, Failed:false)

activateConfigurationSet

public boolean activateConfigurationSet(java.lang.String config_id)
Activate the configuration set

Activate the configuration set of specified ID Return empty configuration set, if a configuration set of specified ID doesn't exist.

Parameters:
config_id - ID of the target configuration set for remove
Returns:
Activate result (Remove success:true、Remove failure:false)

setOnUpdate

public void setOnUpdate(OnUpdateCallbackFunc cb)
Set callback that is called by OnUpdate.

Parameters:
cb - OnUpdateCallback type object

setOnUpdateParam

public void setOnUpdateParam(OnUpdateParamCallbackFunc cb)
Set callback that is called by OnUpdateParam.

Parameters:
cb - OnUpdateParamCallback type object

setOnSetConfigurationSet

public void setOnSetConfigurationSet(OnSetConfigurationSetCallbackFunc cb)
Set callback that is called by OnSetConfiguration.

Parameters:
cb - OnSetConfigurationSetCallback type object

setOnAddConfigurationSet

public void setOnAddConfigurationSet(OnAddConfigurationAddCallbackFunc cb)
Set callback that is called by OnSetConfiguration.

Parameters:
cb - OnSetConfigurationSetCallback type object

setOnRemoveConfigurationSet

public void setOnRemoveConfigurationSet(OnRemoveConfigurationSetCallbackFunc cb)
Set callback that is called by OnRemoveConfigurationSet.

Parameters:
cb - OnRemoveConfigurationSetCallback type object

setOnActivateSet

public void setOnActivateSet(OnActivateSetCallbackFunc cb)
Set callback that is called by OnActivateSet.

Parameters:
cb - OnActivateSetCallback type object

onUpdate

public void onUpdate(java.lang.String config_set)
When the configuration parameter is updated, it is called.

Call the set callback object.

Parameters:
config_set - The target configuration set's ID to setup

onUpdateParam

public void onUpdateParam(java.lang.String config_set,
                          java.lang.String config_param)
When the configuration parameter is updated, it is called.

Call the set callback object.

Parameters:
config_set - configuration-set ID.
config_param - configuration parameter name.

onSetConfigurationSet

public void onSetConfigurationSet(Properties config_set)
Called when the property is added to the configuration set

Call the set callback object.

Parameters:
config_set - property

onAddConfigurationSet

public void onAddConfigurationSet(Properties config_set)
Called when a set value is added to the configuration set

Call the set callback object.

Parameters:
config_set - property

onRemoveConfigurationSet

public void onRemoveConfigurationSet(java.lang.String config_id)
Called when the configuration set has been deleted

Call the set callback object.

Parameters:
config_id - property

onActivateSet

public void onActivateSet(java.lang.String config_id)
Called when the configuration set is made active

Call the set callback object.

Parameters:
config_id - property