|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.compass.core.config.CompassConfiguration
public class CompassConfiguration
Used to configure Compass instances.
Compass.
There are several options to configure a Compass instance,
programmatically using the CompassConfiguration class, using
the xml configuration file (compass.cfg.xml), or a combination of both.
Usually the application will create a single
CompassConfiguration, use it to configure and than build a
Compass instance, and than instantiate
CompassSessions in threads servicing client requests.
The CompassConfiguration is meant only as an
initialization-time object. Compass is immutable and do not
affect the CompassConfiguration that created it.
Compass| Field Summary | |
|---|---|
protected ConfigurationBuilder |
configurationBuilder
|
protected static org.apache.commons.logging.Log |
log
|
protected CompassMappingBinding |
mappingBinding
|
| Constructor Summary | |
|---|---|
CompassConfiguration()
|
|
| Method Summary | |
|---|---|
CompassConfiguration |
addClass(Class searchableClass)
Read a mapping from an application resource, using a convention. |
CompassConfiguration |
addDirectory(File dir)
Read all mapping and meta-data documents from a directory tree. |
CompassConfiguration |
addFile(File file)
Read mappings from a particular file. |
CompassConfiguration |
addFile(String filePath)
Read mappings from a particular file. |
CompassConfiguration |
addInputStream(InputStream inputStream,
String resourceName)
Read mappings from an InputStream. |
CompassConfiguration |
addJar(File jar)
Read all mappings and meta-data from a jar file. |
protected void |
addMappingBindings(CompassMappingBinding mappingBinding)
|
CompassConfiguration |
addMappingResover(InputStreamMappingResolver mappingResolver)
Uses a class that implements the InputStreamMappingResolver for auto
generation of mapping definitions. |
CompassConfiguration |
addPackage(String packageName)
Read annotated package definitions. |
CompassConfiguration |
addResource(String path)
Read mappings from an application resource trying different classloaders. |
CompassConfiguration |
addResource(String path,
ClassLoader classLoader)
Read mappings from an application resource |
CompassConfiguration |
addResourceMapping(ResourceMapping resourceMapping)
Advance: Add mappings based on ResourceMapping
implementation which allows for adding pre built mapping constructs. |
CompassConfiguration |
addURL(URL url)
Read mappings from a URL. |
Compass |
buildCompass()
Build compass with the configurations set. |
CompassConfiguration |
configure()
Use the mappings and properties specified in an application resource with the path /compass.cfg.xml. |
CompassConfiguration |
configure(File configFile)
Use the mappings and properties specified in the given application file. |
CompassConfiguration |
configure(String resource)
Use the mappings and properties specified in the given application resource. |
CompassConfiguration |
configure(URL url)
Use the mappings and properties specified in the given document. |
CompassSettings |
getSettings()
Returns the current set of settings associated with the configuration. |
CompassConfiguration |
registerConverter(String converterName,
Converter converter)
Registers a Converter under the given name. |
protected void |
registerExtraConverters(ConverterLookup converterLookup)
|
CompassConfiguration |
setConnection(String connection)
Sets the connection for the compass instance. |
CompassConfiguration |
setSetting(String setting,
String value)
Sets a specific setting in the compass configuration settings. |
boolean |
tryAddClass(Class searchableClass)
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected static final org.apache.commons.logging.Log log
protected CompassMappingBinding mappingBinding
protected ConfigurationBuilder configurationBuilder
| Constructor Detail |
|---|
public CompassConfiguration()
| Method Detail |
|---|
protected void addMappingBindings(CompassMappingBinding mappingBinding)
public CompassSettings getSettings()
public CompassConfiguration setSetting(String setting,
String value)
setting - The setting namevalue - The setting value
CompassConfiguration for method chainingpublic CompassConfiguration setConnection(String connection)
connection - The connection for compass to use
CompassConfiguration for method chaining
public CompassConfiguration registerConverter(String converterName,
Converter converter)
Converter under the given name. The name can then be used in the mapping
definitions as a logical name to the converter.
converterName - the converter name the converter will be registered underconverter - The converter to use
public Compass buildCompass()
throws CompassException
Compass instance and
starts it.
Note that the CompassConfiguration class can be used to
create more Compass objects after the method has been called.
CompassExceptionprotected void registerExtraConverters(ConverterLookup converterLookup)
public CompassConfiguration configure()
throws ConfigurationException
/compass.cfg.xml.
CompassConfiguration for method chaining
ConfigurationException
public CompassConfiguration configure(String resource)
throws ConfigurationException
resource - The compass configuration resource path
CompassConfiguration for method chaining
ConfigurationException
public CompassConfiguration configure(URL url)
throws ConfigurationException
url - URL from which you wish to load the configuration
ConfigurationException
public CompassConfiguration configure(File configFile)
throws ConfigurationException
configFile - File from which you wish to load the
configuration
ConfigurationExceptionpublic CompassConfiguration addResourceMapping(ResourceMapping resourceMapping)
ResourceMapping
implementation which allows for adding pre built mapping constructs.
public CompassConfiguration addMappingResover(InputStreamMappingResolver mappingResolver)
throws ConfigurationException
InputStreamMappingResolver for auto
generation of mapping definitions.
mappingResolver -
ConfigurationException
public CompassConfiguration addResource(String path,
ClassLoader classLoader)
throws ConfigurationException
path - a resourceclassLoader - a ClassLoader to use
ConfigurationException
public CompassConfiguration addResource(String path)
throws ConfigurationException
path - The path of the resource
ConfigurationException
public CompassConfiguration addFile(String filePath)
throws ConfigurationException
filePath - a path to a file
ConfigurationException
public CompassConfiguration addFile(File file)
throws ConfigurationException
file - a path to a file
ConfigurationException
public CompassConfiguration addPackage(String packageName)
throws ConfigurationException
packageName - The package name to load
ConfigurationException
public CompassConfiguration addClass(Class searchableClass)
throws ConfigurationException
foo.bar.Foo is mapped by the file
foo/bar/Foo.cpm.xml (in the case of Xml binding).
searchableClass - the mapped class
ConfigurationException
public boolean tryAddClass(Class searchableClass)
throws ConfigurationException
ConfigurationException
public CompassConfiguration addDirectory(File dir)
throws ConfigurationException
*.cpm.xml or *.cmd.xml
is a mapping document.
dir - a directory
ConfigurationException
public CompassConfiguration addJar(File jar)
throws ConfigurationException
*.cpm.xml or *.cmd.xml is a mapping
document.
jar - a jar file
ConfigurationException
public CompassConfiguration addURL(URL url)
throws ConfigurationException
URL.
url - the URL
ConfigurationException
public CompassConfiguration addInputStream(InputStream inputStream,
String resourceName)
throws ConfigurationException
InputStream.
inputStream - an InputStream containing
ConfigurationException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||