net.esper.event
Class EventAdapterServiceImpl

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

public class EventAdapterServiceImpl
extends Object
implements EventAdapterService

Implementation for resolving event name to event type.


Constructor Summary
EventAdapterServiceImpl(Map<String,ConfigurationEventTypeLegacy> classToLegacyConfigs)
          Ctor.
 
Method Summary
 EventBean adapterForBean(Object event)
          Wrap the native event returning an EventBean.
 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 addAliasForType(String eventTypeAlias, EventType eventType)
          Add a new alias for an existing type.
 EventType addBeanType(String eventTypeAlias, Class clazz)
          Add an event type with the given alias and Java class.
 EventType addBeanType(String eventTypeAlias, String fullyQualClassName)
          Add an event type with the given alias and Java fully-qualified 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 addWrapperType(String eventTypeAlias, EventType underlyingEventType, Map<String,Class> propertyTypes)
          Add an event type with the given alias and the given underlying event type, as well as the additional given properties.
 void 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,Class> propertyTypes)
          Creates a new anonymous EventType instance for an event type that contains a map of name value pairs.
 EventType createAnonymousMapTypeUnd(Map<String,EventType> 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,Class> propertyTypes)
          Create a new anonymous event type with the given underlying event type, as well as the additional given properties.
 EventBean createMapFromUnderlying(Map<String,EventBean> events, EventType eventType)
          Create an aggregate event wrapper bean from a set of named events stored in a Map.
 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
 EventType getEventType(String eventName)
          Return the event type for a given event name, or null if none is registered for that name.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EventAdapterServiceImpl

public EventAdapterServiceImpl(Map<String,ConfigurationEventTypeLegacy> classToLegacyConfigs)
Ctor.

Parameters:
classToLegacyConfigs - is a map of event type alias to legacy event type config
Method Detail

getEventType

public EventType getEventType(String eventName)
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:
getEventType in interface EventAdapterService
Parameters:
eventName - is the event type alias name to return type for
Returns:
event type for named event, or null if unknown/unnamed type

addAliasForType

public void addAliasForType(String eventTypeAlias,
                            EventType eventType)
                     throws EventAdapterException
Description copied from interface: EventAdapterService
Add a new alias for an existing type.

Specified by:
addAliasForType in interface EventAdapterService
Parameters:
eventTypeAlias - is the event type alias name to add
eventType - is the event type for which to add the aias
Throws:
EventAdapterException

addBeanType

public EventType addBeanType(String eventTypeAlias,
                             Class clazz)
                      throws EventAdapterException
Description copied from interface: EventAdapterService
Add an event type with the given alias and Java class.

If the alias already exists with the same Class, returns the existing EventType instance.

If the alias already exists with different Class name, throws an exception.

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

Specified by:
addBeanType in interface EventAdapterService
Parameters:
eventTypeAlias - is the alias name for the event type
clazz - is the fully Java class
Returns:
event type is the type added
Throws:
EventAdapterException - if alias already exists and doesn't match class names

addBeanType

public EventType addBeanType(String eventTypeAlias,
                             String fullyQualClassName)
                      throws EventAdapterException
Description copied from interface: EventAdapterService
Add an event type with the given alias and Java fully-qualified class name.

If the alias already exists with the same class name, returns the existing EventType instance.

If the alias already exists with different class name, throws an exception.

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

Specified by:
addBeanType in interface EventAdapterService
Parameters:
eventTypeAlias - is the alias name for the event type
fullyQualClassName - is the fully qualified class name
Returns:
event type is the type added
Throws:
EventAdapterException - if alias already exists and doesn't match class names

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

createAnonymousMapType

public EventType createAnonymousMapType(Map<String,Class> 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 created 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 EventType createAnonymousWrapperType(EventType underlyingEventType,
                                            Map<String,Class> 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 created
Throws:
EventAdapterException - if alias already exists and doesn't match this type's info

adapterForBean

public EventBean adapterForBean(Object event)
Description copied from interface: EventAdapterService
Wrap the native event returning an EventBean.

Specified by:
adapterForBean in interface EventAdapterService
Parameters:
event - to be wrapped
Returns:
event bean wrapping native underlying event

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

createMapFromValues

public 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

createMapFromUnderlying

public EventBean createMapFromUnderlying(Map<String,EventBean> events,
                                         EventType eventType)
Description copied from interface: EventAdapterService
Create an aggregate event wrapper bean from a set of named events stored in a Map.

Specified by:
createMapFromUnderlying in interface EventAdapterService
Parameters:
events - is key-value pairs where the key is the event name and the value is the event
eventType - is the type metadata for any maps of that type
Returns:
EventBean instance

createAddToEventType

public 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

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

createAnonymousCompositeType

public 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

adapterForCompositeEvent

public 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

addXMLDOMType

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

Parameters:
eventTypeAlias - is the alias name of the event type
configurationEventTypeXMLDOM - configures the event type schema and namespace and XPath property information.

addWrapperType

public EventType addWrapperType(String eventTypeAlias,
                                EventType underlyingEventType,
                                Map<String,Class> 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

createWrapper

public 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

createAnonymousMapTypeUnd

public EventType createAnonymousMapTypeUnd(Map<String,EventType> propertyTypes)
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 EventType objects as the values. The EventType instances represent the property types whose underlying class is used to set the type, via method createAnonymousMapType.

Specified by:
createAnonymousMapTypeUnd in interface EventAdapterService
Parameters:
propertyTypes - is a map of String to EventType objects
Returns:
EventType implementation for map field names and value types which are the underlying types to the event type passed in