systemic.sif.sifcommon.utils
Class SIFCommonProperties

java.lang.Object
  extended by systemic.sif.sifcommon.utils.SIFCommonProperties

public class SIFCommonProperties
extends java.lang.Object

This class provides a number of handy methods to access the values of the SIFCommon Framework properties file. Generally this file is called SIFAgent.properties but it doesn't have to.

Author:
Joerg Huber

Field Summary
static int NO_EVENT
          Constant to check if the event frequency is indicating that no events should be sent.
static int NO_SYNC
          Constant to check if the sync frequency is indicating that no sync should be performed.
 
Constructor Summary
SIFCommonProperties()
          Same as the method above but it assumes that the property file is called SIFAgent.properties.
SIFCommonProperties(java.lang.String propertyFileName)
          Name of the SIFCommon Framework Property file.
 
Method Summary
 java.lang.String getADKConfigDir(java.lang.String agentID)
          Returns the SIFWorks ADK configuration file directory for the given agent.
 java.lang.String getADKConfigFileName(java.lang.String agentID)
          Returns the SIFWorks ADK configuration file name for the given agent.
 java.lang.String getADKConfigPathAndFileName(java.lang.String agentID)
          Returns the SIFWorks ADK configuration file name with the full path for the given agent.
 java.lang.String getApplicationID(java.lang.String agentID, java.lang.String defaultValue)
          This method returns the applicationID for the given agent.
 java.util.List<java.lang.String> getCustomObjects(java.lang.String agentID)
          This method returns a list of custom object names for a given agent.
 java.lang.String getCustonObjBasePackageName(java.lang.String agentID)
          Returns the package name of the custom objects.
 java.lang.String getDebugLevel(java.lang.String agentID)
          Returns the debug level for the given agent.
 int getEventBatchSize()
           
 int getEventFrequencyInSeconds(java.lang.String agentID, int defaultValue)
          This method returns the default event frequency for the given agent.
 int getEventFrequencyInSeconds(java.lang.String agentID, java.lang.String publisherID, int defaultValue)
          This method returns the event frequency for the given agent and publisher.
 java.util.List<java.lang.String> getFromCommaSeparated(java.lang.String propertyName)
           
 java.lang.String getLogDir(java.lang.String agentID)
          Returns the directory for Log4J logging for the given agent.
 java.lang.String getLogFileName(java.lang.String agentID)
          Returns the logging file name for the given agent.
 java.lang.String getLogPathAndFileName(java.lang.String agentID)
          Returns the logging file name with the full path for the given agent.
 java.lang.String getMappingName(java.lang.String agentID)
          Returns the name of the mapping section to be used for this agent.
 boolean getMultiThreaded(java.lang.String agentID, boolean defaultValue)
          This method returns the multi-threaded indicator for the given agent.
 int getNumConsumerThreads(java.lang.String agentID)
          This method returns the number of threads that shall be initiated to consume messages retrieved by the given agent.
 int getNumConsumerThreads(java.lang.String agentID, java.lang.String subscriberID)
          This method returns the number of threads that shall be initiated to consume messages retrieved by the given subscriber.
 java.lang.String getPathAndFileName(java.lang.String path, java.lang.String name)
          Builds a full path and file name.
 java.util.Properties getProperties()
          This method returns the values of the SIFCommon Framework Property file as a property structure.
 java.lang.Boolean getPropertyAsBool(java.lang.String propertyName)
          Returns the given property as a boolean object.
 boolean getPropertyAsBool(java.lang.String propertyName, boolean defaultValue)
          Returns the given property as a boolean.
 java.lang.Integer getPropertyAsInt(java.lang.String propertyName)
          Returns the given property as a Integer object.
 int getPropertyAsInt(java.lang.String propertyName, int defaultValue)
          Returns the given property as a int.
 java.lang.String getPropertyAsString(java.lang.String propertyName, java.lang.String defaultValue)
          Returns the given property as a String.
 java.lang.String getPublisherBasePackageName(java.lang.String agentID)
          Returns the package name of the publishers.
 java.util.List<java.lang.String> getPublishers(java.lang.String agentID)
          This method returns a list of publisher names for a given agent.
 int getStartupDelay(int defalutValue)
          Returns the value for the start up delay in seconds between publishers and subscribers.
 java.lang.String getSubscriberBasePackageName(java.lang.String agentID)
          Returns the package name of the subscribers.
 java.util.List<java.lang.String> getSubscribers(java.lang.String agentID)
          This method returns a list of subscriber names for a given agent.
 int getSyncFrequencyInSeconds(java.lang.String agentID, int defaultValue)
          This method returns the default sync frequency for the given agent.
 int getSyncFrequencyInSeconds(java.lang.String agentID, java.lang.String subscriberID, int defaultValue)
          This method returns the sync frequency for the given agent and subscriber.
 java.lang.String getTestDir(java.lang.String agentID)
          Returns the test directory for the given agent.
 boolean getTestMode(java.lang.String agentID)
          This method returns the test mode indicator for the given agent.
 java.lang.String getWorkDir(java.lang.String agentID)
          Returns the SIFWorks ADK working directory for the given agent.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NO_EVENT

public static final int NO_EVENT
Constant to check if the event frequency is indicating that no events should be sent.

See Also:
Constant Field Values

NO_SYNC

public static final int NO_SYNC
Constant to check if the sync frequency is indicating that no sync should be performed.

See Also:
Constant Field Values
Constructor Detail

SIFCommonProperties

public SIFCommonProperties(java.lang.String propertyFileName)
Name of the SIFCommon Framework Property file. This is the file that holds the names and locations of all publishers, subscribers etc. The property file must be on the classpath.

Parameters:
propertyFileName - File Name without the extension '.properties'.

SIFCommonProperties

public SIFCommonProperties()
Same as the method above but it assumes that the property file is called SIFAgent.properties.

Method Detail

getApplicationID

public java.lang.String getApplicationID(java.lang.String agentID,
                                         java.lang.String defaultValue)
This method returns the applicationID for the given agent. If that doesn't exist then the defaultValue is returned.

Each agent should be responsible for a particular application. More than one agent can be responsible for the same application where they each deal with different SIF Objects.

The property that this method attempts to access must have the following structure:

agent._agentID_.application=_applicationID_

Parameters:
agentID - The agentID of the agent for which the application shall be returned.
defaultValue - The default value to be returned if no frequency can be found.
Returns:
See description.

getEventFrequencyInSeconds

public int getEventFrequencyInSeconds(java.lang.String agentID,
                                      java.lang.String publisherID,
                                      int defaultValue)
This method returns the event frequency for the given agent and publisher. If no such frequency exists then it will attempt to return the default frequency of this agent. If that doesn't exist either then the defaultValue is returned.

The frequency should be interpreted as seconds.

The property that this method attempts to access must have the following structure:

agent._agentID_._publisherID_.event.frequency=_int_value_

or

agent._agentID_.event.frequency=_int_value_

in case of the global setting

Parameters:
agentID - The agentID of the agent for which the frequency shall be returned.
publisherID - The publisherID of the publisher for which the frequency shall be returned.
defaultValue - The default value to be returned if no frequency can be found.
Returns:
See description.

getEventFrequencyInSeconds

public int getEventFrequencyInSeconds(java.lang.String agentID,
                                      int defaultValue)
This method returns the default event frequency for the given agent. If that doesn't exist then the defaultValue is returned.

The frequency should be interpreted as seconds.

The property that this method attempts to access must have the following structure:

agent._agentID_.event.frequency=_int_value_

Parameters:
agentID - The agentID of the agent for which the frequency shall be returned.
defaultValue - The default value to be returned if no frequency can be found.
Returns:
See description.

getSyncFrequencyInSeconds

public int getSyncFrequencyInSeconds(java.lang.String agentID,
                                     java.lang.String subscriberID,
                                     int defaultValue)
This method returns the sync frequency for the given agent and subscriber. If no such frequency exists then it will attempt to return the default frequency of this agent. If that doesn't exist either then the defaultValue is returned.

The frequency should be interpreted as seconds.

The property that this method attempts to access must have the following structure:

agent._agentID_._subscriber_.sync.frequency=_int_value_

or

agent._agentID_.sync.frequency=_int_value_

in case of the global setting

Parameters:
agentID - The agentID of the agent for which the frequency shall be returned.
subscriberID - The subscriberID of the subscriber for which the frequency shall be returned.
defaultValue - The default value to be returned if no frequency can be found.
Returns:
See description.

getSyncFrequencyInSeconds

public int getSyncFrequencyInSeconds(java.lang.String agentID,
                                     int defaultValue)
This method returns the default sync frequency for the given agent. If that doesn't exist then the defaultValue is returned.

The frequency should be interpreted as seconds.

The property that this method attempts to access must have the following structure:

agent._agentID_.sync.frequency=_int_value_

Parameters:
agentID - The agentID of the agent for which the frequency shall be returned.
defaultValue - The default value to be returned if no frequency can be found.
Returns:
See description.

getMultiThreaded

public boolean getMultiThreaded(java.lang.String agentID,
                                boolean defaultValue)
This method returns the multi-threaded indicator for the given agent. If that doesn't exist then the defaultValue is returned.

Valid values in the property file for this property is 'true' or 'false'.

The property that this method attempts to access must have the following structure:

agent._agentID_.multiTreaded=true|false

Parameters:
agentID - The agentID of the agent for which the multi-threaded indicator shall be returned.
defaultValue - The default value to be returned if indicator can be found.
Returns:
See description.

getADKConfigDir

public java.lang.String getADKConfigDir(java.lang.String agentID)
Returns the SIFWorks ADK configuration file directory for the given agent. If the property doesn't exist then null is returned.

The property that this method attempts to access must have the following structure:

agent._agentID_.cfg.location=_path_to_config_file

Parameters:
agentID - The agentID of the agent for which the SIFWorks ADK configuration file directory shall be returned.
Returns:
See description.

getADKConfigFileName

public java.lang.String getADKConfigFileName(java.lang.String agentID)
Returns the SIFWorks ADK configuration file name for the given agent. If the property doesn't exist then the agentID is returned as the file name.

The property that this method attempts to access must have the following structure:

agent._agentID_.cfg.name=_name_of_config_file

Parameters:
agentID - The agentID of the agent for which the SIFWorks ADK configuration file name shall be returned.
Returns:
See description.

getADKConfigPathAndFileName

public java.lang.String getADKConfigPathAndFileName(java.lang.String agentID)
Returns the SIFWorks ADK configuration file name with the full path for the given agent. This is a convenience method that simply concatenates the getADKConfigDir() with the getADKConfigFileName(). If any of the values (path of filename) is null then null is returned.

Parameters:
agentID - The agentID of the agent for which the SIFWorks ADK configuration file name shall be returned.
Returns:
See description.

getLogDir

public java.lang.String getLogDir(java.lang.String agentID)
Returns the directory for Log4J logging for the given agent. If the property doesn't exist then null is returned.

The property that this method attempts to access must have the following structure:

agent._agentID_.log.dir=_path_to_directory

Parameters:
agentID - The agentID of the agent for which the logging directory shall be returned.
Returns:
See description.

getLogFileName

public java.lang.String getLogFileName(java.lang.String agentID)
Returns the logging file name for the given agent. If the property doesn't exist then the agentID is returned as the file name.

The property that this method attempts to access must have the following structure:

agent._agentID_.log.name=_name_of_log_file

Parameters:
agentID - The agentID of the agent for which the log file name shall be returned.
Returns:
See description.

getLogPathAndFileName

public java.lang.String getLogPathAndFileName(java.lang.String agentID)
Returns the logging file name with the full path for the given agent. This is a convenience method that simply concatenates the getLogDir() with the getLogFileName(). If any of the values (path of filename) is null then null is returned.

Parameters:
agentID - The agentID of the agent for which the logging configuration file name shall be returned.
Returns:
See description.

getWorkDir

public java.lang.String getWorkDir(java.lang.String agentID)
Returns the SIFWorks ADK working directory for the given agent. If the property doesn't exist then null is returned.

The property that this method attempts to access must have the following structure:

agent._agentID_.workdir=_path_to_directory

Parameters:
agentID - The agentID of the agent for which the working directory shall be returned.
Returns:
See description.

getDebugLevel

public java.lang.String getDebugLevel(java.lang.String agentID)
Returns the debug level for the given agent. If no value is found then DBG_NONE is returned.

The property that this method attempts to access must have the following structure:

agent._agentID_.debugLevel=_debug_level_

Parameters:
agentID - The agentID of the agent for which the debug level shall be returned.
Returns:
See description.

getSubscriberBasePackageName

public java.lang.String getSubscriberBasePackageName(java.lang.String agentID)
Returns the package name of the subscribers. All subscriber classes listed in the property file will be assumed to be in this package. This value must be a fully qualified java package name. If no value is found then null is returned.

The property that this method attempts to access must have the following structure:

agent._agentID_.subscriber.basePackageName=_fully_quaified_package_name_

Parameters:
agentID - The agentID of the agent for which the package name shall be returned.
Returns:
See description.

getPublisherBasePackageName

public java.lang.String getPublisherBasePackageName(java.lang.String agentID)
Returns the package name of the publishers. All publisher classes listed in the property file will be assumed to be in this package. This value must be a fully qualified java package name. If no value is found then null is returned.

The property that this method attempts to access must have the following structure:

agent._agentID_.publisher.basePackageName=_fully_quaified_package_name_

Parameters:
agentID - The agentID of the agent for which the package name shall be returned.
Returns:
See description.

getPublishers

public java.util.List<java.lang.String> getPublishers(java.lang.String agentID)
This method returns a list of publisher names for a given agent. If no publishers are listed then an empty list is returned. The names of the publishers must match a class name for an implemented publisher. The publisher class must exist and must extend the BasePublisher class.

The property that this method attempts to access must have the following structure:

agent._agentID_.publishers=_comma_separated_list_

Parameters:
agentID - The agentID of the agent for which the publisher list shall be returned.
Returns:
See description.

getSubscribers

public java.util.List<java.lang.String> getSubscribers(java.lang.String agentID)
This method returns a list of subscriber names for a given agent. If no subscribers are listed then an empty list is returned. The names of the subscribers must match a class name for an implemented subscriber. The subscriber class must exist and must extend the BaseSubscriber class.

The property that this method attempts to access must have the following structure:

agent._agentID_.subscribers=_comma_separated_list_

Parameters:
agentID - The agentID of the agent for which the subscriber list shall be returned.
Returns:
See description.

getTestMode

public boolean getTestMode(java.lang.String agentID)
This method returns the test mode indicator for the given agent. If that doesn't exist then the false is returned.

Valid values in the property file for this property is 'true' or 'false'.

The property that this method attempts to access must have the following structure:

agent._agentID_.testMode=true|false

Parameters:
agentID - The agentID of the agent for which the test mode indicator shall be returned.
Returns:
See description.

getTestDir

public java.lang.String getTestDir(java.lang.String agentID)
Returns the test directory for the given agent. If the property doesn't exist then null is returned. The test directory is used if the agent runs in test mode and messages are only read/written to the file system.

The property that this method attempts to access must have the following structure:

agent._agentID_.test.data.directory=_path_to_directory_

Parameters:
agentID - The agentID of the agent for which the working directory shall be returned.
Returns:
See description.

getMappingName

public java.lang.String getMappingName(java.lang.String agentID)
Returns the name of the mapping section to be used for this agent. This name must match the node in the SIFWorks ADK configuration file for the given agent. If the property is not given then 'Default' is assumed and returned.

The property that this method attempts to access must have the following structure:

agent._agentID_.mapping.name=_name_

Parameters:
agentID - The agentID of the agent for which the mapping name shall be returned.
Returns:
See description.

getStartupDelay

public int getStartupDelay(int defalutValue)
Returns the value for the start up delay in seconds between publishers and subscribers. There might be a reason for starting them with some delay in between such as DB or any other resource access.

The property that this method attempts to access must have the following structure:

agent.thread.startup.delay=_delay_in_seconds_

Returns:
See description.

getNumConsumerThreads

public int getNumConsumerThreads(java.lang.String agentID,
                                 java.lang.String subscriberID)
This method returns the number of threads that shall be initiated to consume messages retrieved by the given subscriber. If no such number exists for the given subscriber then it will attempt to return the number of threads of this agent. If that doesn't exist either then the default number of 1 is returned.

The property that this method attempts to access must have the following structure:

agent._agentID_._subscriber_.consumer.numThreads=_int_value_

or

agent._agentID_.consumer.numThreads=_int_value_

in case of the global setting

Parameters:
agentID - The agentID of the agent for which the number of threads shall be returned.
subscriberID - The subscriberID of the subscriber for which the number of threads shall be returned.
Returns:
See description.

getNumConsumerThreads

public int getNumConsumerThreads(java.lang.String agentID)
This method returns the number of threads that shall be initiated to consume messages retrieved by the given agent. If that doesn't exist then the default value of 1 is returned.

The property that this method attempts to access must have the following structure:

agent._agentID_.consumer.numThreads=_int_value_

Parameters:
agentID - The agentID of the agent for which the frequency shall be returned.
Returns:
See description.

getProperties

public java.util.Properties getProperties()
This method returns the values of the SIFCommon Framework Property file as a property structure. This method is intended to be used if one adds additional properties to the file that are not the default properties for which a method is provided within this class. Generally one should use the other getter methods of this class to access the values of the SIFCommon Framework Property file.

Returns:
the values of the SIFCommon Framework Property file as a property structure. Null if the file could not be read.

getEventBatchSize

public int getEventBatchSize()

getCustonObjBasePackageName

public java.lang.String getCustonObjBasePackageName(java.lang.String agentID)
Returns the package name of the custom objects. All custom object classes listed in the property file will be assumed to be in this package. This value must be a fully qualified java package name. If no value is found then null is returned.

The property that this method attempts to access must have the following structure:

agent._agentID_.customObjects.basePackageName=_fully_quaified_package_name_

Parameters:
agentID - The agentID of the agent for which the package name shall be returned.
Returns:
See description.

getCustomObjects

public java.util.List<java.lang.String> getCustomObjects(java.lang.String agentID)
This method returns a list of custom object names for a given agent. If no custom objects are listed then an empty list is returned. The names of the custom objects must match a class name for an implemented custom objects. The custom object class must exist and must implement the CustomObject interface.

The property that this method attempts to access must have the following structure:

agent._agentID_.customObjects=_comma_separated_list_

Parameters:
agentID - The agentID of the agent for which the publisher list shall be returned.
Returns:
See description.

getPropertyAsInt

public java.lang.Integer getPropertyAsInt(java.lang.String propertyName)
Returns the given property as a Integer object. If it doesn't exist or is not an Integer then null is returned.


getPropertyAsInt

public int getPropertyAsInt(java.lang.String propertyName,
                            int defaultValue)
Returns the given property as a int. If it doesn't exist or is not an Integer then the default value is returned.


getPropertyAsBool

public java.lang.Boolean getPropertyAsBool(java.lang.String propertyName)
Returns the given property as a boolean object. If it doesn't exist or is not a boolean then null is returned.


getPropertyAsBool

public boolean getPropertyAsBool(java.lang.String propertyName,
                                 boolean defaultValue)
Returns the given property as a boolean. If it doesn't exist or is not a boolean then the default value is returned.


getPropertyAsString

public java.lang.String getPropertyAsString(java.lang.String propertyName,
                                            java.lang.String defaultValue)
Returns the given property as a String. If it doesn't exist or is empty then the default value is returned.


getFromCommaSeparated

public java.util.List<java.lang.String> getFromCommaSeparated(java.lang.String propertyName)

getPathAndFileName

public java.lang.String getPathAndFileName(java.lang.String path,
                                           java.lang.String name)
Builds a full path and file name. If path is not given then the file name is returned.