Project JXTA

net.jxta.impl.peergroup
Class NullConfigurator

java.lang.Object
  extended bynet.jxta.impl.peergroup.NullConfigurator
All Implemented Interfaces:
Configurator, PlatformConfigurator
Direct Known Subclasses:
DefaultConfigurator

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.


Nested Class Summary
(package private) static class NullConfigurator.ProxyAuthenticator
          inner class to be used when a proxy user/pass is set
 
Field Summary
protected  PlatformConfig advertisement
          The platform config
protected  File configFile
          The file in which contains the platform configurtation.
protected static String CONFIGFILENAME
          File name into which we will store the platform configuration.
protected  File jxtaHomeDir
          The directory in which the configuration files will reside.
protected  File propertiesFile
          The file in which contains the configurtation properties.
protected static String PROPERTIESFILENAME
          File name into which we will store various configuration properties.
 
Constructor Summary
NullConfigurator()
          Constructor for the NullConfigurator object
NullConfigurator(File homeDir)
           
 
Method Summary
protected  void adjustLog4JPriority()
          Adjust the log4j priority based on the user's configuration file.
 ConfigParams getConfigParams()
           
 URI getJXTAHome()
           
 PlatformConfig getPlatformConfig()
          Retrieve the associated PlatformConfig and potentially reconfigure the parameters before returning.
 boolean isReconfigure()
          Determine if a forced reconfiguration is set for the next call to getPlatformConfig().
 ConfigParams load()
          
 PlatformConfig load(File loadFile)
          Persist the associated{ @link net.jxta.impl.protocol.PlatformConfig} to the specified location.
 boolean save()
          
 boolean save(File saveFile)
          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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CONFIGFILENAME

protected static final String CONFIGFILENAME
File name into which we will store the platform configuration.

See Also:
Constant Field Values

PROPERTIESFILENAME

protected static final String PROPERTIESFILENAME
File name into which we will store various configuration properties.

See Also:
Constant Field Values

jxtaHomeDir

protected final File jxtaHomeDir
The directory in which the configuration files will reside.


configFile

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


propertiesFile

protected final File propertiesFile
The file in which contains the configurtation properties.


advertisement

protected PlatformConfig advertisement
The platform config

Constructor Detail

NullConfigurator

public NullConfigurator()
                 throws ConfiguratorException
Constructor for the NullConfigurator object


NullConfigurator

public NullConfigurator(File homeDir)
                 throws ConfiguratorException
Method Detail

getJXTAHome

public URI getJXTAHome()
Specified by:
getJXTAHome in interface PlatformConfigurator

getPlatformConfig

public PlatformConfig getPlatformConfig()
                                 throws ConfiguratorException
Description copied from interface: PlatformConfigurator
Retrieve the associated PlatformConfig and potentially reconfigure the parameters before returning.

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

setPlatformConfig

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

Specified by:
setPlatformConfig in interface PlatformConfigurator
Parameters:
config -

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)
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

Specified by:
load in interface Configurator
Throws:
ConfiguratorException

load

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

Specified by:
load in interface PlatformConfigurator
Parameters:
loadFile - 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

save

public boolean save()
             throws ConfiguratorException

Specified by:
save in interface Configurator
Throws:
ConfiguratorException

save

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

Specified by:
save in interface PlatformConfigurator
Parameters:
saveFile - 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

adjustLog4JPriority

protected void adjustLog4JPriority()
Adjust the log4j priority based on the user's configuration file. If the configuration is not set or the value is "user default", then don't change it.


JXTA J2SE