JXTA

net.jxta.impl.peergroup
Class NullConfigurator

java.lang.Object
  extended by net.jxta.impl.peergroup.NullConfigurator
All Implemented Interfaces:
PlatformConfigurator, Configurator
Direct Known Subclasses:
AutomaticConfigurator

public class NullConfigurator
extends Object
implements PlatformConfigurator

A minimal Platform Configurator. This implementation can load a configuration from an existing PlatformConfig file and also save a configuration to the PlatformConfig file.

This configurator provides no explict validation of the PlatformConfig as it is read from the file (Some is done by the PlatformConfig class) and provides no mechanism for reconfiguration. The NullConfigurator provides a useful base implementation for extending your own Configurator and also provides the minimal implementation needed for applications which perform their own configuration.


Field Summary
protected  PlatformConfig advertisement
          The platform config
protected  URI configFile
          The file in which contains the platform configurtation.
protected  URI jxtaHome
          The location in which the configuration files will reside.
 
Constructor Summary
NullConfigurator(URI homeRoot)
          Constructor for the NullConfigurator
 
Method Summary
 ConfigParams getConfigParams()
          Retrieve the parameters associated with this configuration from the default location.
 PlatformConfig getPlatformConfig()
          Retrieve the associated PlatformConfig and potentially performing any required configuration of the parameters before returning.
 boolean isReconfigure()
          Determine if a forced reconfiguration is set for the next call to PlatformConfigurator.getPlatformConfig().
 ConfigParams load()
          Retrieves the persisted parameters associated with this configuration from the standard location.
protected  PlatformConfig load(URI loadFile)
          Deprecated. Loading of existing configuration is best accomplished by use of specific constructors of the implementing configurator. This method complicates the state management of configuration parameters and may have unpredictable results depending upon the constructor and configuration set methods used prior to it's execution.
 boolean save()
          Persist the parameters associated with this configuration to the standard location.
protected  boolean save(URI saveFile)
          Persist the parameters associated with this configuration to the specified location.
 void setConfigParams(ConfigParams cp)
          Sets the parameters associated with this configuration object to the provided values.
 void setPlatformConfig(PlatformConfig config)
          Sets the associated PlatformConfig.
 void setReconfigure(boolean reconfigure)
          Sets the reconfiguration status to the specified status.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

jxtaHome

protected final URI jxtaHome
The location in which the configuration files will reside.


configFile

protected final URI configFile
The file in which contains the platform configurtation.


advertisement

protected PlatformConfig advertisement
The platform config

Constructor Detail

NullConfigurator

public NullConfigurator(URI homeRoot)
                 throws ConfiguratorException
Constructor for the NullConfigurator

Parameters:
homeRoot - The location in which the configuration files will reside.
Throws:
ConfiguratorException - If there is a problem accessing the configuration information.
Method Detail

getPlatformConfig

public PlatformConfig getPlatformConfig()
                                 throws ConfiguratorException
Description copied from interface: PlatformConfigurator
Retrieve the associated PlatformConfig and potentially performing any required configuration of the parameters before returning.

Specified by:
getPlatformConfig in interface PlatformConfigurator
Returns:
PlatformConfig
Throws:
ConfiguratorException - If configuration error occurs.

setPlatformConfig

public final void setPlatformConfig(PlatformConfig config)
Description copied from interface: PlatformConfigurator
Sets the associated PlatformConfig.

Specified by:
setPlatformConfig in interface PlatformConfigurator
Parameters:
config - the configuration

getConfigParams

public ConfigParams getConfigParams()
                             throws ConfiguratorException
Description copied from interface: net.jxta.peergroup.Configurator
Retrieve the parameters associated with this configuration from the default location. If necessary the parameters will be created or an opportunity to adjust them will be provided.

Specified by:
getConfigParams in interface Configurator
Returns:
The configuration parameters.
Throws:
ConfiguratorException - If there was a failure in retrieving the parameters. This is normally a chained exception to the underlying cause.

setConfigParams

public void setConfigParams(ConfigParams cp)
Description copied from interface: net.jxta.peergroup.Configurator
Sets the parameters associated with this configuration object to the provided values.

Specified by:
setConfigParams in interface Configurator
Parameters:
cp - The parameters to be associated with this configuration.

setReconfigure

public void setReconfigure(boolean reconfigure)
Description copied from interface: PlatformConfigurator
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.

isReconfigure

public boolean isReconfigure()
Description copied from interface: PlatformConfigurator
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.

load

public ConfigParams load()
                  throws ConfiguratorException
Retrieves the persisted parameters associated with this configuration from the standard location.

Specified by:
load in interface Configurator
Returns:
The configuration parameters.
Throws:
ConfiguratorException - If there was a failure in retrieving the persisted parameters. This is normally a chained exception to the underlying cause.

load

@Deprecated
protected PlatformConfig load(URI loadFile)
                       throws ConfiguratorException
Deprecated. Loading of existing configuration is best accomplished by use of specific constructors of the implementing configurator. This method complicates the state management of configuration parameters and may have unpredictable results depending upon the constructor and configuration set methods used prior to it's execution.

Retrieves the persisted parameters associated with this configuration from the standard location.

Parameters:
loadFile - The location from which the configuration data should be loaded.
Returns:
The configuration parameters.
Throws:
ConfiguratorException - If there was a failure in retrieving the persisted parameters. This is normally a chained exception to the underlying cause.

save

public boolean save()
             throws ConfiguratorException
Persist the parameters associated with this configuration to the standard location.

Specified by:
save in interface Configurator
Returns:
true if the configuration was successfully saved otherwise false. If the parameters are not persisted then false/code> is returned.
Throws:
ConfiguratorException - If there was a failure in persisting the parameters. This is normally a chained exception to the underlying cause.

save

protected boolean save(URI saveFile)
                throws ConfiguratorException
Persist the parameters associated with this configuration to the specified location.

Parameters:
saveFile - The location to which the configuration should 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 - If there was a failure in persisting the parameters. This is normally a chained exception to the underlying cause.

JXSE