Project JXTA

net.jxta.ext.config
Class AbstractConfigurator

java.lang.Object
  extended by net.jxta.ext.config.AbstractConfigurator
All Implemented Interfaces:
PlatformConfigurator, Configurator

public abstract class AbstractConfigurator
extends Object
implements PlatformConfigurator

An abstract PlatformConfigurator implementation that provides application callbacks for PlatformConfig generation and update prior to Platform startup. The default backing configurator is ext:config Configurator that is overridable via a constructor. Applications can register their implementation with the Platform in addition to adding application specific resources that will be copied to the JXTA_HOME prior to startup.

Version:
$Id: AbstractConfigurator.java,v 1.1 2004/11/30 22:42:09 gonzo Exp $
Author:
james todd [gonzo at jxta dot org]

Nested Class Summary
(package private) static class AbstractConfigurator.ConfiguratorWrapper
           
 
Field Summary
static String JXTA_PROPERTIES_KEY
          jxta.properties resource name.
static String PROFILE_KEY
          ext:config profile resource name.
 
Constructor Summary
AbstractConfigurator(PlatformConfigurator configurator)
          Constructor which overrides the backing Configurator.
 
Method Summary
static String addResource(String key, String value)
          Deprecated. resource management will be moved to instance members.
static void addResources(Map resources)
          Deprecated. resource management will be moved to instance members.
static Map clearResources()
          Deprecated. resource management will be moved to instance members.
abstract  PlatformConfig createPlatformConfig(PlatformConfigurator configurator)
          Application callback invoked upon registered Configurators prior to Platform startup when a newly created PlatformConfig is required.
 ConfigParams getConfigParams()
          
 URI getJXTAHome()
          
 PlatformConfig getPlatformConfig()
          Retrieve the associated PlatformConfig and potentially reconfigure the parameters before returning.
static String getResource(String key)
          Deprecated. resource management will be moved to instance members.
static Iterator getResourceKeys()
          Deprecated. resource management will be moved to instance members.
 boolean isReconfigure()
          Determine if a forced reconfiguration is set for the next call to PlatformConfigurator.getPlatformConfig().
 ConfigParams load()
          
 PlatformConfig load(File pc)
          Persist the associated{ @link net.jxta.impl.protocol.PlatformConfig} to the specified location.
static void register(Class configurator)
          Registers a delgate Configurator class with the Platform that will manage configuration resources.
static String removeResource(String key)
          Deprecated. resource management will be moved to instance members.
 boolean save()
          
 boolean save(File f)
          Persist the associated{ @link net.jxta.impl.protocol.PlatformConfig} to the specified location.
 void setConfigParams(ConfigParams cp)
          
 void setPlatformConfig(PlatformConfig config)
          Sets the associated PlatformConfig.
 void setReconfigure(boolean reconfigure)
          Sets the reconfiguration status to the specified status.
 PlatformConfig updatePlatformConfig(PlatformConfigurator configurator)
          Application callback invoked upon registered Configurators prior to Platform startup.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PROFILE_KEY

public static final String PROFILE_KEY
ext:config profile resource name.

See Also:
Constant Field Values

JXTA_PROPERTIES_KEY

public static final String JXTA_PROPERTIES_KEY
jxta.properties resource name.

See Also:
Constant Field Values
Constructor Detail

AbstractConfigurator

public AbstractConfigurator(PlatformConfigurator configurator)
Constructor which overrides the backing Configurator.

Parameters:
configurator - configurator delegate
Method Detail

register

public static void register(Class configurator)
Registers a delgate Configurator class with the Platform that will manage configuration resources.

Parameters:
configurator -

getResourceKeys

public static Iterator getResourceKeys()
Deprecated. resource management will be moved to instance members.

Resource key iterator. note: not thread safe

Returns:
resource keys

getResource

public static String getResource(String key)
Deprecated. resource management will be moved to instance members.

Resource accessor.

Parameters:
key - resource key
Returns:
resource value

addResource

public static String addResource(String key,
                                 String value)
Deprecated. resource management will be moved to instance members.

Resource setter.

Parameters:
key - resource key
value - resource value
Returns:
previous keyed value or null

addResources

public static void addResources(Map resources)
Deprecated. resource management will be moved to instance members.

Resource setter.

Parameters:
resources - resource map

removeResource

public static String removeResource(String key)
Deprecated. resource management will be moved to instance members.

Resource remover.

Parameters:
key - resource key
Returns:
resource value

clearResources

public static Map clearResources()
Deprecated. resource management will be moved to instance members.

Resource clearer.


createPlatformConfig

public abstract PlatformConfig createPlatformConfig(PlatformConfigurator configurator)
                                             throws ConfiguratorException
Application callback invoked upon registered Configurators prior to Platform startup when a newly created PlatformConfig is required. A ConfiguratorException will be thrown in the event the manufactured PlatformConfig is invalid.

Parameters:
configurator - delegate Configurator
Returns:
PlatformConfig generated PlatformConfig
Throws:
ConfiguratorException

updatePlatformConfig

public PlatformConfig updatePlatformConfig(PlatformConfigurator configurator)
                                    throws ConfiguratorException
Application callback invoked upon registered Configurators prior to Platform startup. A ConfiguratorException will be thrown in the event the manufactured PlatformConfig is invalid.

Parameters:
configurator - delegate Configurator
Returns:
PlatformConfig updated PlatformConfig
Throws:
ConfiguratorException

getJXTAHome

public URI getJXTAHome()

Specified by:
getJXTAHome in interface PlatformConfigurator

getPlatformConfig

public PlatformConfig getPlatformConfig()
                                 throws ConfiguratorException
Retrieve the associated PlatformConfig and potentially reconfigure the parameters before returning.

Specified by:
getPlatformConfig in interface PlatformConfigurator
Returns:
PlatformConfig
Throws:
ConfiguratorException

setPlatformConfig

public void setPlatformConfig(PlatformConfig config)
Sets the associated PlatformConfig.

Specified by:
setPlatformConfig in interface PlatformConfigurator

getConfigParams

public ConfigParams getConfigParams()
                             throws ConfiguratorException

Specified by:
getConfigParams in interface Configurator
Throws:
ConfiguratorException

setConfigParams

public void setConfigParams(ConfigParams cp)

Specified by:
setConfigParams in interface Configurator

setReconfigure

public void setReconfigure(boolean reconfigure)
Sets the reconfiguration status to the specified status. If true then reconfiguration will be forced the next time the PlatformConfig is retrieved.

Specified by:
setReconfigure in interface PlatformConfigurator
Parameters:
reconfigure - If true then a forced reconfiguration will occur the next time PlatformConfigurator.getPlatformConfig() is called.

load

public ConfigParams load()
                  throws ConfiguratorException

Specified by:
load in interface Configurator
Throws:
ConfiguratorException

load

public PlatformConfig load(File pc)
                    throws ConfiguratorException
Persist the associated{ @link net.jxta.impl.protocol.PlatformConfig} to the specified location.

Specified by:
load in interface PlatformConfigurator
Parameters:
pc - The file to which the configuration will be saved.
Returns:
true if the configuration was successfully saved otherwise false. If the parameters are not persisted then false/code> is returned.
Throws:
ConfiguratorException

isReconfigure

public boolean isReconfigure()
Determine if a forced reconfiguration is set for the next call to PlatformConfigurator.getPlatformConfig().

Specified by:
isReconfigure in interface PlatformConfigurator
Returns:
Returns true if a forced reconfiguration will occur the next time PlatformConfigurator.getPlatformConfig() is called.

save

public boolean save()
             throws ConfiguratorException

Specified by:
save in interface Configurator
Throws:
ConfiguratorException

save

public boolean save(File f)
             throws ConfiguratorException
Persist the associated{ @link net.jxta.impl.protocol.PlatformConfig} to the specified location.

Specified by:
save in interface PlatformConfigurator
Parameters:
f - The file to which the configuration will be saved.
Returns:
true if the configuration was successfully saved otherwise false. If the parameters are not persisted then false/code> is returned.
Throws:
ConfiguratorException

JXTA J2SE