org.xorm.util
Class AppConfig

java.lang.Object
  |
  +--org.xorm.util.AppConfig

public class AppConfig
extends Object

Generic JDO application configuration. This object encapsulates the basic functionality required to instantiate a set of properties and a JDO persistence manager factory.

Author:
Dan Checkoway
See Also:
AppConfigFactory

Field Summary
static String DEFAULT_CONNECTION_NAME
           
protected  Logger logger
           
protected  Hashtable pmFactoriesByName
           
protected  Properties props
           
 
Constructor Summary
AppConfig()
          Constructor
AppConfig(Properties props)
          Constructor from Properties
 
Method Summary
static AppConfig getAppConfig(String jndiConfigResource, String configFileSystemProperty, String defaultConfigFile)
          Convenience method for getting a new AppConfig instance.
static AppConfig getAppConfig(String jndiConfigResource, String configFileSystemProperty, String defaultConfigFile, Class appConfigClass)
          Convenience method for getting a new AppConfig instance.
 PersistenceManager getPersistenceManager()
          Convenience method to get a persistence manager
 PersistenceManager getPersistenceManager(String name)
          Convenience method to get a persistence manager
 PersistenceManagerFactory getPersistenceManagerFactory()
          Get the default persistence manager factory
 PersistenceManagerFactory getPersistenceManagerFactory(String name)
          Get the associated persistence manager factory
 Properties getProperties()
          Get the underlying properties that this object wraps
 String getProperty(String propName)
          Get a property value
 String getProperty(String propName, String defaultValue)
          Get a property value with a default
protected  void loadProperties(Properties newProps)
          Load and absorb a set of properties
protected  void loadProperties(String propertyFileOrResource)
          Load properties from a file or resource
 void setPropertiesFile(String propertiesFile)
          This is called by the JRE or servlet engine resource manager.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_CONNECTION_NAME

public static final String DEFAULT_CONNECTION_NAME
See Also:
Constant Field Values

logger

protected Logger logger

props

protected Properties props

pmFactoriesByName

protected Hashtable pmFactoriesByName
Constructor Detail

AppConfig

public AppConfig()
Constructor


AppConfig

public AppConfig(Properties props)
Constructor from Properties

Parameters:
props - the Properties to clone and use
Method Detail

loadProperties

protected void loadProperties(String propertyFileOrResource)
Load properties from a file or resource

Parameters:
propertyFileOrResource - the file or resource path to the given properties file; the file system is checked first, falling back on the classpath

loadProperties

protected void loadProperties(Properties newProps)
Load and absorb a set of properties

Parameters:
newProps - the properties to absorb

getProperty

public String getProperty(String propName)
Get a property value

Parameters:
propName - the name of the value to get
Returns:
the property value or null if not found

getProperty

public String getProperty(String propName,
                          String defaultValue)
Get a property value with a default

Parameters:
propName - the name of the value to get
defaultValue - the value to return if the given property was not explicitly set
Returns:
the property value or the default value

getProperties

public Properties getProperties()
Get the underlying properties that this object wraps

Returns:
the underlying properties

getPersistenceManagerFactory

public PersistenceManagerFactory getPersistenceManagerFactory()
Get the default persistence manager factory

Returns:
the default persistence manager factory
See Also:
PersistenceManagerFactory

getPersistenceManagerFactory

public PersistenceManagerFactory getPersistenceManagerFactory(String name)
Get the associated persistence manager factory

Parameters:
name - the name of the connection, used as a property prefix
Returns:
the persistence manager factory identified by the given name
See Also:
PersistenceManagerFactory

getPersistenceManager

public PersistenceManager getPersistenceManager()
Convenience method to get a persistence manager

Returns:
a new persistence manager from the default persistence manager factory
See Also:
PersistenceManager

getPersistenceManager

public PersistenceManager getPersistenceManager(String name)
Convenience method to get a persistence manager

Parameters:
name - the name of the connection, used as a property prefix
Returns:
a new persistence manager from the persistence manager factory identified by the given name
See Also:
PersistenceManager

setPropertiesFile

public void setPropertiesFile(String propertiesFile)
This is called by the JRE or servlet engine resource manager. The propertiesFile, usually a parameter to the JNDI resource, should point to the properties file to be loaded.


getAppConfig

public static AppConfig getAppConfig(String jndiConfigResource,
                                     String configFileSystemProperty,
                                     String defaultConfigFile)
Convenience method for getting a new AppConfig instance. Internally, this constructs an AppConfigFactory and returns its configuration.


getAppConfig

public static AppConfig getAppConfig(String jndiConfigResource,
                                     String configFileSystemProperty,
                                     String defaultConfigFile,
                                     Class appConfigClass)
Convenience method for getting a new AppConfig instance. Internally, this constructs an AppConfigFactory and returns its configuration.



$Header: /cvsroot/xorm/xorm/docs/api/org/xorm/util/AppConfig.html,v 1.2 2004/05/30 08:55:10 wbiggs Exp $