org.obe.util
Class CommonConfig

java.lang.Object
  extended byorg.obe.util.CommonConfig
Direct Known Subclasses:
ClientConfig

public class CommonConfig
extends java.lang.Object

Provides common configuration-related functionality.

Author:
Adrian Price

Field Summary
protected static org.apache.commons.logging.Log _logger
           
protected static java.util.Properties _props
           
static java.lang.String CONFIG_DIR_PROP
          Property key for the configuration directory.
protected static java.lang.String CONFIG_FILE
           
static java.lang.String CREDENTIALS_PROP
          Property key for the default JAAS credentials.
static java.lang.String DATE_FORMAT_PROP
          Property key for the default date format.
static java.lang.String DURATION_UNIT_PROP
          Property key for the default duration unit.
static java.lang.String PRINCIPAL_PROP
          Property key for the default JAAS principal name.
static java.lang.String PROTOCOL_PROP
          Property key for the default client protocol type.
 
Constructor Summary
protected CommonConfig()
           
 
Method Summary
static java.net.URL findResource(java.lang.String resource)
          Locates a configuration resource.
protected static boolean getBooleanProperty(java.lang.String propertyName, boolean defaultValue)
           
static java.io.File getConfigDir()
          Returns the configuration directory.
static java.lang.String getCredentials()
          Returns the credentials with which the client should authenticate.
static java.lang.String getDefaultDateFormat()
          Returns the date format to be used when rendering dates.
static java.lang.String getDefaultDurationUnit()
          Returns the default duration unit to use if an XPDL file does not specify a default.
protected static int getIntProperty(java.lang.String propertyName, int defaultValue)
           
static java.lang.String getPrincipal()
          Returns the default client principal name.
static java.lang.String getProtocol()
          Returns the default client protocol type.
protected static java.lang.String getStringProperty(java.lang.String propertyName, java.lang.String defaultValue)
           
static org.xml.sax.InputSource openInputSource(java.lang.String resource)
          Opens a SAX input source for a resource.
static java.io.InputStream openInputStream(java.lang.String resource)
          Opens an input stream for the specified resource.
static java.io.OutputStream openOutputStream(java.lang.String resource)
          Opens an output stream for the specified resource.
static java.io.Reader openReader(java.lang.String resource)
          Opens a character stream for a resource.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_logger

protected static final org.apache.commons.logging.Log _logger

CONFIG_FILE

protected static final java.lang.String CONFIG_FILE
See Also:
Constant Field Values

PROTOCOL_PROP

public static final java.lang.String PROTOCOL_PROP
Property key for the default client protocol type.

See Also:
getProtocol(), Constant Field Values

PRINCIPAL_PROP

public static final java.lang.String PRINCIPAL_PROP
Property key for the default JAAS principal name.

See Also:
getPrincipal(), Constant Field Values

CREDENTIALS_PROP

public static final java.lang.String CREDENTIALS_PROP
Property key for the default JAAS credentials.

See Also:
getCredentials(), Constant Field Values

CONFIG_DIR_PROP

public static final java.lang.String CONFIG_DIR_PROP
Property key for the configuration directory.

See Also:
getConfigDir(), Constant Field Values

DATE_FORMAT_PROP

public static final java.lang.String DATE_FORMAT_PROP
Property key for the default date format.

See Also:
getDefaultDateFormat(), Constant Field Values

DURATION_UNIT_PROP

public static final java.lang.String DURATION_UNIT_PROP
Property key for the default duration unit.

See Also:
getDefaultDurationUnit(), Constant Field Values

_props

protected static final java.util.Properties _props
Constructor Detail

CommonConfig

protected CommonConfig()
Method Detail

getBooleanProperty

protected static boolean getBooleanProperty(java.lang.String propertyName,
                                            boolean defaultValue)

getIntProperty

protected static int getIntProperty(java.lang.String propertyName,
                                    int defaultValue)

getStringProperty

protected static java.lang.String getStringProperty(java.lang.String propertyName,
                                                    java.lang.String defaultValue)

getConfigDir

public static java.io.File getConfigDir()
Returns the configuration directory. Loose files in this directory override their counterparts in the obeconfig.jar archive.

The setting reflects the string value of the system property obe.config.dir.

Returns:
The configuration directory, defaulting to the current directory.
See Also:
CONFIG_DIR_PROP

getProtocol

public static java.lang.String getProtocol()
Returns the default client protocol type.

The setting reflects the string value of the configuration property obe.client.protocol.

Returns:
Client protocol type, defaulting to "local".
See Also:
PROTOCOL_PROP

getPrincipal

public static java.lang.String getPrincipal()
Returns the default client principal name.

The setting reflects the string value of the configuration property obe.client.principal.

Returns:
Client principal name, defaulting to "system".
See Also:
PRINCIPAL_PROP

getCredentials

public static java.lang.String getCredentials()
Returns the credentials with which the client should authenticate.

The setting reflects the string value of the configuration property obe.client.credentials.

Returns:
Client credentials, defaulting to "password".
See Also:
CREDENTIALS_PROP

getDefaultDateFormat

public static java.lang.String getDefaultDateFormat()
Returns the date format to be used when rendering dates.

The setting reflects the value of the configuration property obe.xpdl.date.format.

Returns:
Date format, defaulting to yyyy-MM-dd'T'HH:mm:ssZ.
See Also:
DATE_FORMAT_PROP

getDefaultDurationUnit

public static java.lang.String getDefaultDurationUnit()
Returns the default duration unit to use if an XPDL file does not specify a default.

The setting reflects the value of the configuration property obe.xpdl.duration.unit.

Returns:
Default duration unit, defaulting to "D" (day).
See Also:
DURATION_UNIT_PROP

findResource

public static java.net.URL findResource(java.lang.String resource)
Locates a configuration resource. The resource can either be in the configuration directory, or it can be packaged in obeconfig.jar.

Parameters:
resource - The resource name.
Returns:
The URL of the resource, or null if it could not be located.

openInputStream

public static java.io.InputStream openInputStream(java.lang.String resource)
Opens an input stream for the specified resource. The caller is responsible for closing the input stream after reading from it. The implementation checks first whether the resource is present as a file in the configuration directory, and if this is not the case it checks for the presence of the resource inside the obeconfig.jar file.

Parameters:
resource - The partially qualified resource name, relative to the configuration directory or the root of obeconfig.jar.
Returns:
The input stream, or null if the resource could not be located.

openOutputStream

public static java.io.OutputStream openOutputStream(java.lang.String resource)
Opens an output stream for the specified resource. The caller is responsible for closing the output stream after writing to it. The implementation attempts to open the specified file in the configuration directory (or a subdirectory thereof if the resource name contains a path).

Parameters:
resource - The partially qualified resource name, relative to the configuration directory.
Returns:
The output stream, or null if the resource could not be located.

openInputSource

public static org.xml.sax.InputSource openInputSource(java.lang.String resource)
Opens a SAX input source for a resource. The caller is responsible for closing the associated byte stream afterwards.

Parameters:
resource - The resource name.
Returns:
The input source, or null if the resource could not be located.

openReader

public static java.io.Reader openReader(java.lang.String resource)
Opens a character stream for a resource. The caller is responsible for closing the reader afterwards.

Parameters:
resource - The resource name.
Returns:
The character stream, or null if the resource could not be located.


SourceForge.net Logo OBE-1.0 Copyright (C) 2002-2006 Adrian Price. All Rights Reserved.