com.espertech.esper.event
Class EventAdapterServiceImpl

java.lang.Object
  extended by com.espertech.esper.event.EventAdapterServiceImpl
All Implemented Interfaces:
EventAdapterService

public class EventAdapterServiceImpl
extends Object
implements EventAdapterService

Implementation for resolving event name to event type.

The implementation assigned a unique identifier to each event type. For Class-based event types, only one EventType instance and one event type id exists for the same class.

Alias names must be unique, that is an alias name must resolve to a single event type.

Each event type can have multiple aliases defined for it. For example, expressions such as "select * from A" and "select * from B" in which A and B are aliases for the same class X the select clauses each fireStatementStopped for events of type X. In summary, aliases A and B point to the same underlying event type and therefore event type id.


Constructor Summary
EventAdapterServiceImpl()
          Ctor.
 
Method Summary
 EventBean adapterForBean(Object event)
          Create an event bean given an event of object id.
 EventBean adapterForCompositeEvent(EventType eventType, Map<String,EventBean> taggedEvents)
          Creates a wrapper for a composite event type.
 EventBean adapterForDOM(Node node)
          Returns an adapter for the XML DOM document that exposes it's data as event properties for use in statements.
 EventBean adapterForMap(Map event, String eventTypeAlias)
          Wrap the Map-type event returning an EventBean using the event type alias name to identify the EventType that the event should carry.
 void addAutoAliasPackage(String javaPackageName)
          Adds a Java package name of a package that Java event classes reside in.
 EventType addBeanType(String eventTypeAlias, Class clazz)
          Add an alias and class as an event type.
 EventType addBeanType(String eventTypeAlias, String fullyQualClassName, boolean considerAutoAlias)
          Add an event type for the given Java class name.
 EventType addMapType(String eventTypeAlias, Map<String,Class> propertyTypes)
          Add an event type with the given alias and a given set of properties.
 EventType addNestableMapType(String eventTypeAlias, Map<String,Object> propertyTypes)
          Add an event type with the given alias and a given set of properties, wherein properties may itself be Maps, nested and strongly-typed.
 EventType addWrapperType(String eventTypeAlias, EventType underlyingEventType, Map<String,Object> propertyTypes)
          Add an event type with the given alias and the given underlying event type, as well as the additional given properties.
 EventType addXMLDOMType(String eventTypeAlias, ConfigurationEventTypeXMLDOM configurationEventTypeXMLDOM)
          Add a configured XML DOM event type.
 EventType createAddToEventType(EventType originalType, String[] fieldNames, Class[] fieldTypes)
          Create an event type based on the original type passed in adding one or more properties.
 EventType createAnonymousCompositeType(Map<String,EventType> taggedEventTypes)
          Creates an unnamed composite event type with event properties that are name-value pairs with values being other event types.
 EventType createAnonymousMapType(Map<String,Object> propertyTypes)
          Creates a new anonymous EventType instance for an event type that contains a map of name value pairs.
 EventType createAnonymousWrapperType(EventType underlyingEventType, Map<String,Object> propertyTypes)
          Create a new anonymous event type with the given underlying event type, as well as the additional given properties.
 EventBean createMapFromValues(Map<String,Object> properties, EventType eventType)
          Create an event wrapper bean from a set of event properties (name and value objectes) stored in a Map.
 EventBean createWrapper(EventBean event, Map<String,Object> properties, EventType eventType)
          Creata a wrapper around an event and some additional properties
 BeanEventTypeFactory getBeanEventTypeFactory()
          Returns a subset of the functionality of the service specific to creating POJO bean event types.
 EventType getExistsTypeByAlias(String eventTypeAlias)
          Return the event type for a given event name, or null if none is registered for that name.
static boolean isCompatibleWrapper(EventType existingType, EventType underlyingType, Map<String,Object> propertyTypes)
          Returns true if the wrapper type is compatible with an existing wrapper type, for the reason that the underlying event is a subtype of the existing underlying wrapper's type.
 void setClassLegacyConfigs(Map<String,ConfigurationEventTypeLegacy> classToLegacyConfigs)
          Set the legacy Java class type information.
 void setDefaultPropertyResolutionStyle(Configuration.PropertyResolutionStyle defaultPropertyResolutionStyle)
          Sets the default property resolution style.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EventAdapterServiceImpl

public EventAdapterServiceImpl()
Ctor.

Method Detail

getBeanEventTypeFactory

public BeanEventTypeFactory getBeanEventTypeFactory()
Description copied from interface: EventAdapterService
Returns a subset of the functionality of the service specific to creating POJO bean event types.

Specified by:
getBeanEventTypeFactory in interface EventAdapterService
Returns:
bean event type factory

setClassLegacyConfigs

public void setClassLegacyConfigs(Map<String,ConfigurationEventTypeLegacy> classToLegacyConfigs)
Set the legacy Java class type information.

Specified by:
setClassLegacyConfigs in interface EventAdapterService
Parameters:
classToLegacyConfigs - is the legacy class configs

setDefaultPropertyResolutionStyle

public void setDefaultPropertyResolutionStyle(Configuration.PropertyResolutionStyle defaultPropertyResolutionStyle)
Sets the default property resolution style.

Specified by:
setDefaultPropertyResolutionStyle in interface EventAdapterService
Parameters:
defaultPropertyResolutionStyle - is the default style

getExistsTypeByAlias

public EventType getExistsTypeByAlias(String eventTypeAlias)
Description copied from interface: EventAdapterService
Return the event type for a given event name, or null if none is registered for that name.

Specified by:
getExistsTypeByAlias in interface EventAdapterService
Parameters:
eventTypeAlias - is the event type alias name to return type for
Returns:
event type for named event, or null if unknown/unnamed type

addBeanType

public EventType addBeanType(String eventTypeAlias,
                             Class clazz)
                      throws EventAdapterException
Add an alias and class as an event type.

Specified by:
addBeanType in interface EventAdapterService
Parameters:
eventTypeAlias - is the alias
clazz - is the Java class to add
Returns:
event type
Throws:
EventAdapterException - to indicate an error constructing the type

adapterForBean

public EventBean adapterForBean(Object event)
Create an event bean given an event of object id.

Specified by:
adapterForBean in interface EventAdapterService
Parameters:
event - is the event class
Returns:
event

addBeanType

public EventType addBeanType(String eventTypeAlias,
                             String fullyQualClassName,
                             boolean considerAutoAlias)
                      throws EventAdapterException
Add an event type for the given Java class name.

Specified by:
addBeanType in interface EventAdapterService
Parameters:
eventTypeAlias - is the alias
fullyQualClassName - is the Java class name
considerAutoAlias - whether auto-alias by Java packages should be considered
Returns:
event type
Throws:
EventAdapterException - if the Class name cannot resolve or other error occured

addMapType

public EventType addMapType(String eventTypeAlias,
                            Map<String,Class> propertyTypes)
                     throws EventAdapterException
Description copied from interface: EventAdapterService
Add an event type with the given alias and a given set of properties.

If the alias already exists with the same event property information, returns the existing EventType instance.

If the alias already exists with different event property information, throws an exception.

If the alias does not already exists, adds the alias and constructs a new MapEventType.

Specified by:
addMapType in interface EventAdapterService
Parameters:
eventTypeAlias - is the alias name for the event type
propertyTypes - is the names and types of event properties
Returns:
event type is the type added
Throws:
EventAdapterException - if alias already exists and doesn't match property type info

addNestableMapType

public EventType addNestableMapType(String eventTypeAlias,
                                    Map<String,Object> propertyTypes)
                             throws EventAdapterException
Description copied from interface: EventAdapterService
Add an event type with the given alias and a given set of properties, wherein properties may itself be Maps, nested and strongly-typed.

If the alias already exists with the same event property information, returns the existing EventType instance.

If the alias already exists with different event property information, throws an exception.

If the alias does not already exists, adds the alias and constructs a new MapEventType.

Specified by:
addNestableMapType in interface EventAdapterService
Parameters:
eventTypeAlias - is the alias name for the event type
propertyTypes - is the names and types of event properties
Returns:
event type is the type added
Throws:
EventAdapterException - if alias already exists and doesn't match property type info

adapterForMap

public EventBean adapterForMap(Map event,
                               String eventTypeAlias)
                        throws EventAdapterException
Description copied from interface: EventAdapterService
Wrap the Map-type event returning an EventBean using the event type alias name to identify the EventType that the event should carry.

Specified by:
adapterForMap in interface EventAdapterService
Parameters:
event - to be wrapped
eventTypeAlias - alias for the event type of the event
Returns:
event bean wrapping native underlying event
Throws:
EventAdapterException - if the alias has not been declared, or the event cannot be wrapped using that alias's event type

adapterForDOM

public EventBean adapterForDOM(Node node)
Description copied from interface: EventAdapterService
Returns an adapter for the XML DOM document that exposes it's data as event properties for use in statements.

Specified by:
adapterForDOM in interface EventAdapterService
Parameters:
node - is the node to wrap
Returns:
event wrapper for document

addXMLDOMType

public EventType addXMLDOMType(String eventTypeAlias,
                               ConfigurationEventTypeXMLDOM configurationEventTypeXMLDOM)
Add a configured XML DOM event type.

Specified by:
addXMLDOMType in interface EventAdapterService
Parameters:
eventTypeAlias - is the alias name of the event type
configurationEventTypeXMLDOM - configures the event type schema and namespace and XPath property information.
Returns:
event type

createMapFromValues

public final EventBean createMapFromValues(Map<String,Object> properties,
                                           EventType eventType)
Description copied from interface: EventAdapterService
Create an event wrapper bean from a set of event properties (name and value objectes) stored in a Map.

Specified by:
createMapFromValues in interface EventAdapterService
Parameters:
properties - is key-value pairs for the event properties
eventType - is the type metadata for any maps of that type
Returns:
EventBean instance

addWrapperType

public EventType addWrapperType(String eventTypeAlias,
                                EventType underlyingEventType,
                                Map<String,Object> propertyTypes)
                         throws EventAdapterException
Description copied from interface: EventAdapterService
Add an event type with the given alias and the given underlying event type, as well as the additional given properties.

Specified by:
addWrapperType in interface EventAdapterService
Parameters:
eventTypeAlias - is the alias name for the event type
underlyingEventType - is the event type for the event type that this wrapper wraps
propertyTypes - is the names and types of any additional properties
Returns:
eventType is the type added
Throws:
EventAdapterException - if alias already exists and doesn't match this type's info

isCompatibleWrapper

public static boolean isCompatibleWrapper(EventType existingType,
                                          EventType underlyingType,
                                          Map<String,Object> propertyTypes)
Returns true if the wrapper type is compatible with an existing wrapper type, for the reason that the underlying event is a subtype of the existing underlying wrapper's type.

Parameters:
existingType - is the existing wrapper type
underlyingType - is the proposed new wrapper type's underlying type
propertyTypes - is the additional properties
Returns:
true for compatible, or false if not

createAnonymousMapType

public final EventType createAnonymousMapType(Map<String,Object> propertyTypes)
                                       throws EventAdapterException
Description copied from interface: EventAdapterService
Creates a new anonymous EventType instance for an event type that contains a map of name value pairs. The method accepts a Map that contains the property names as keys and Class objects as the values. The Class instances represent the property types.

New instances are createdStatement by this method on every invocation. Clients to this method need to cache the returned EventType instance to reuse EventType's for same-typed events.

Specified by:
createAnonymousMapType in interface EventAdapterService
Parameters:
propertyTypes - is a map of String to Class objects
Returns:
EventType implementation for map field names and value types
Throws:
EventAdapterException

createAnonymousWrapperType

public final EventType createAnonymousWrapperType(EventType underlyingEventType,
                                                  Map<String,Object> propertyTypes)
                                           throws EventAdapterException
Description copied from interface: EventAdapterService
Create a new anonymous event type with the given underlying event type, as well as the additional given properties.

Specified by:
createAnonymousWrapperType in interface EventAdapterService
Parameters:
underlyingEventType - is the event type for the event type that this wrapper wraps
propertyTypes - is the names and types of any additional properties
Returns:
eventType is the type createdStatement
Throws:
EventAdapterException - if alias already exists and doesn't match this type's info

createAddToEventType

public final EventType createAddToEventType(EventType originalType,
                                            String[] fieldNames,
                                            Class[] fieldTypes)
Description copied from interface: EventAdapterService
Create an event type based on the original type passed in adding one or more properties.

Specified by:
createAddToEventType in interface EventAdapterService
Parameters:
originalType - - event type to add property to
fieldNames - - names of properties
fieldTypes - - types of properties
Returns:
new event type

createAnonymousCompositeType

public final EventType createAnonymousCompositeType(Map<String,EventType> taggedEventTypes)
Description copied from interface: EventAdapterService
Creates an unnamed composite event type with event properties that are name-value pairs with values being other event types. Pattern statement generate events of such type.

Specified by:
createAnonymousCompositeType in interface EventAdapterService
Parameters:
taggedEventTypes - is a map of name keys and event type values
Returns:
event type representing a composite event

createWrapper

public final EventBean createWrapper(EventBean event,
                                     Map<String,Object> properties,
                                     EventType eventType)
Description copied from interface: EventAdapterService
Creata a wrapper around an event and some additional properties

Specified by:
createWrapper in interface EventAdapterService
Parameters:
event - is the wrapped event
properties - are the additional properties
eventType - os the type metadata for any wrappers of this type
Returns:
wrapper event bean

adapterForCompositeEvent

public final EventBean adapterForCompositeEvent(EventType eventType,
                                                Map<String,EventBean> taggedEvents)
Description copied from interface: EventAdapterService
Creates a wrapper for a composite event type. The wrapper wraps an event that consists of name-value pairs in which the values are other already-wrapped events.

Specified by:
adapterForCompositeEvent in interface EventAdapterService
Parameters:
eventType - is the composite event type
taggedEvents - is the name-event map
Returns:
wrapper for composite event

addAutoAliasPackage

public void addAutoAliasPackage(String javaPackageName)
Description copied from interface: EventAdapterService
Adds a Java package name of a package that Java event classes reside in.

Specified by:
addAutoAliasPackage in interface EventAdapterService
Parameters:
javaPackageName - is the fully-qualified Java package name of the Java package that event classes reside in

© 2007 EsperTech Inc.
All rights reserved.
Visit us at espertech.com