|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.espertech.esper.client.Configuration
public class Configuration
An instance of Configuration allows the application
to specify properties to be used when
creating a EPServiceProvider. Usually an application will create
a single Configuration, then get one or more instances of
EPServiceProvider
via EPServiceProviderManager
.
The Configuration is meant
only as an initialization-time object. EPServiceProviders are
immutable and do not retain any association back to the
Configuration.
The format of an Esper XML configuration file is defined in
esper-configuration-2.0.xsd.
Nested Class Summary | |
---|---|
static class |
Configuration.PropertyResolutionStyle
Enumeration of different resolution styles for resolving property names. |
Field Summary | |
---|---|
protected Map<String,ConfigurationDBRef> |
databaseReferences
The class and package name imports that will be used to resolve partial class names. |
protected ConfigurationEngineDefaults |
engineDefaults
Saves engine default configs such as threading settings |
protected String |
epServicesContextFactoryClassName
Optional classname to use for constructing services context. |
protected static String |
ESPER_DEFAULT_CONFIG
Default name of the configuration file. |
protected Map<String,String> |
eventClasses
Map of event name and fully-qualified class name. |
protected Set<String> |
eventTypeAutoAliasPackages
Saves the packages to search to resolve event type aliases. |
protected Map<String,ConfigurationEventTypeLegacy> |
eventTypesLegacy
Map of event type alias and Legacy-type event configuration. |
protected Map<String,ConfigurationEventTypeXMLDOM> |
eventTypesXMLDOM
Map of event type alias and XML DOM configuration. |
protected List<String> |
imports
The class and package name imports that will be used to resolve partial class names. |
protected Map<String,Properties> |
mapAliases
The type aliases for events that are backed by java.util.Map, not containing strongly-typed nested maps. |
protected Map<String,ConfigurationMethodRef> |
methodInvocationReferences
Map of class name and configuration for method invocations on that class. |
protected Map<String,Map<String,Object>> |
nestableMapAliases
The type aliases for events that are backed by java.util.Map, possibly containing strongly-typed nested maps. |
protected List<ConfigurationPlugInAggregationFunction> |
plugInAggregationFunctions
List of configured plug-in aggregation functions. |
protected List<ConfigurationPluginLoader> |
pluginLoaders
List of adapter loaders. |
protected List<ConfigurationPlugInPatternObject> |
plugInPatternObjects
List of configured plug-in pattern objects. |
protected List<ConfigurationPlugInView> |
plugInViews
List of configured plug-in views. |
protected Map<String,ConfigurationVariable> |
variables
Map of variables. |
Constructor Summary | |
---|---|
Configuration()
Constructs an empty configuration. |
Method Summary | |
---|---|
void |
addDatabaseReference(String name,
ConfigurationDBRef configurationDBRef)
Add a database reference with a given database name. |
void |
addEventTypeAlias(String eventTypeAlias,
Class eventClass)
Add an alias for an event type represented by Java-bean plain-old Java object events. |
void |
addEventTypeAlias(String eventTypeAlias,
ConfigurationEventTypeXMLDOM xmlDOMEventTypeDesc)
Add an alias for an event type that represents org.w3c.dom.Node events. |
void |
addEventTypeAlias(String eventTypeAlias,
Map<String,Class> typeMap)
Add an alias for an event type that represents java.util.Map events, taking a Map of event property and class name as a parameter. |
void |
addEventTypeAlias(String eventTypeAlias,
Properties typeMap)
Add an alias for an event type that represents java.util.Map events. |
void |
addEventTypeAlias(String eventTypeAlias,
String eventClassName)
Add an alias for an event type represented by Java-bean plain-old Java object events. |
void |
addEventTypeAlias(String eventTypeAlias,
String eventClass,
ConfigurationEventTypeLegacy legacyEventTypeDesc)
Add an alias for an event type that represents legacy Java type (non-JavaBean style) events. |
void |
addEventTypeAliasSimpleName(Class eventClass)
Add an alias for an event type represented by Java-bean plain-old Java object events, and the alias is the simple class name of the class. |
void |
addEventTypeAutoAlias(String packageName)
Adds a Java package name of a package that Java event classes reside in. |
void |
addImport(String autoImport)
Adds a package or class to the list of automatically-imported classes and packages. |
void |
addMethodRef(Class clazz,
ConfigurationMethodRef methodInvocationConfig)
Adds a cache configuration for a class providing methods for use in the from-clause. |
void |
addMethodRef(String className,
ConfigurationMethodRef methodInvocationConfig)
Adds a cache configuration for a class providing methods for use in the from-clause. |
void |
addNestableEventTypeAlias(String eventTypeAlias,
Map<String,Object> typeMap)
Add an alias for an event type that represents java.util.Map events, and for which each property may itself be a Map of further properties, with unlimited nesting levels. |
void |
addPlugInAggregationFunction(String functionName,
String aggregationClassName)
Adds a plug-in aggregation function given a function name and an aggregation class name. |
void |
addPluginLoader(String loaderName,
String className,
Properties configuration)
Add a plugin loader (f.e. |
void |
addPlugInPatternGuard(String namespace,
String name,
String guardFactoryClass)
Add a pattern guard for plug-in. |
void |
addPlugInPatternObserver(String namespace,
String name,
String observerFactoryClass)
Add a pattern event observer for plug-in. |
void |
addPlugInView(String namespace,
String name,
String viewFactoryClass)
Add a view for plug-in. |
void |
addVariable(String variableName,
Class type,
Object initializationValue)
Add a variable. |
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. |
protected static InputStream |
getConfigurationInputStream(String resource)
Get the configuration file as an InputStream. |
Map<String,ConfigurationDBRef> |
getDatabaseReferences()
Returns a map of string database names to database configuration options. |
ConfigurationEngineDefaults |
getEngineDefaults()
Returns engine default settings. |
String |
getEPServicesContextFactoryClassName()
Returns the service context factory class name |
Map<String,String> |
getEventTypeAliases()
Returns the mapping of event type alias to Java class name. |
Set<String> |
getEventTypeAutoAliasPackages()
Returns a set of Java package names that Java event classes reside in. |
Map<String,ConfigurationEventTypeLegacy> |
getEventTypesLegacy()
Returns the mapping of event type alias to legacy java event type information. |
Map<String,Properties> |
getEventTypesMapEvents()
Returns a map keyed by event type alias name, and values being the definition for the event type of the property names and types that make up the event. |
Map<String,Map<String,Object>> |
getEventTypesNestableMapEvents()
Returns a map keyed by event type alias name, and values being the definition for the event type of the property names and types that make up the event, for nestable, strongly-typed Map-based event representations. |
Map<String,ConfigurationEventTypeXMLDOM> |
getEventTypesXMLDOM()
Returns the mapping of event type alias to XML DOM event type information. |
List<String> |
getImports()
Returns the class and package imports. |
Map<String,ConfigurationMethodRef> |
getMethodInvocationReferences()
Returns a map of class name and cache configurations, for use in method invocations in the from-clause of methods provided by the class. |
List<ConfigurationPlugInAggregationFunction> |
getPlugInAggregationFunctions()
Returns a list of configured plug-in aggregation functions. |
List<ConfigurationPluginLoader> |
getPluginLoaders()
Returns a list of configured plugin loaders. |
List<ConfigurationPlugInPatternObject> |
getPlugInPatternObjects()
Returns a list of configured plug-ins for pattern observers and guards. |
List<ConfigurationPlugInView> |
getPlugInViews()
Returns a list of configured plug-in views. |
protected static InputStream |
getResourceAsStream(String resource)
Returns an input stream from an application resource in the classpath. |
Map<String,ConfigurationVariable> |
getVariables()
Returns the variables by name as key and type plus initialization value as value |
protected void |
reset()
Reset to an empty configuration. |
void |
setEPServicesContextFactoryClassName(String epServicesContextFactoryClassName)
Sets the class name of the services context factory class to use. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static final String ESPER_DEFAULT_CONFIG
protected Map<String,String> eventClasses
protected Map<String,ConfigurationEventTypeXMLDOM> eventTypesXMLDOM
protected Map<String,ConfigurationEventTypeLegacy> eventTypesLegacy
protected Map<String,Properties> mapAliases
protected Map<String,Map<String,Object>> nestableMapAliases
Each entrie's value must be either a Class or a Map
protected List<String> imports
protected Map<String,ConfigurationDBRef> databaseReferences
protected String epServicesContextFactoryClassName
protected List<ConfigurationPlugInView> plugInViews
protected List<ConfigurationPlugInPatternObject> plugInPatternObjects
protected List<ConfigurationPlugInAggregationFunction> plugInAggregationFunctions
protected List<ConfigurationPluginLoader> pluginLoaders
protected ConfigurationEngineDefaults engineDefaults
protected Set<String> eventTypeAutoAliasPackages
protected Map<String,ConfigurationVariable> variables
protected Map<String,ConfigurationMethodRef> methodInvocationReferences
Constructor Detail |
---|
public Configuration()
Method Detail |
---|
public void setEPServicesContextFactoryClassName(String epServicesContextFactoryClassName)
epServicesContextFactoryClassName
- service context factory class namepublic String getEPServicesContextFactoryClassName()
ConfigurationInformation
getEPServicesContextFactoryClassName
in interface ConfigurationInformation
public void addPlugInAggregationFunction(String functionName, String aggregationClassName)
ConfigurationOperations
The aggregation class must extends the base class AggregationSupport
.
The same function name cannot be added twice.
addPlugInAggregationFunction
in interface ConfigurationOperations
functionName
- is the new aggregation function nameaggregationClassName
- is the fully-qualified class name of the class implementing the aggregation functionpublic void addEventTypeAlias(String eventTypeAlias, String eventClassName)
addEventTypeAlias
in interface ConfigurationOperations
eventTypeAlias
- is the alias for the event typeeventClassName
- fully-qualified class name of the event typepublic void addEventTypeAlias(String eventTypeAlias, Class eventClass)
addEventTypeAlias
in interface ConfigurationOperations
eventTypeAlias
- is the alias for the event typeeventClass
- is the Java event class for which to create the aliaspublic void addEventTypeAliasSimpleName(Class eventClass)
addEventTypeAliasSimpleName
in interface ConfigurationOperations
eventClass
- is the Java event class for which to create the aliaspublic void addEventTypeAlias(String eventTypeAlias, Properties typeMap)
addEventTypeAlias
in interface ConfigurationOperations
eventTypeAlias
- is the alias for the event typetypeMap
- maps the name of each property in the Map event to the type
(fully qualified classname) of its value in Map event instances.public void addNestableEventTypeAlias(String eventTypeAlias, Map<String,Object> typeMap)
Each entry in the type mapping must contain the String property name
and either a Class or further Map
addNestableEventTypeAlias
in interface ConfigurationOperations
eventTypeAlias
- is the alias for the event typetypeMap
- maps the name of each property in the Map event to the type
(fully qualified classname) of its value in Map event instances.
public void addEventTypeAlias(String eventTypeAlias, Map<String,Class> typeMap)
This method is provided for convenience and is same in function to method taking a Properties object that contain fully qualified class name as values.
addEventTypeAlias
in interface ConfigurationOperations
eventTypeAlias
- is the alias for the event typetypeMap
- maps the name of each property in the Map event to the type of its value in the Map objectpublic void addEventTypeAlias(String eventTypeAlias, ConfigurationEventTypeXMLDOM xmlDOMEventTypeDesc)
addEventTypeAlias
in interface ConfigurationOperations
eventTypeAlias
- is the alias for the event typexmlDOMEventTypeDesc
- descriptor containing property and mapping information for XML-DOM eventspublic void addDatabaseReference(String name, ConfigurationDBRef configurationDBRef)
name
- is the database nameconfigurationDBRef
- descriptor containing database connection and access policy informationpublic void addEventTypeAlias(String eventTypeAlias, String eventClass, ConfigurationEventTypeLegacy legacyEventTypeDesc)
eventTypeAlias
- is the alias for the event typeeventClass
- fully-qualified class name of the event typelegacyEventTypeDesc
- descriptor containing property and mapping information for Legacy Java type eventspublic void addImport(String autoImport)
ConfigurationOperations
To import a single class offering a static method, simply supply the fully-qualified name of the class
and use the syntax classname.methodname(...)
To import a whole package and use the classname.methodname(...)
syntax, specifiy a package
with wildcard, such as com.mycompany.staticlib.*
.
addImport
in interface ConfigurationOperations
autoImport
- is a fully-qualified class name or a package name with wildcardpublic void addMethodRef(String className, ConfigurationMethodRef methodInvocationConfig)
className
- is the class name (simple or fully-qualified) providing methodsmethodInvocationConfig
- is the cache configurationpublic void addMethodRef(Class clazz, ConfigurationMethodRef methodInvocationConfig)
clazz
- is the class providing methodsmethodInvocationConfig
- is the cache configurationpublic Map<String,String> getEventTypeAliases()
ConfigurationInformation
getEventTypeAliases
in interface ConfigurationInformation
public Map<String,Properties> getEventTypesMapEvents()
ConfigurationInformation
getEventTypesMapEvents
in interface ConfigurationInformation
public Map<String,Map<String,Object>> getEventTypesNestableMapEvents()
ConfigurationInformation
getEventTypesNestableMapEvents
in interface ConfigurationInformation
public Map<String,ConfigurationEventTypeXMLDOM> getEventTypesXMLDOM()
ConfigurationInformation
getEventTypesXMLDOM
in interface ConfigurationInformation
public Map<String,ConfigurationEventTypeLegacy> getEventTypesLegacy()
ConfigurationInformation
getEventTypesLegacy
in interface ConfigurationInformation
public List<String> getImports()
ConfigurationInformation
getImports
in interface ConfigurationInformation
public Map<String,ConfigurationDBRef> getDatabaseReferences()
ConfigurationInformation
getDatabaseReferences
in interface ConfigurationInformation
public List<ConfigurationPlugInView> getPlugInViews()
ConfigurationInformation
getPlugInViews
in interface ConfigurationInformation
public List<ConfigurationPluginLoader> getPluginLoaders()
ConfigurationInformation
getPluginLoaders
in interface ConfigurationInformation
public List<ConfigurationPlugInAggregationFunction> getPlugInAggregationFunctions()
ConfigurationInformation
getPlugInAggregationFunctions
in interface ConfigurationInformation
public List<ConfigurationPlugInPatternObject> getPlugInPatternObjects()
ConfigurationInformation
getPlugInPatternObjects
in interface ConfigurationInformation
public Map<String,ConfigurationVariable> getVariables()
ConfigurationInformation
getVariables
in interface ConfigurationInformation
public Map<String,ConfigurationMethodRef> getMethodInvocationReferences()
ConfigurationInformation
getMethodInvocationReferences
in interface ConfigurationInformation
public void addPluginLoader(String loaderName, String className, Properties configuration)
loaderName
- is the name of the loaderclassName
- is the fully-qualified classname of the loader classconfiguration
- is loader cofiguration entriespublic void addPlugInView(String namespace, String name, String viewFactoryClass)
namespace
- is the namespace the view should be available undername
- is the name of the viewviewFactoryClass
- is the view factory class to usepublic void addPlugInPatternObserver(String namespace, String name, String observerFactoryClass)
namespace
- is the namespace the observer should be available undername
- is the name of the observerobserverFactoryClass
- is the observer factory class to usepublic void addPlugInPatternGuard(String namespace, String name, String guardFactoryClass)
namespace
- is the namespace the guard should be available undername
- is the name of the guardguardFactoryClass
- is the guard factory class to usepublic void addEventTypeAutoAlias(String packageName)
ConfigurationOperations
This setting allows an application to place all it's events into one or more Java packages and then declare these packages via this method. The engine attempts to resolve an event type alias to a Java class residing in each declared package.
For example, in the statement "select * from MyEvent" the engine attempts to load class "javaPackageName.MyEvent" and if successful, uses that class as the event type.
addEventTypeAutoAlias
in interface ConfigurationOperations
packageName
- is the fully-qualified Java package name of the Java package that event classes reside inpublic void addVariable(String variableName, Class type, Object initializationValue)
ConfigurationOperations
addVariable
in interface ConfigurationOperations
variableName
- name of the variable to addtype
- the type of the variable must be a primitive or boxed Java-builtin scalar type.initializationValue
- is the first assigned valuepublic Set<String> getEventTypeAutoAliasPackages()
ConfigurationInformation
This setting allows an application to place all it's events into one or more Java packages and then declare these packages via this method. The engine attempts to resolve an event type alias to a Java class residing in each declared package.
For example, in the statement "select * from MyEvent" the engine attempts to load class "javaPackageName.MyEvent" and if successful, uses that class as the event type.
getEventTypeAutoAliasPackages
in interface ConfigurationInformation
public ConfigurationEngineDefaults getEngineDefaults()
ConfigurationInformation
getEngineDefaults
in interface ConfigurationInformation
public Configuration configure() throws EPException
EPException
- thrown to indicate error reading configurationpublic Configuration configure(String resource) throws EPException
resource
- if the file name of the resource
EPException
- 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 name
EPException
- thrown to indicate error reading configurationpublic Configuration configure(URL url) throws EPException
url
- URL from which you wish to load the configuration
EPException
- is thrown when the URL could not be accesspublic Configuration configure(File configFile) throws EPException
configFile
- File from which you wish to load the configuration
EPException
- when the file could not be foundpublic Configuration configure(Document document) throws EPException
document
- an XML document from which you wish to load the configuration
EPException
- 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 for
protected void reset()
|
© 2007 EsperTech Inc. All rights reserved. Visit us at espertech.com |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |