|
||||||||||
| 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 json configuration file, or a combination of all.
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 |
addScan(String basePackage)
Scans the given base package recursivly for any applicable mappings definitions. |
CompassConfiguration |
addScan(String basePackage,
String pattern)
Scans the given base package recursivly for any applicable mappings definitions. |
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. |
ClassLoader |
getClassLoader()
Returns the class loader that will be used to load classes and resources. |
CompassSettings |
getSettings()
Returns the current set of settings associated with the configuration. |
CompassConfiguration |
registerConverter(String converterName,
Class type,
Converter converter)
Regsiters a Converter under the given name. |
CompassConfiguration |
registerConverter(String converterName,
Converter converter)
Registers a Converter under the given name. |
protected void |
registerExtraConverters(ConverterLookup converterLookup)
|
CompassConfiguration |
removeMappingByAlias(String alias)
Removes the mapping registered under the given alias. |
CompassConfiguration |
removeMappingByClass(Class clazz)
Removes all the mappings registered under the given class name. |
CompassConfiguration |
removeMappingByClass(String className)
Removes all the mappings registered under the given class name. |
CompassConfiguration |
setClassLoader(ClassLoader classLoader)
Sets the class loader that will be used to load classes and resources. |
CompassConfiguration |
setConnection(String connection)
Sets the connection for the compass instance. |
CompassConfiguration |
setSetting(String setting,
Object value)
Sets a specific setting in the compass configuration settings. |
boolean |
tryAddClass(Class searchableClass)
Tries to add a class and returns a boolean indicator if it was added or not. |
| 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 CompassConfiguration setClassLoader(ClassLoader classLoader)
public ClassLoader getClassLoader()
public CompassSettings getSettings()
public CompassConfiguration setSetting(String setting,
Object 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 CompassConfiguration registerConverter(String converterName,
Class type,
Converter converter)
Converter under the given name. This converter will apply to all the given
types that match the given type.
converterName - The name of the convertertype - The type to register the converter forconverter - The converter
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 removeMappingByAlias(String alias)
throws MappingException
MappingException
public CompassConfiguration removeMappingByClass(Class clazz)
throws MappingException
MappingException
public CompassConfiguration removeMappingByClass(String className)
throws MappingException
MappingException
public CompassConfiguration addMappingResover(InputStreamMappingResolver mappingResolver)
throws ConfigurationException
InputStreamMappingResolver for auto
generation of mapping definitions.
mappingResolver - The mapping resolver
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 CompassConfiguration addScan(String basePackage)
throws ConfigurationException
ConfigurationException
public CompassConfiguration addScan(String basePackage,
String pattern)
throws ConfigurationException
An optional ant style pattern can be provided to narrow down the search. For example,
the base package can be com.mycompany, and the pattern can be **/model/**
which will match all the everythign that has a package named model within it under the given base package.
ConfigurationException
public boolean tryAddClass(Class searchableClass)
throws ConfigurationException
searchableClass - The searchable class to add
true if the class was added, false otherwise
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 | |||||||||