Project Wonder 5.0

er.extensions.foundation
Class ERXConfigurationManager

java.lang.Object
  extended by er.extensions.foundation.ERXConfigurationManager

public class ERXConfigurationManager
extends java.lang.Object

Configuration Manager handles rapid turnaround for system configuration as well as swizzling of the EOModel connection dictionaries.

Placing configuration parameters

You can provide the system configuration by the following ways:
Note: This is the standard way for WebObjects 5.x applications.

Loading order of the configuration parameters

When the application launches, configuration parameters will be loaded by the following order. ERXConfigurationManager trys to reload them by the exactly same order when one of those configuration files changes.

1. Properties in frameworks that the application links to
2. Properties in the application
3. WebObjects.properties under the home directory
4. Command line arguments

If there is a conflicting parameter between the files and arguments, the latter one overrides the earlier one.

Note that the order between frameworks does not seems to be specified. You should not put conflicting parameters between framework Properties files. On the other hand, the application Properties should be always loaded after all framework Properties are loaded. You can safely override parameters on the frameworks from the applications Properties.

Changing the connection dictionary

To do this for Oracle you can either specify on a per model basis or on a global basis.

 Global:
      dbConnectServerGLOBAL = myDatabaseServer
      dbConnectUserGLOBAL = me
      dbConnectPasswordGLOBAL = secret
      dbConnectPluginGLOBAL = Oracle
 Per Model for say model ER:
      ER.DBServer = myDatabaseServer
      ER.DBUser = me
      ER.DBPassword = secret
      ER.DBPlugin = Oracle
 
 Openbase: same, with DBDatabase and DBHostname
 
 JDBC: same with dbConnectURLGLOBAL, or ER.DBURL
 

Prototypes can be swapped globally or per model either by hydrating an archived prototype entity for a file or from another entity.

Properties
er.extensions.ERXConfigurationManager.PropertiesTouchFile if this property is set to a file name, the application will register for notifications of changes to that file and when that file is touched, the application will re-load properties.
           

Field Summary
protected  java.lang.String _hostName
          holds the host name
static java.lang.String ConfigurationDidChangeNotification
          Notification posted when the configuration is updated.
protected  java.lang.String documentRoot
           
static org.apache.log4j.Logger log
          logging support
static int MacOSXOperatingSystem
           
static int SolarisOperatingSystem
           
static int UnknownOperatingSystem
           
static int WindowsOperatingSystem
           
 
Method Summary
 java.util.Properties applyConfiguration(java.util.Properties systemProperties)
          This will overlay the current system config files.
 java.util.Properties commandLineArgumentProperties()
          Returns the command line arguments as Properties.
 java.lang.String[] commandLineArguments()
          Returns the command line arguments.
 void configureRapidTurnAround()
          Sets up the system for rapid turnaround mode.
static ERXConfigurationManager defaultManager()
          Returns the single instance of this class
 java.util.Properties defaultProperties()
          Returns the command line arguments as Properties.
 java.lang.String documentRoot()
          Path to the web server's document root.
 java.lang.String hostName()
          Gets the default host name for the current local host.
 void initialize()
          Initializes the configuration manager.
 boolean isDeployedAsServlet()
          Checks if the application is deployed as a servlet.
 void loadConfiguration()
          This will overlay the current system config files.
 int operatingSystem()
           
 void setCommandLineArguments(java.lang.String[] newCommandLineArguments)
          Sets the command line arguments.
 void updateAllSystemProperties(com.webobjects.foundation.NSNotification notification)
           
 void updateSystemProperties(com.webobjects.foundation.NSNotification n)
          Updates the configuration from the current configuration and posts ConfigurationDidChangeNotification.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

public static final org.apache.log4j.Logger log
logging support


ConfigurationDidChangeNotification

public static final java.lang.String ConfigurationDidChangeNotification
Notification posted when the configuration is updated. The Java system properties is the part of the configuration.

See Also:
Constant Field Values

WindowsOperatingSystem

public static final int WindowsOperatingSystem
See Also:
Constant Field Values

MacOSXOperatingSystem

public static final int MacOSXOperatingSystem
See Also:
Constant Field Values

SolarisOperatingSystem

public static final int SolarisOperatingSystem
See Also:
Constant Field Values

UnknownOperatingSystem

public static final int UnknownOperatingSystem
See Also:
Constant Field Values

documentRoot

protected java.lang.String documentRoot

_hostName

protected java.lang.String _hostName
holds the host name

Method Detail

defaultManager

public static ERXConfigurationManager defaultManager()
Returns the single instance of this class

Returns:
the configuration manager

commandLineArguments

public java.lang.String[] commandLineArguments()
Returns the command line arguments. ERXApplication#main sets this value.

Returns:
the command line arguments as a String[]
See Also:
setCommandLineArguments(java.lang.String[])

commandLineArgumentProperties

public java.util.Properties commandLineArgumentProperties()
Returns the command line arguments as Properties. ERXApplication#main sets this value.

Returns:
the command line arguments as a String[]
See Also:
setCommandLineArguments(java.lang.String[])

defaultProperties

public java.util.Properties defaultProperties()
Returns the command line arguments as Properties. ERXApplication#main sets this value.

Returns:
the command line arguments as a String[]
See Also:
setCommandLineArguments(java.lang.String[])

setCommandLineArguments

public void setCommandLineArguments(java.lang.String[] newCommandLineArguments)
Sets the command line arguments. ERXApplication#main will call this method when the application starts up.

See Also:
commandLineArguments()

initialize

public void initialize()
Initializes the configuration manager. The framework principal ERXExtensions calls this method when the ERExtensions framework is loaded.


configureRapidTurnAround

public void configureRapidTurnAround()
Sets up the system for rapid turnaround mode. It will watch the changes on Properties files in application and framework bundles and WebObjects.properties under the home directory. Rapid turnaround mode will only be enabled if there are such files available and system has WOCaching disabled.


loadConfiguration

public void loadConfiguration()
This will overlay the current system config files. It will then re-load the command line args.


applyConfiguration

public java.util.Properties applyConfiguration(java.util.Properties systemProperties)
This will overlay the current system config files. It will then re-load the command line args.


updateSystemProperties

public void updateSystemProperties(com.webobjects.foundation.NSNotification n)
Updates the configuration from the current configuration and posts ConfigurationDidChangeNotification. It also calls ERXLogger#configureLogging to reconfigure the logging system.

The configuration files: Properties and WebObjects.properties files are reloaded to the Java system properties by the same order to the when the system starts up. Then the command line arguments will be applied to the properties again so that the configuration will be consistent during the application lifespan.

This method is called when rapid turnaround is enabled and one of the configuration files changes.

Parameters:
n - NSNotification object for the event (null means load all files)

updateAllSystemProperties

public void updateAllSystemProperties(com.webobjects.foundation.NSNotification notification)

operatingSystem

public int operatingSystem()

documentRoot

public java.lang.String documentRoot()
Path to the web server's document root. This implementation tries first to resolve the application.name()+ "DocumentRoot" property value, then the ERXDocumentRoot property before getting the DocumentRoot key in your WebServerConfig.plist in the JavaWebObjects bundle.

Returns:
to the web server's document root.

hostName

public java.lang.String hostName()
Gets the default host name for the current local host.

Returns:
host name or UnknownHost if the host is unknown.

isDeployedAsServlet

public boolean isDeployedAsServlet()
Checks if the application is deployed as a servlet.

The current implementation only checks if the application is linked against JavaWOJSPServlet.framework.

Returns:
true if the application is deployed as a servlet

Last updated: Tue, Feb 21, 2017 • 05:45 PM CET

Copyright © 2002 – 2007 Project Wonder.