copyright The Portico Project 2008.

org.portico.lrc
Class LRCConfigurator

java.lang.Object
  extended by org.portico.lrc.LRCConfigurator

public class LRCConfigurator
extends Object

This class is responsible for initializing and configuring the LRC according to the configuration file and any loaded plugins. See the configure(LRC) method for more informationa regarding what happens during this process.

The various configuration sources will be loaded in the following order:

  1. The default plug-ins shipped with Portico (initializeSinks(LRC))
  2. Any additional plug-ins that are found in the plug-in directory
  3. Any configuration data found in the RTI RID file (processRid(LRC))
  4. Any user-specific configuration data (processUserConfiguration(LRC))


Field Summary
private  org.apache.log4j.Logger logger
           
 
Constructor Summary
LRCConfigurator()
           
 
Method Summary
private  void bootstrapLogging()
          This method will initialize and configure the logging properties for the LRC.
 void configure(LRC theLRC)
          This method will do the following: Initialize the LRC sinks with the default configuration Looks for any plugins and processed any configurations found in them Apply any user configuration (from any file pointed to by the system property LRCProperties.PROP_CONFIG if it exists - does nothing if it doesn't) Creates and configures the connection The user configuration is applied last so that it can override any settings provided by the default or plugin configurations.
private  void createConnection(LRC theLRC)
          This method will create the connection for the LRC.
private  String findUserConfiguration()
          This method will attempt to locate a user configuratoin file on the local filesystem.
private  com.lbf.commons.messaging.ModuleGroup getModules(com.lbf.commons.config.xml.XMLSource configuration)
          Process the given configuration element for any modules.
private  void initializeSinks(LRC theLRC)
          Applies the default configuration.
protected  boolean processConfiguration(LRC theLRC, com.lbf.commons.config.xml.XMLSource xsource)
          Attempts to apply the configuration in the given XMLSource to the given LRC.
private  void processRid(LRC theLRC)
          This method will look for a configuration file at the location specified in the environment variable RTI_RID_FILE, and if that does not exist, the path given in the PorticoConstants.DEFAULT_RTI_RID variable will be checked.
private  void processUserConfiguration(LRC theLRC)
          Attempts to apply any user configuration to the given LRC.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

private org.apache.log4j.Logger logger
Constructor Detail

LRCConfigurator

public LRCConfigurator()
Method Detail

configure

public void configure(LRC theLRC)
               throws JRTIinternalError
This method will do the following:
  1. Initialize the LRC sinks with the default configuration
  2. Looks for any plugins and processed any configurations found in them
  3. Apply any user configuration (from any file pointed to by the system property LRCProperties.PROP_CONFIG if it exists - does nothing if it doesn't)
  4. Creates and configures the connection
The user configuration is applied last so that it can override any settings provided by the default or plugin configurations. If an error occurs during the configuration process (perhaps there is an error in a configuration file somewhere) a JRTIinternalError is thrown.

Throws:
JRTIinternalError

bootstrapLogging

private void bootstrapLogging()
This method will initialize and configure the logging properties for the LRC. The method includes a check to ensure that it is only run once.

A user can change the level to which the LRC will log its messages by altering the LRCProperties.PROP_LOGLEVEL system property and setting it to any valid log4j level string (TRACE, DEBUG, INFO, WARN, ERROR, FATAL, OFF)


initializeSinks

private void initializeSinks(LRC theLRC)
                      throws JRTIinternalError
Applies the default configuration. If the LRCProperties.PROP_IDC property is set to true, this method will not execute.

Here we initialize the LRC message sinks using the appropriate modules for the HLA specification version that is being used by the federate.

Throws:
JRTIinternalError

getModules

private com.lbf.commons.messaging.ModuleGroup getModules(com.lbf.commons.config.xml.XMLSource configuration)
                                                  throws com.lbf.commons.config.ConfigurationException
Process the given configuration element for any modules. Return the resulting module group. If there is a problem with the configuration, an exception will be thrown.

Throws:
com.lbf.commons.config.ConfigurationException

processConfiguration

protected boolean processConfiguration(LRC theLRC,
                                       com.lbf.commons.config.xml.XMLSource xsource)
                                throws JRTIinternalError
Attempts to apply the configuration in the given XMLSource to the given LRC.

Throws:
JRTIinternalError

processUserConfiguration

private void processUserConfiguration(LRC theLRC)
                               throws JRTIinternalError
Attempts to apply any user configuration to the given LRC. It will search for a user configuration using the findUserConfiguration() method. Only files that are only the location file system will be considered. See findUserConfiguration() for information on where it looks.

Files can be either a valid XML LRC configuration file, or a standard java properties file

Throws:
JRTIinternalError

findUserConfiguration

private String findUserConfiguration()
This method will attempt to locate a user configuratoin file on the local filesystem. The user config file can be used to provide user-specific options. As it is applied last, it can override all the previously provided options in other configuration files loaded before it.

The location of the file is determined by the value of the system property lrc.configuration. If that property is set, the value is used as the location of the file. If the property isn't set, then the default value is used. The default value is ./lrc.configuration.

If the file exists, its location is returned from the method, if it doesn't, null is returned.


processRid

private void processRid(LRC theLRC)
                 throws JRTIinternalError
This method will look for a configuration file at the location specified in the environment variable RTI_RID_FILE, and if that does not exist, the path given in the PorticoConstants.DEFAULT_RTI_RID variable will be checked. This should be applied to the LRC after the plug-in configuration, but before the user configuration. If the file doesn't exist, nothing will happen and the method will return. If the file does exist, and it contains errors, it will throw a JRTIinternalError.

Parameters:
theLRC - Apply the configuration data in the rid to this LRC
Throws:
JRTIinternalError - If the config file exists, but contains errors

createConnection

private void createConnection(LRC theLRC)
                       throws JRTIinternalError
This method will create the connection for the LRC. It will first check the system property LRCProperties.PROP_CONNECTION for the implementation class. If found, it will attempt to create and configuration an instance of that class. If not found, it will use the default value from LRCProperties.DEFAULT_CONNECT.

NOTE: The connection implementation class must extend the LRCConnection abstract class.

Throws:
JRTIinternalError

copyright The Portico Project 2008.