public class Configuration extends Object implements Serializable
Modifier and Type | Field and Description |
---|---|
protected static String |
ESPER_DEFAULT_CONFIG
Default name of the configuration file.
|
Constructor and Description |
---|
Configuration()
Constructs an empty configuration.
|
Modifier and Type | Method and Description |
---|---|
Configuration |
configure()
Use the configuration specified in an application
resource named esper.cfg.xml.
|
Configuration |
configure(Document document)
Use the mappings and properties specified in the given XML document.
|
Configuration |
configure(File configFile)
Use the configuration specified in the given application
file.
|
Configuration |
configure(String resource)
Use the configuration specified in the given application
resource.
|
Configuration |
configure(URL url)
Use the configuration specified by the given URL.
|
ConfigurationCommon |
getCommon()
Returns the common section of the configuration.
|
ConfigurationCompiler |
getCompiler()
Returns the compiler section of the configuration.
|
protected static InputStream |
getConfigurationInputStream(String resource)
Get the configuration file as an InputStream.
|
protected static InputStream |
getResourceAsStream(String resource)
Returns an input stream from an application resource in the classpath.
|
ConfigurationRuntime |
getRuntime()
Returns the runtime section of the configuration.
|
protected void |
reset()
Reset to an empty configuration.
|
void |
setCommon(ConfigurationCommon common)
Sets the common section of the configuration.
|
void |
setCompiler(ConfigurationCompiler compiler)
Sets the compiler section of the configuration.
|
void |
setRuntime(ConfigurationRuntime runtime)
Sets the runtime section of the configuration.
|
protected static final String ESPER_DEFAULT_CONFIG
public Configuration()
public Configuration configure() throws EPException
EPException
- thrown to indicate error reading configurationpublic Configuration configure(String resource) throws EPException
The resource is found via getConfigurationInputStream(resource). That method can be overridden to implement an arbitrary lookup strategy.
See getResourceAsStream for information on how the resource name is resolved.
resource
- if the file name of the resourceEPException
- thrown to indicate error reading configurationprotected static InputStream getConfigurationInputStream(String resource) throws EPException
See getResourceAsStream for information on how the resource name is resolved.
resource
- is the resource nameEPException
- thrown to indicate error reading configurationpublic Configuration configure(URL url) throws EPException
url
- URL from which you wish to load the configurationEPException
- is thrown when the URL could not be accesspublic Configuration configure(File configFile) throws EPException
configFile
- File from which you wish to load the configurationEPException
- when the file could not be foundpublic Configuration configure(Document document) throws EPException
document
- an XML document from which you wish to load the configurationEPException
- if there is problem in accessing the document.protected static InputStream getResourceAsStream(String resource)
The method first removes the '/' character from the resource name if the first character is '/'.
The lookup order is as follows:
If a thread context class loader exists, use Thread.currentThread().getResourceAsStream to obtain an InputStream.
If no input stream was returned, use the Configuration.class.getResourceAsStream. to obtain an InputStream.
If no input stream was returned, use the Configuration.class.getClassLoader().getResourceAsStream. to obtain an InputStream.
If no input stream was returned, throw an Exception.
resource
- to get input stream forpublic ConfigurationCommon getCommon()
The common section is for use by both the compiler and the runtime.
public void setCommon(ConfigurationCommon common)
The common section is for use by both the compiler and the runtime.
common
- common configurationpublic ConfigurationCompiler getCompiler()
The compiler section is for use by the compiler. The runtime ignores this part of the configuration object.
public void setCompiler(ConfigurationCompiler compiler)
The compiler section is for use by the compiler. The runtime ignores this part of the configuration object.
compiler
- compiler configurationpublic ConfigurationRuntime getRuntime()
The runtime section is for use by the runtime. The compiler ignores this part of the configuration object.
public void setRuntime(ConfigurationRuntime runtime)
The runtime section is for use by the runtime. The compiler ignores this part of the configuration object.
runtime
- runtime configurationprotected void reset()
Copyright © 2005–2018. All rights reserved.