This section contains information on the following subjects:
Oracle Complex Event Processing, or Oracle CEP for short, provides a number of application assembly tags that you use in the EPN assembly file of your application to register event types, declare the components of the event processing network and specify how they are linked together. The EPN assembly file is an extension of the standard Spring context file.
The following graphic describes the hierarchy of the Oracle CEP application assembly tags.
The following sample EPN assembly file from the HelloWorld application shows how to use many of the Oracle CEP tags:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:osgi="http://www.springframework.org/schema/osgi"
xmlns:wlevs="http://www.bea.com/ns/wlevs/spring"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/osgi
http://www.springframework.org/schema/osgi/spring-osgi.xsd
http://www.bea.com/ns/wlevs/spring
http://www.bea.com/ns/wlevs/spring/spring-wlevs.xsd">
<wlevs:event-type-repository>
<wlevs:event-type type-name="HelloWorldEvent">
<wlevs:class>com.bea.wlevs.event.example.helloworld.HelloWorldEvent</wlevs:class>
</wlevs:event-type>
</wlevs:event-type-repository>
<wlevs:adapter id="helloworldAdapter"
class="com.bea.wlevs.adapter.example.helloworld.HelloWorldAdapter" >
<wlevs:instance-property name="message"
value="HelloWorld - the currenttime is:"/>
</wlevs:adapter>
<wlevs:processor id="helloworldProcessor" />
<wlevs:stream id="helloworldInstream" >
<wlevs:listener ref="helloworldProcessor"/>
<wlevs:source ref="helloworldAdapter"/>
</wlevs:stream>
<wlevs:stream id="helloworldOutstream" advertise="true">
<wlevs:listener>
<bean class="com.bea.wlevs.example.helloworld.HelloWorldBean"/>
</wlevs:listener>
<wlevs:source ref="helloworldProcessor"/>
</wlevs:stream>
</beans>
Use this tag to declare an adapter component to the Spring application context.
The wlevs:adapter
application assembly tag supports the following child tags:
The following table lists the attributes of the wlevs:adapter
application assembly tag.
The following example shows how to use the wlevs:adapter
tag in the EPN assembly file:
<wlevs:adapter id="helloworldAdapter" provider="hellomsgs">
<wlevs:instance-property name="message"
value="HelloWorld - the current time is:"/>
</wlevs:adapter>
In the example, the adapter’s unique identifier is helloworldAdapter
. The provider is an OSGi service, also registered in the EPN assembly file, whose reference is hellomsgs
. The adapter has a static property called message
, which implies that the adapter Java file has a setMessage()
method.
Use this tag to declare a cache to the Spring application context.
The wlevs:cache
application assembly tag supports the following child tags.
wlevs:caching-system
—Specifies the caching system to which this cache belongs. Note: | This child tag is different from the wlevs:caching-system tag used to declare a caching system. The child tag of the wlevs:cache tag takes a single attribute, ref , that references the id attribute of a declared caching system. |
The following table lists the attributes of the wlevs:cache
application assembly tag.
The following example shows how to use the wlevs:cache
tag in the EPN assembly file:
<wlevs:cache id="cache-id" name="alternative-cache-name">
<wlevs:caching-system ref="caching-system-id"/>
<wlevs:cache-listener ref="tradeListener" />
</wlevs:cache>
In the example, the cache’s unique identifier is cache-id
and its alternate name is alternative-cache-name
. The caching system to which the cache belongs has an id
of caching-system-id
. The cache has a listener to which the cache sends events; the component that listens to it has an id
of tradeListener
.
Use this tag to specify a cache as a source of events to the listening component. The listening component must implement the com.bea.cache.jcache.CacheListener
interface.
This tag is always a child of wlevs:cache.
The following table lists the attributes of the wlevs:cache-listener
application assembly tag.
The following example shows how to use the wlevs:cache-listener
tag in the EPN assembly file:
<wlevs:caching-system id="caching-system-id"/>
...
<wlevs:cache id="cache-id" name="alternative-cache-name">
<wlevs:caching-system ref="caching-system-id"/>
<wlevs:cache-listener ref="cache-listener-id" />
</wlevs:cache>
...
<bean id="cache-listener-id" class="wlevs.example.MyCacheListener"/>
In the example, the cache-listener-id
Spring bean listens to events coming from the cache; the class that implements this component, wlevs.example.MyCacheListener
, must implement the com.bea.jcache.CacheListener
interface. You must program the wlevs.example.MyCacheListener
class yourself.
Specifies the Spring bean that implements an object that loads data into a cache.
This tag is always a child of wlevs:cache.
The following table lists the attributes of the wlevs:cache-loader
application assembly tag.
The Spring bean must implement the com.bea.cache.jcache.CacheLoader interface.
|
The following example shows how to use the wlevs:cache-loader
tag in the EPN assembly file:
<wlevs:cache id="cache-id" name="alternative-cache-name">
<wlevs:caching-system ref="caching-system-id"/>
<wlevs:cache-loader ref="cache-loader-id" />
</wlevs:cache>
...
<bean id="cache-loader-id" class="wlevs.example.MyCacheLoader"/>
In the example, the cache-loader-id
Spring bean, implemented with the wlevs.example.MyCacheLoader
class that in turn implements the com.bea.cache.jcache.CacheLoader
interface, is a bean that loads data into a cache. The cache specifies this loader by pointing to it with the ref
attribute of the <wlevs:cache-loader>
child element.
Specifies a cache that supplies data to this processor component. The processor component in turn is associated with an EPL query that directly references the cache.
Use the value-type
attribute of the wlevs:cache tag to declare the event type of the data supplied by the cache.
This tag is a child of only wlevs:processor tag.
The following table lists the attributes of the wlevs:cache-source
application assembly tag.
The following example shows how to use the wlevs:cache-source
tag in the EPN assembly file:
<wlevs:caching-system id="caching-system-id"/>
...
<wlevs:cache id="cache-id"
name="alternative-cache-name"value-type="Company">
<wlevs:caching-system ref="caching-system-id"/>
</wlevs:cache>
<wlevs:stream id="stream-id"/>
<wlevs:processor id="processor-id">
<wlevs:cache-source ref="cache-id">
<wlevs:source ref="stream-id">
</wlevs:processor>
In the example, the processor will have data pushed to it from the stream-id
stream as usual; however, the EPL queries that execute in the processor can also pull data from the cache-id
cache. When the query processor matches an event type in the FROM clause to an event type supplied by a cache, such as Company
, the processor pulls instances of that event type from the cache.
Specifies the Spring bean that implements a custom store that is responsible for writing data from the cache to a backing store, such as a table in a database.
This tag is always a child of wlevs:cache.
The following table lists the attributes of the wlevs:cache-store
application assembly tag.
The Spring bean must implement the com.bea.cache.jcache.CacheStore interface.
|
The following example shows how to use the wlevs:cache-store
tag in the EPN assembly file:
<wlevs:cache id="cache-id" name="alternative-cache-name">
<wlevs:caching-system ref="caching-system-id"/>
<wlevs:cache-store ref="cache-store-id" />
</wlevs:cache>
...
<bean id="cache-store-id" class="wlevs.example.MyCacheStore"/>
In the example, the cache-store-id
Spring bean, implemented with the wlevs.example.MyCacheStore
class that in turn implements the com.bea.cache.jcache.CacheStore
interface, is a bean for the custom store, such as a database. The cache specifies this store by pointing to it with the ref
attribute of the <wlevs:cache-store>
child element.
Specifies the caching system used by the application.
The wlevs:caching-system
application assembly tag supports the following child tag:
The following table lists the attributes of the wlevs:caching-system
application assembly tag.
The following example shows the simplest use of the wlevs:caching-system
tag in the EPN assembly file:
<wlevs:caching-system id="caching-system-id"/>
The following example shows how to specify a third-party implementation that uses a factory as a provider:
<wlevs:caching-system id ="caching-system-id"
provider="caching-provider"/>
<factory id="factory-id" provider-name="caching-provider">
<class>the.factory.class.name</class>
</factory>
In the example, the.factory.class.name
is a factory for creating some third-party caching system; the provider attribute of wlevs:caching-system in turn references it as the caching system implementation for the application.
Use this tag to declare to the Spring application context that an event bean is part of your event processing network (EPN). Event beans are managed by the Oracle CEP container, analogous to Spring beans that are managed by the Spring framework. In many ways, event beans and Spring beans are similar so it is up to a developer which one to use in their EPN. Use a Spring bean for legacy integration to Spring. Use an event bean if you want to take full advantage of the additional capabilities of Oracle CEP.
For example, you can monitor an event bean using the Oracle CEP monitoring framework, make use of the Configuration framework metadata annotations, and record and playback events that pass through the event bean. An event-bean can also participate in the Oracle CEP bean lifecycle by specifying methods in its EPN assembly file declaration, rather than by implementing Oracle CEP API interfaces.
The wlevs:event-bean
application assembly tag supports the following child tags:
The following table lists the attributes of the wlevs:event-bean
application assembly tag.
The following example shows how to use the wlevs:event-bean
tag in the EPN assembly file:
<wlevs:event-bean id="myBean" class="com.customer.SomeEventBean" >
<wlevs:listener ref="myProcessor" />
</wlevs:event-bean>
In the example, the event bean called myBean
is implemented with the class com.customer.SomeEventBean
. The component called myProcessor
receives events from the myBean
event bean.
Use this tag to group together one or more wlevs:event-type
tags, each of which is used to register an event type used throughout the application.
This tag does not have any attributes.
The wlevs:event-type-repository
application assembly tag supports the following child tag:
The following example shows how to use the wlevs:event-type-repository
tag in the EPN assembly file:
<wlevs:event-type-repository>
<wlevs:event-type type-name="HelloWorldEvent">
<wlevs:class>com.bea.wlevs.event.example.helloworld.HelloWorldEvent</wlevs:class>
</wlevs:event-type></wlevs:event-type-repository>
In the example, the <wlevs:event-type-repository>
tag groups a single <wlevs:event-type>
tag to declare a single event type: HelloWorldEvent
. See wlevs:event-type for additional details.
Specifies the definition of an event type used in the Oracle CEP application. Once you define the event types of the application, you can reference them in the adapter and business class POJO, as well as the EPL rules.
You can define an event type in the following ways:
<wlevs:class>
child tag.
You can specify one of either wlevs:class
or wlevs:metadata
as a child of wlevs:event-type
, but not both.
You can also use the wlevs:property child tag to specify a custom property to apply to the event type.
Oracle recommends that you define your event type by using the wlevs:class
child tag because you can them reuse the specified JavaBean class, and you control exactly what the event type looks like.
The wlevs:event-type
application assembly tag supports the following child tags:
The following table lists the attributes of the wlevs:event-type
application assembly tag.
The following example shows how to use the wlevs:event-type
tag in the EPN assembly file:
<wlevs:event-type-repository><wlevs:event-type type-name="HelloWorldEvent">
</wlevs:event-type-repository>
<wlevs:class>com.bea.wlevs.event.example.helloworld.HelloWorldEvent</wlevs:class>
</wlevs:event-type>
In the example, the name of the event type is HelloWorldEvent
and its definition is determined by the com.bea.wlevs.event.example.helloworld.HelloWorldEvent
JavaBean class.
Use this tag to register a factory class as a service. Use of this tag decreases the dependency of your application on Spring-OSGi interfaces.
The Java source of this factory must implement the com.bea.wlevs.ede.api.Factory
interface.
The factory tag does not allow you to specify service properties. If you need to specify service properties, then you must use the Spring- OSGi <osgi:service>
tag instead.
This tag does not have any child tags.
The following table lists the attributes of the wlevs:factory
application assembly tag.
The following example shows how to use the wlevs:factory
tag in the EPN assembly file:
<wlevs:factory provider-name="myEventSourceFactory"
class="com.customer.MyEventSourceFactory" />
In the example, the factory implemented by the com.customer.MyEventSourceFactory
goes by the provider name of myEventSourceFactory
.
Use this tag to specify a bean that contains user-defined functions for a processor.
This tag always has a standard Spring <bean>
tag as a child that specifies the Spring bean for the user-defined function.
The following table lists the attributes of the wlevs:function
application assembly tag.
The following example shows how to use the wlevs:function
tag in the EPN assembly file:
<wlevs:processor id="testProcessor">
<wlevs:listener ref="providerCache"/>
<wlevs:listener ref="outputCache"/>
<wlevs:cache-source ref="testCache"/> <wlevs:function epl-name="testfunction">
</wlevs:processor>
<bean class="com.bea.wlevs.example.cache.function.TestFunction"/>
</wlevs:function>
Specifies the properties that apply to the create stage instance of the component to which this is a child tag. This allows declarative configuration of user-defined stage properties.
This tag is used only as a child of wlevs:adapter, wlevs:processor, wlevs:stream, or wlevs:caching-system.
The wlevs:instance-property
tag is defined as the Spring propertyType
type; for additional details of this Spring data type, the definition of the allowed child tags, and so on, see the
Spring 2.0 XSD.
You can specify one of the following standard Spring tags as a child tag of the wlevs:instance-property
tag:
The following table lists the attributes of the wlevs:instance-property
application assembly tag.
The following example shows how to use the wlevs:instance-property
tag in the EPN assembly file:
<wlevs:adapter id="helloworldAdapter" provider="hellomsgs"><wlevs:instance-property name="message" value="HelloWorld - the current time is:"/>
</wlevs:adapter>
In the example, the bean that implements the helloworldAdapter
adapter component expects an instance property called message
; the sample wlevs:instance-property
tag above sets the value of this property to HelloWorld - the current time is:
.
Specifies the component that listens to the component to which this tag is a child. A listener can be an instance of any other component. You can also nest the definition of a component within a particular wlevs:listener
component to specify the component that listens to the parent.
WARNING: | Nested definitions are not eligible for dynamic configuration or monitoring. |
This tag is always a child of wlevs:adapter, wlevs:processor, wlevs:stream, wlevs:event-bean or wlevs:cache.
The following table lists the attributes of the wlevs:listener
application assembly tag.
The following example shows how to use the wlevs:listener
tag in the EPN assembly file:
<wlevs:processor id="helloworldProcessor"><wlevs:listener ref="helloworldOutstream"/>
</wlevs:processor>
In the example, the hellworldOutstream
component listens to the helloworldProcessor
component. It is assumed that the EPN assembly file also contains a declaration for a <wlevs:adapter>
, <wlevs:stream>
, or <wlevs:processor>
component whose unique identifier is helloworldOustream
.
Specifies the definition of an event type by listing its fields as a group of Spring entry
tags. When you define an event type this way, Oracle CEP automatically generates the Java class for you.
Use the key
attribute of the entry
tag to specify the name of a field and the value
attribute to specify the Java class that represents the field’s data type.
This tag is used only as a child of wlevs:event-type.
The wlevs:metadata
tag is defined as the Spring mapType
type; for additional details of this Spring data type, see the
Spring 2.0 XSD.
The wlevs:metadata
tag can have one or more standard
Spring entry
child tags.
The following table lists the attributes of the wlevs:metadata
application assembly tag.
The following example shows how to use the wlevs:metadata
tag in the EPN assembly file:
<wlevs:event-type type-name="ForeignExchangeEvent"><wlevs:metadata>
...
<entry key="symbol" value="java.lang.String"/>
<entry key="price" value="java.lang.Double"/>
<entry key="fromRate" value="java.lang.String"/>
<entry key="toRate" value="java.lang.String"/>
</wlevs:metadata>
</wlevs:event-type>
In the example, the wlevs:metadata
tag groups together four standard Spring entry
tags that represent the four fields of the ForeignExchangeEvent
: symbol
, price
, fromRate
, and toRate
. The data types of the fields are java.lang.String
, java.lang.Double
, java.lang.String
, and java.lang.String
, respectively.
Use this tag to declare a processor to the Spring application context.
The wlevs:processor
Spring tag supports the following child tags:
The following table lists the attributes of the wlevs:processor
application assembly tag.
The following example shows how to use the wlevs:processor
tag in the EPN assembly file:
<wlevs:processor id="spreader" />
The example shows how to declare a processor with ID spreader
. This means that in the processor configuration file that contains the EPL rules for this processor, the <name>
element must contain the value spreader
. This way Oracle CEP knows which EPL rules it must file for this particular processor.
Specifies a custom property to apply to the event type.
This tag is used only as a child of wlevs:event-type, wlevs:adapter, wlevs:processor, wlevs:stream, or wlevs:caching-system.
The wlevs:property
tag is defined as the Spring propertyType
type; for additional details of this Spring data type, the definition of the allowed child tags, and so on, see the
Spring 2.0 XSD.
You can specify one of the following standard Spring tags as a child element of the wlevs:property
tag:
The following table lists the attributes of the wlevs:property
application assembly tag.
The following example shows how to use the wlevs:property
tag in the EPN assembly file:
<wlevs:event-type type-name="ForeignExchangeEvent">
<wlevs:metadata>
<entry key="symbol" value="java.lang.String"/>
<entry key="price" value="java.lang.Double"/>
</wlevs:metadata><wlevs:property name="builderFactory">
</wlevs:event-type>
<bean id="builderFactory"
class="com.bea.wlevs.example.fx.ForeignExchangeBuilderFactory"/>
</wlevs:property>
In the example, the wlevs:property
tag defines a custom property of the ForeignExchangeEvent
called builderFactory
. The property uses the standard Spring bean
tag to specify the Spring bean used as a factory to create ForeignExchangeEvents
.
Specifies an event source for this component, or in other words, the component which the events are coming from. Specifying an event source is equivalent to specifying this component as an event listener to another component.
You can also nest the definition of a component within a particular wlevs:source
component to specify the component source.
WARNING: | Nested definitions are not eligible for dynamic configuration or monitoring. |
This tag is a child of wlevs:stream or wlevs:processor.
The following table lists the attributes of the wlevs:source
application assembly tag.
The following example shows how to use the wlevs:source
tag in the EPN assembly file:
<wlevs:stream id="helloworldInstream">
<wlevs:listener ref="helloworldProcessor"/><wlevs:source ref="helloworldAdapter"/>
</wlevs:stream>
In the example, the component with id
helloworldAdapter
is the source of the helloworldInstream
stream component.
Use this tag to declare a stream to the Spring application context.
The wlevs:stream
application assembly tag supports the following child tags:
The following table lists the attributes of the wlevs:stream
application assembly tag.
The following example shows how to use the wlevs:stream
tag in the EPN assembly file:
<wlevs:stream id="fxMarketAmerOut" />
The example shows how to declare a stream service with unique identifier fxMarketAmerOut
.