|
||||||||||
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 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 Map |
dataViewLocations
|
static Class |
DEFAULT_CONFIGURATION_CLASS
|
static String |
DEFAULT_DOMAIN_FILE
|
protected String |
domainConfigurationName
|
protected EventManager |
eventManager
|
protected boolean |
ignoringLoadFailures
|
protected ConfigLoaderDelegate |
loaderDelegate
|
protected ConfigStatus |
loadStatus
|
protected DataSourceFactory |
overrideFactory
|
protected String |
projectVersion
|
protected ConfigSaverDelegate |
saverDelegate
|
protected static Configuration |
sharedConfiguration
|
Constructor Summary | |
---|---|
protected |
Configuration()
Default constructor for new Configuration instances. |
protected |
Configuration(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. |
abstract boolean |
canInitialize()
Indicates whether initialize() can be called. |
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. |
Map |
getDataViewLocations()
|
DataDomain |
getDomain()
Returns default domain of this configuration. |
DataDomain |
getDomain(String name)
Returns registered domain matching name or null if no
such domain is found. |
protected abstract InputStream |
getDomainConfiguration()
Returns a DataDomain as a stream or null if it cannot be found. |
String |
getDomainConfigurationName()
Returns the name of the main domain configuration resource. |
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. |
protected abstract InputStream |
getMapConfiguration(String name)
Returns a DataMap with the given name or null if it cannot be found. |
String |
getProjectVersion()
|
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 InputStream |
getViewConfiguration(String location)
|
abstract void |
initialize()
Initializes the new instance. |
static void |
initializeSharedConfiguration()
Creates and initializes shared Configuration object. |
static void |
initializeSharedConfiguration(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. |
boolean |
loadDataView(DataView dataView)
|
boolean |
loadDataView(DataView dataView,
Predicate dataViewNameFilter)
|
void |
removeDomain(String name)
Unregisters DataDomain matching name |
void |
setDataSourceFactory(DataSourceFactory overrideFactory)
|
void |
setDataViewLocations(Map dataViewLocations)
Initializes configuration with the location of data views. |
protected void |
setDomainConfigurationName(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. |
void |
setProjectVersion(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 String DEFAULT_DOMAIN_FILE
public static final Class DEFAULT_CONFIGURATION_CLASS
protected static Configuration sharedConfiguration
public static final Predicate ACCEPT_ALL_DATAVIEWS
protected CayenneMap dataDomains
protected DataSourceFactory overrideFactory
protected ConfigStatus loadStatus
protected String domainConfigurationName
protected boolean ignoringLoadFailures
protected ConfigLoaderDelegate loaderDelegate
protected ConfigSaverDelegate saverDelegate
protected org.apache.cayenne.conf.Configuration.ConfigurationShutdownHook configurationShutdownHook
protected Map dataViewLocations
protected String projectVersion
protected EventManager eventManager
Constructor Detail |
---|
protected Configuration()
Configuration(String)
.
Configuration(String)
protected Configuration(String domainConfigurationName)
Method Detail |
---|
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 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(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 Exception
Exception
public abstract void didInitialize()
initialize()
.
protected abstract ResourceLocator getResourceLocator()
protected abstract InputStream getDomainConfiguration()
null
if it cannot be found.
protected abstract InputStream getMapConfiguration(String name)
null
if it cannot be found.
protected abstract InputStream getViewConfiguration(String location)
public String getDomainConfigurationName()
DEFAULT_DOMAIN_FILE
.
protected void setDomainConfigurationName(String domainConfigurationName)
domainConfigurationName
- the name of the resource that contains this
Configuration's domain(s).public String getProjectVersion()
public void setProjectVersion(String projectVersion)
public DataSourceFactory getDataSourceFactory()
public void setDataSourceFactory(DataSourceFactory overrideFactory)
public void addDomain(DataDomain domain)
public DataDomain getDomain(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(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 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(Map dataViewLocations)
dataViewLocations
- Map of DataView locations.public Map getDataViewLocations()
public boolean loadDataView(DataView dataView) throws IOException
IOException
public boolean loadDataView(DataView dataView, Predicate dataViewNameFilter) throws IOException
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 |