|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.cayenne.conf.Configuration
public abstract class Configuration
This class is an entry point to Cayenne. It loads all configuration files and
instantiates main Cayenne objects. Used as a singleton via the
getSharedConfiguration()
method.
To use a custom subclass of Configuration, Java applications must call
initializeSharedConfiguration()
with the subclass as argument. This will create
and initialize a Configuration singleton instance of the specified class. By default
DefaultConfiguration
is instantiated.
Field Summary | |
---|---|
static org.apache.commons.collections.Predicate |
ACCEPT_ALL_DATAVIEWS
|
protected org.apache.cayenne.conf.Configuration.ConfigurationShutdownHook |
configurationShutdownHook
|
protected CayenneMap |
dataDomains
Lookup map that stores DataDomains with names as keys. |
protected java.util.Map |
dataViewLocations
|
static java.lang.Class |
DEFAULT_CONFIGURATION_CLASS
|
static java.lang.String |
DEFAULT_DOMAIN_FILE
|
static java.lang.String |
DEFAULT_LOGGING_PROPS_FILE
|
protected java.lang.String |
domainConfigurationName
|
protected EventManager |
eventManager
|
protected boolean |
ignoringLoadFailures
|
protected ConfigLoaderDelegate |
loaderDelegate
|
protected ConfigStatus |
loadStatus
|
protected DataSourceFactory |
overrideFactory
|
protected java.lang.String |
projectVersion
|
protected ConfigSaverDelegate |
saverDelegate
|
protected static Configuration |
sharedConfiguration
|
Constructor Summary | |
---|---|
protected |
Configuration()
Default constructor for new Configuration instances. |
protected |
Configuration(java.lang.String domainConfigurationName)
Default constructor for new Configuration instances using the given resource name as the main domain file. |
Method Summary | |
---|---|
void |
addDomain(DataDomain domain)
Adds new DataDomain to the list of registered domains. |
static void |
bootstrapSharedConfiguration(java.lang.Class cl)
Deprecated. since 1.2. Use Thread.currentThread().setContextClassLoader() instead. |
abstract boolean |
canInitialize()
Indicates whether initialize() can be called. |
static void |
configureCommonLogging()
Configures Cayenne logging properties. |
static void |
configureCommonLogging(java.net.URL propsFile)
Configures Cayenne logging properties using properties found at the specified URL. |
protected void |
configureLogging()
Configures log4J. |
abstract void |
didInitialize()
Called after successful completion of initialize() . |
DataSourceFactory |
getDataSourceFactory()
Returns an internal property for the DataSource factory that will override any settings configured in XML. |
java.util.Map |
getDataViewLocations()
|
DataDomain |
getDomain()
Returns default domain of this configuration. |
DataDomain |
getDomain(java.lang.String name)
Returns registered domain matching name or null if no
such domain is found. |
protected abstract java.io.InputStream |
getDomainConfiguration()
Returns a DataDomain as a stream or null if it cannot be found. |
java.lang.String |
getDomainConfigurationName()
Returns the name of the main domain configuration resource. |
java.util.Collection |
getDomains()
Returns an unmodifiable collection of registered DataDomain objects. |
EventManager |
getEventManager()
Returns EventManager used by this configuration. |
ConfigLoaderDelegate |
getLoaderDelegate()
Returns a delegate used for controlling the loading of configuration elements. |
ConfigStatus |
getLoadStatus()
Returns the load status. |
static org.apache.log4j.Level |
getLoggingLevel()
Deprecated. since 1.2 unused |
protected abstract java.io.InputStream |
getMapConfiguration(java.lang.String name)
Returns a DataMap with the given name or null if it cannot be found. |
java.lang.String |
getProjectVersion()
|
static java.lang.ClassLoader |
getResourceLoader()
Deprecated. since 1.2 use Thread.currentThread().getContextClassLoader(). This is what Cayenne uses internally. |
protected abstract ResourceLocator |
getResourceLocator()
Returns the resource locator used for finding and loading resources. |
ConfigSaverDelegate |
getSaverDelegate()
|
static Configuration |
getSharedConfiguration()
Use this method as an entry point to all Cayenne access objects. |
protected abstract java.io.InputStream |
getViewConfiguration(java.lang.String location)
|
abstract void |
initialize()
Initializes the new instance. |
static void |
initializeSharedConfiguration()
Creates and initializes shared Configuration object. |
static void |
initializeSharedConfiguration(java.lang.Class configurationClass)
Creates and initializes a shared Configuration object of a custom Configuration subclass. |
static void |
initializeSharedConfiguration(Configuration conf)
Sets the shared Configuration object to a new Configuration object. |
void |
installConfigurationShutdownHook()
|
boolean |
isIgnoringLoadFailures()
Returns whether to ignore any failures during map loading or not. |
static boolean |
isLoggingConfigured()
Indicates whether Log4j has been initialized, either by cayenne or otherwise. |
boolean |
loadDataView(DataView dataView)
|
boolean |
loadDataView(DataView dataView,
org.apache.commons.collections.Predicate dataViewNameFilter)
|
void |
removeDomain(java.lang.String name)
Unregisters DataDomain matching name |
void |
setDataSourceFactory(DataSourceFactory overrideFactory)
|
void |
setDataViewLocations(java.util.Map dataViewLocations)
Initializes configuration with the location of data views. |
protected void |
setDomainConfigurationName(java.lang.String domainConfigurationName)
Sets the name of the main domain configuration resource. |
void |
setEventManager(EventManager eventManager)
Sets EventManager used by this configuration. |
protected void |
setIgnoringLoadFailures(boolean ignoringLoadFailures)
Sets whether to ignore any failures during map loading or not. |
void |
setLoaderDelegate(ConfigLoaderDelegate loaderDelegate)
|
protected void |
setLoadStatus(ConfigStatus status)
Sets the load status. |
static void |
setLoggingConfigured(boolean state)
Indicate whether Log4j has been initialized. |
static void |
setLoggingLevel(org.apache.log4j.Level logLevel)
Deprecated. since 1.2 unused. |
void |
setProjectVersion(java.lang.String projectVersion)
|
void |
setSaverDelegate(ConfigSaverDelegate saverDelegate)
|
void |
shutdown()
Shutdowns all owned domains. |
void |
uninstallConfigurationShutdownHook()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String DEFAULT_LOGGING_PROPS_FILE
public static final java.lang.String DEFAULT_DOMAIN_FILE
public static final java.lang.Class DEFAULT_CONFIGURATION_CLASS
protected static Configuration sharedConfiguration
public static final org.apache.commons.collections.Predicate ACCEPT_ALL_DATAVIEWS
protected CayenneMap dataDomains
protected DataSourceFactory overrideFactory
protected ConfigStatus loadStatus
protected java.lang.String domainConfigurationName
protected boolean ignoringLoadFailures
protected ConfigLoaderDelegate loaderDelegate
protected ConfigSaverDelegate saverDelegate
protected org.apache.cayenne.conf.Configuration.ConfigurationShutdownHook configurationShutdownHook
protected java.util.Map dataViewLocations
protected java.lang.String projectVersion
protected EventManager eventManager
Constructor Detail |
---|
protected Configuration()
Configuration(String)
.
Configuration(String)
protected Configuration(java.lang.String domainConfigurationName)
configureLogging()
, then
setDomainConfigurationName(java.lang.String)
with the given domain configuration resource
name.
Method Detail |
---|
public static void bootstrapSharedConfiguration(java.lang.Class cl)
public static void configureCommonLogging()
cayenne-log.properties
is first done in $HOME/.cayenne, then in
CLASSPATH.
public static void configureCommonLogging(java.net.URL propsFile)
public static boolean isLoggingConfigured()
setLoggingConfigured(boolean)
will be called to
remember this.
public static void setLoggingConfigured(boolean state)
public static Configuration getSharedConfiguration()
Note that if you want to provide a custom Configuration, make sure you call one of
the initializeSharedConfiguration()
methods before your application code has
a chance to call this method.
public static java.lang.ClassLoader getResourceLoader()
public static org.apache.log4j.Level getLoggingLevel()
public static void setLoggingLevel(org.apache.log4j.Level logLevel)
public EventManager getEventManager()
public void setEventManager(EventManager eventManager)
public static void initializeSharedConfiguration()
DefaultConfiguration
will be instantiated and assigned to a singleton
instance of Configuration.
public static void initializeSharedConfiguration(java.lang.Class configurationClass)
public static void initializeSharedConfiguration(Configuration conf)
canInitialize()
and - if permitted -initialize()
followed by
didInitialize()
.
public abstract boolean canInitialize()
initialize()
can be called. Returning false
allows new instances to delay or refuse the initialization process.
public abstract void initialize() throws java.lang.Exception
java.lang.Exception
public abstract void didInitialize()
initialize()
.
protected abstract ResourceLocator getResourceLocator()
protected abstract java.io.InputStream getDomainConfiguration()
null
if it cannot be found.
protected abstract java.io.InputStream getMapConfiguration(java.lang.String name)
null
if it cannot be found.
protected abstract java.io.InputStream getViewConfiguration(java.lang.String location)
protected void configureLogging()
configureCommonLogging()
.
public java.lang.String getDomainConfigurationName()
DEFAULT_DOMAIN_FILE
.
protected void setDomainConfigurationName(java.lang.String domainConfigurationName)
domainConfigurationName
- the name of the resource that contains this
Configuration's domain(s).public java.lang.String getProjectVersion()
public void setProjectVersion(java.lang.String projectVersion)
public DataSourceFactory getDataSourceFactory()
public void setDataSourceFactory(DataSourceFactory overrideFactory)
public void addDomain(DataDomain domain)
public DataDomain getDomain(java.lang.String name)
name
or null
if no
such domain is found.
public DataDomain getDomain()
null
is returned. If more than one domain exists in this
configuration, a CayenneRuntimeException is thrown, indicating that the domain name
must be explicitly specified. In such cases getDomain(String name)
must be
used instead.
public void removeDomain(java.lang.String name)
name from
this Configuration object. Note that any domain database
connections remain open, and it is a responsibility of a
caller to clean it up.
public java.util.Collection getDomains()
DataDomain
objects.
public boolean isIgnoringLoadFailures()
protected void setIgnoringLoadFailures(boolean ignoringLoadFailures)
ignoringLoadFailures
- true
or false
public ConfigStatus getLoadStatus()
protected void setLoadStatus(ConfigStatus status)
public ConfigLoaderDelegate getLoaderDelegate()
public void setLoaderDelegate(ConfigLoaderDelegate loaderDelegate)
public ConfigSaverDelegate getSaverDelegate()
public void setSaverDelegate(ConfigSaverDelegate saverDelegate)
public void setDataViewLocations(java.util.Map dataViewLocations)
dataViewLocations
- Map of DataView locations.public java.util.Map getDataViewLocations()
public boolean loadDataView(DataView dataView) throws java.io.IOException
java.io.IOException
public boolean loadDataView(DataView dataView, org.apache.commons.collections.Predicate dataViewNameFilter) throws java.io.IOException
java.io.IOException
public void shutdown()
public void installConfigurationShutdownHook()
public void uninstallConfigurationShutdownHook()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |