org.apache.cayenne.conf
Class FileConfiguration

java.lang.Object
  extended by org.apache.cayenne.conf.Configuration
      extended by org.apache.cayenne.conf.DefaultConfiguration
          extended by org.apache.cayenne.conf.FileConfiguration
Direct Known Subclasses:
ProjectConfiguration

public class FileConfiguration
extends DefaultConfiguration

FileConfiguration loads a Cayenne configuraton file from a given location in the file system.

Author:
Holger Hoffstaette

Field Summary
protected  java.io.File projectFile
          The domain file used for this configuration
 
Fields inherited from class org.apache.cayenne.conf.Configuration
ACCEPT_ALL_DATAVIEWS, configurationShutdownHook, dataDomains, dataViewLocations, DEFAULT_CONFIGURATION_CLASS, DEFAULT_DOMAIN_FILE, DEFAULT_LOGGING_PROPS_FILE, domainConfigurationName, eventManager, ignoringLoadFailures, loaderDelegate, loadStatus, overrideFactory, projectVersion, saverDelegate, sharedConfiguration
 
Constructor Summary
FileConfiguration()
          Default constructor.
FileConfiguration(java.io.File domainConfigurationFile)
          Creates a configuration that uses the provided file as the main project file, ignoring any other lookup strategies.
FileConfiguration(java.lang.String domainConfigurationName)
          Creates a configuration that uses the provided file name as the main project file, ignoring any other lookup strategies.
 
Method Summary
 void addFilesystemPath(java.io.File path)
          Adds the given directory as a path for filesystem lookups.
 void addFilesystemPath(java.lang.String path)
          Adds the given String as a custom path for filesystem lookups.
 boolean canInitialize()
          Only returns true when getProjectFile() does not return null.
 java.io.File getProjectDirectory()
          Returns the directory of the current project file as returned by getProjectFile().
 java.io.File getProjectFile()
          Returns the main domain file used for this configuration.
protected  void setProjectFile(java.io.File projectFile)
          Sets the main domain file used for this configuration.
 
Methods inherited from class org.apache.cayenne.conf.DefaultConfiguration
addClassPath, addResourcePath, didInitialize, getDomainConfiguration, getMapConfiguration, getResourceLocator, getViewConfiguration, initialize, setResourceLocator, toString
 
Methods inherited from class org.apache.cayenne.conf.Configuration
addDomain, bootstrapSharedConfiguration, configureCommonLogging, configureCommonLogging, configureLogging, getDataSourceFactory, getDataViewLocations, getDomain, getDomain, getDomainConfigurationName, getDomains, getEventManager, getLoaderDelegate, getLoadStatus, getLoggingLevel, getProjectVersion, getResourceLoader, getSaverDelegate, getSharedConfiguration, initializeSharedConfiguration, initializeSharedConfiguration, initializeSharedConfiguration, installConfigurationShutdownHook, isIgnoringLoadFailures, isLoggingConfigured, loadDataView, loadDataView, removeDomain, setDataSourceFactory, setDataViewLocations, setDomainConfigurationName, setEventManager, setIgnoringLoadFailures, setLoaderDelegate, setLoadStatus, setLoggingConfigured, setLoggingLevel, setProjectVersion, setSaverDelegate, shutdown, uninstallConfigurationShutdownHook
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

projectFile

protected java.io.File projectFile
The domain file used for this configuration

Constructor Detail

FileConfiguration

public FileConfiguration()
Default constructor. Simply calls FileConfiguration(String) with Configuration.DEFAULT_DOMAIN_FILE as argument.

See Also:
DefaultConfiguration.DefaultConfiguration()

FileConfiguration

public FileConfiguration(java.lang.String domainConfigurationName)
Creates a configuration that uses the provided file name as the main project file, ignoring any other lookup strategies. The file name is not checked for existence and must not contain relative or absolute paths, i.e. only the file name.

Throws:
ConfigurationException - when projectFile is null.
See Also:
DefaultConfiguration.DefaultConfiguration(String)

FileConfiguration

public FileConfiguration(java.io.File domainConfigurationFile)
Creates a configuration that uses the provided file as the main project file, ignoring any other lookup strategies.

Throws:
ConfigurationException - when projectFile is null, a directory or not readable.
Method Detail

addFilesystemPath

public void addFilesystemPath(java.lang.String path)
Adds the given String as a custom path for filesystem lookups. The path can be relative or absolute and is not checked for existence. This allows for easy customization of resource search paths after Constructor invocation:
 conf = new FileConfiguration("myconfig-cayenne.xml");
 conf.addFilesystemPath(new File("a/relative/path"));
 conf.addFilesystemPath(new File("/an/absolute/search/path"));
 Configuration.initializeSharedConfiguration(conf);
 
Alternatively use addFilesystemPath(File) for adding a path that is checked for existence.

Throws:
java.lang.IllegalArgumentException - if path is null.

addFilesystemPath

public void addFilesystemPath(java.io.File path)
Adds the given directory as a path for filesystem lookups. The directory is checked for existence.

Throws:
java.lang.IllegalArgumentException - if path is null, not a directory or not readable.

canInitialize

public boolean canInitialize()
Only returns true when getProjectFile() does not return null.

Overrides:
canInitialize in class DefaultConfiguration

getProjectFile

public java.io.File getProjectFile()
Returns the main domain file used for this configuration.


setProjectFile

protected void setProjectFile(java.io.File projectFile)
Sets the main domain file used for this configuration.

Throws:
ConfigurationException - if projectFile is null, a directory or not readable.

getProjectDirectory

public java.io.File getProjectDirectory()
Returns the directory of the current project file as returned by getProjectFile().



Copyright © 2001-2006 Apache.org All Rights Reserved.