org.openeai.config
Class AppConfig

java.lang.Object
  |
  +--org.openeai.OpenEaiObject
        |
        +--org.openeai.config.EnterpriseConfigurationObjectImpl
              |
              +--org.openeai.config.AppConfig
All Implemented Interfaces:
EnterpriseConfigurationObject

public class AppConfig
extends EnterpriseConfigurationObjectImpl
implements EnterpriseConfigurationObject

The AppConfig class acts as a container for all pre-configured object that an application may use. It reads an application's config XML document, instantiates the objects contained in that document and configures them according to the information found in the document. Then, those objects are available to the application via the getObject, getObjectByType or getObjectsLike methods.

The config document can be stored in several different places which include: file system, web server or directory server. Typically, an application instantiates app config using a properties file that contains all the properties AppConfig needs to find the configuration document and configure the application listed in the properties file.

Currently, an AppConfig is associated to these distinct types of applications:

Configuration Parameters:

These are the configuration parameters that may exist in an application's property file.

Name Required Description
instanceName no, unless a gateway is being started For gateways, this property is used by PubSubConsumers to establish their durable subscriptions. This should be reflective of where the gateway is physically running (machine name etc.)
providerUrl yes Indicates where the config doc is located. If the protocol specified is "ldaps" AppConfig will use SSL to connect to the directory server. It does this by using JSSE. Other protocols that can be specified include http:, https: and file:. A local file system path can also be specified like "/usr/configs/ConfigDoc.xml" or "c:/user/configs/ConfigDoc.xml".
initialContextFactory no, unless the providerUrl is ldap/ldaps The initialContextFactory property indicates how AppConfig is to connect to the store (only applies to directory server connection)
securityPrincipal no, unless the providerUrl is ldap/ldaps The securityPrincipal and securityCredentials are directory server credentials used to connect to the providerUrl in the directory server. This is only related to configuration documents stored in a directory server.
securityCredentials no, unless the providerUrl is ldap/ldaps The securityPrincipal and securityCredentials are directory server credentials used to connect to the providerUrl in the directory server. This is only related to configuration documents stored in a directory server.
configDocName no, unless the providerUrl is ldap/ldaps name of the object as it's stored in the directory server.
messageComponentName yes the application/gateway etc. being configured specifically, as it's named in the config doc.

Example properties file:

Directory Server Example:

Web Server Example:

File system Example:

Version:
3.0 beta2 - 28 January 2003
Author:
Tod Jackson (tod@openeai.org), Steve Wheat (steve@openeai.org)

Field Summary
 
Fields inherited from class org.openeai.OpenEaiObject
logger
 
Constructor Summary
AppConfig()
          Constructor
AppConfig(org.jdom.Element configElement)
          This constructor might be used if an application has already parsed the deployment document and found the configuration Element associated to the application.
AppConfig(java.util.Properties props)
          This is the most commonly used constructor.
AppConfig(java.lang.String docUri, java.lang.String appName)
          This constructor might be used if an application knows URI of the document that is to be used to configure the application.
 
Method Summary
 java.lang.String dumpStats()
          Returns name and class information about all objects currently stored in this AppConfig object.
 java.lang.String getDocUri()
          Returns the config document URI that is used to locate the XML config document for this application.
 java.lang.Object getObject(java.lang.String name)
          Returns the object stored in this AppConfig object with the name passed in.
 java.lang.Object getObjectByType(java.lang.String className)
          Returns the first object stored in this AppConfig that maches the class name passed in.
 java.util.List getObjectsLike(java.lang.String pattern)
          Returns a Vector of objects currently stored in this AppConfig object with names that contain the pattern passed in.
 java.lang.String getProviderUrl()
          Returns the providerUrl instance variable associated with this Application.
 void init(org.jdom.Element eConfig)
          This is the "workhorse" initialization method for an AppConfig object.
 boolean isInitialized()
          Returns an indication that specifies if this AppConfig object has been initialized yet.
 void reInitialize()
          Re-initializes this AppConfig object.
 void setDocUri(java.lang.String docUri)
          Sets the config document URI that is used to locate the XML config document for this application.
 void setProviderUrl(java.lang.String url)
          Sets the providerUrl instance variable associated with this Application.
 
Methods inherited from class org.openeai.config.EnterpriseConfigurationObjectImpl
addProperty, getAppName, getConfigDoc, getConfigElementByAttributeValue, getElementByAttributeValue, getName, getType, getValidation, setAppName, setConfigDoc, setName, setType, setValidation
 
Methods inherited from class org.openeai.OpenEaiObject
addLog4jProperty, getDebug, getFromAddr, getLog4jProperties, getMailHost, getMailService, getProperties, getToAddr, initializeLog4j, initializeLog4j, initializeLog4j, setDebug, setFromAddr, setMailHost, setMailService, setProperties, setToAddr
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.openeai.config.EnterpriseConfigurationObject
getAppName, getProperties, setAppName
 

Constructor Detail

AppConfig

public AppConfig()
Constructor


AppConfig

public AppConfig(java.lang.String docUri,
                 java.lang.String appName)
          throws EnterpriseConfigurationObjectException
This constructor might be used if an application knows URI of the document that is to be used to configure the application. Note, this can only be a web address or a file URI. This is generally not needed but is provided as a potential convenience method.

Throws:
EnterpriseConfigurationObjectException - if any errors occur while initializing the component.

AppConfig

public AppConfig(java.util.Properties props)
          throws EnterpriseConfigurationObjectException
This is the most commonly used constructor. Most applications, gateways, servlets etc. will simply read a properties file on the file system which contains information regarding where to find the configuration document and what component to configure. See Class description for more details on the Properties file used.

Throws:
EnterpriseConfigurationObjectException - if any errors occur while initializing the component.

AppConfig

public AppConfig(org.jdom.Element configElement)
          throws EnterpriseConfigurationObjectException
This constructor might be used if an application has already parsed the deployment document and found the configuration Element associated to the application. This is generally not needed but is provided as a potential convenience method.

Throws:
EnterpriseConfigurationObjectException - if any errors occur while initializing the component.
Method Detail

setProviderUrl

public final void setProviderUrl(java.lang.String url)
Sets the providerUrl instance variable associated with this Application. This is the location in the directory server, file system or web server where the deployment document resides. i.e. - this is where the AppConfig object should "look" for the deployment document.


getProviderUrl

public final java.lang.String getProviderUrl()
Returns the providerUrl instance variable associated with this Application. This is the location in the directory server, file system or web server where the deployment document resides. i.e. - this is where the AppConfig object should "look" for the deployment document.

Returns:
String the providerUrl.

isInitialized

public final boolean isInitialized()
Returns an indication that specifies if this AppConfig object has been initialized yet.

Returns:
boolean

getDocUri

public final java.lang.String getDocUri()
Returns the config document URI that is used to locate the XML config document for this application.

Returns:
String

setDocUri

public final void setDocUri(java.lang.String docUri)
Sets the config document URI that is used to locate the XML config document for this application.


reInitialize

public final void reInitialize()
                        throws EnterpriseConfigurationObjectException
Re-initializes this AppConfig object. This method stops any running component that it's managing, re-reads the deployment document and re-initializes/re-starts all objects for this application that's listed in the deployment document.

Throws:
EnterpriseConfigurationObjectException

getObjectByType

public final java.lang.Object getObjectByType(java.lang.String className)
                                       throws EnterpriseConfigurationObjectException
Returns the first object stored in this AppConfig that maches the class name passed in.

Returns:
Object
Throws:
java.lang.NullPointerException - if no objects of type passed in exist.
EnterpriseConfigurationObjectException

getObjectsLike

public final java.util.List getObjectsLike(java.lang.String pattern)
                                    throws EnterpriseConfigurationObjectException
Returns a Vector of objects currently stored in this AppConfig object with names that contain the pattern passed in.

Returns:
Vector of objects who's names contain the pattern passed in.
Throws:
java.lang.NullPointerException - if no objects exist with names containing the pattern passed in.
EnterpriseConfigurationObjectException

getObject

public final java.lang.Object getObject(java.lang.String name)
                                 throws EnterpriseConfigurationObjectException
Returns the object stored in this AppConfig object with the name passed in. The name of the objects are specified in the XML Configuration documents and are the names by which AppConfig stores objects as it configures itself.

Returns:
Object who's name matches the name passed in.
Throws:
java.lang.NullPointerException - if no object exists with a name passed in.
EnterpriseConfigurationObjectException

init

public void init(org.jdom.Element eConfig)
          throws EnterpriseConfigurationObjectException
This is the "workhorse" initialization method for an AppConfig object. This method is called once the "Configuration" element for an application, gateway etc. has been retrieved from their config document. The configuration element passed in is used to determine which objects to instantiate and initialize with the information found in the Configuration element.

This method loops through all the child elements within the Configuration element passed in and instantiates configuration Java objects with those individual config elements. Then, it passes those Java objects to the appropriate Java object's constructor. These Java objects that are instantiated with the configuration objects, are then available to applications via the getObject, getObjectsLike and getObjectByType methods.

For example, an XML aware ProducerConfig object is instantiated/initialized with the ProducerConfig XML element. This object is then used to construct either a PointToPointProducer or a PubSubProducer foundation component depending on the information contained in the ProducerConfig object/element. Finally, the Producer that's instantiated is stored within the AppConfig object and can be retrieved during application execution by the application developer. This way, the Producer is instantiated, configured and potentially started (ready for producing messages) all based on information contained in the configuration document. All the application developer has to do is enter the appropriate configuration information into the config document and start his application. When the application is started, an AppConfig object is built and the appropriate Producers are added to it for use by the application being developed.

Specified by:
init in interface EnterpriseConfigurationObject
Throws:
EnterpriseConfigurationObjectException - if any errors occur while initializing the component.

dumpStats

public java.lang.String dumpStats()
Returns name and class information about all objects currently stored in this AppConfig object. Line feed included. Debug use only...

Returns:
String


Copyright © 2002, OpenEAI Software Foundation