This appendix provides a reference to elements of the spring-wlevs-v11_1_1_6.xsd
schema, the schema behind assembly XML files with which you declare the components that make up your Oracle Complex Event Processing (Oracle CEP) event processing networks (EPNs).
Section C.1, "Overview of the Oracle CEP Application Assembly Elements"
Section B.1, "EPN Assembly Schema spring-wlevs-v11_1_1_6.xsd"
Oracle CEP provides a number of application assembly elements 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 Oracle CEP application assembly elements are organized into the following hierarchy:
beans Standard Spring and OSGi elements such as bean, osgi-service, and so on. wlevs:event-type-repository wlevs:event-type wlevs:class wlevs:metadata wlevs:properties wlevs:property wlevs:adapter wlevs:listener wlevs:instance-property wlevs:property wlevs:processor wlevs:listener wlevs:source wlevs:function wlevs:instance-property wlevs:property wlevs:cache-source wlevs:table-source wlevs:channel wlevs:listener wlevs:source wlevs:instance-property wlevs:property wlevs:application-timestamped wlevs:expression wlevs:event-bean wlevs:listener wlevs:instance-property wlevs:property wlevs:factory wlevs:cache wlevs:caching-system wlevs:cache-loader wlevs:cache-store wlevs:cache-listener wlevs:caching-system wlevs:instance-property wlevs:property wlevs:table
The following sample EPN assembly file from the HelloWorld application shows how to use many of the Oracle CEP elements:
<?xwml 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-v11_1_1_6.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:channel id="helloworldInstream" > <wlevs:listener ref="helloworldProcessor"/> <wlevs:source ref="helloworldAdapter"/> </wlevs:channel> <wlevs:channel id="helloworldOutstream" advertise="true"> <wlevs:listener> <bean class="com.bea.wlevs.example.helloworld.HelloWorldBean"/> </wlevs:listener> <wlevs:source ref="helloworldProcessor"/> </wlevs:channel> </beans>
Use this element to declare an adapter component to the Spring application context.
The wlevs:adapter
application assembly element supports the following child elements:
Table C-1 lists the attributes of the wlevs:adapter
application assembly element.
Table C-1 Attributes of the wlevs:adapter Application Assembly Element
Attribute | Description | Data Type | Required? |
---|---|---|---|
|
Unique identifier for this component. This identifier must correspond to the |
|
Yes. |
|
Advertises this service in the OSGi registry. Valid values are |
|
No. |
|
Specifies the components that listen to this component. Set this attribute to the value of the |
|
No. |
|
Specifies the adapter service provider. Typically the value of this attribute is a reference to the OSGi-registered adapter factory service. If you are using the provider="csvgen" If you are using one of the built-in HTTP publish-subscribe adapters, then specify the following hard-coded values:
If you are using a JMS adapter, then specify one of the following hard-coded values:
You must specify either the |
|
No. |
|
Specifies the Java class that implements this adapter. You must specify either the |
|
No |
|
Specifies the method of the adapter implementation that corresponds to the lifecycle Oracle CEP invokes this method when the adapter receives an event. |
|
No |
|
Specifies the method of the adapter implementation that corresponds to the lifecycle Oracle CEP invokes this method after it has set all the supplied instance properties. This method allows the adapter instance to perform initialization only possible when all bean properties have been set and to throw an exception in the event of misconfiguration. |
|
No |
|
Specifies the method of the adapter implementation that corresponds to the lifecycle Oracle CEP invokes this method after the dynamic configuration of the adapter has completed. This method allows the adapter instance to perform initialization only possible when all dynamic bean properties have been set and the EPN has been wired. |
|
No |
|
Specifies the method of the adapter implementation that corresponds to the lifecycle Oracle CEP invokes this method when the application is suspended. |
|
No |
|
Specifies the method of the adapter implementation that corresponds to the lifecycle Oracle CEP invokes this method when the application is stopped. |
|
No |
The following example shows how to use the wlevs:adapter
element 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 element to specify if an wlevs:channel
is application timestamped, that is, if the application is responsible for assigning a timestamp to each event, using any time domain.
Otherwise, wlevs:channel
is system timestamped, that is, the Oracle CEP server is responsible for assigning a timestamp to each event using System.nanoTime
.
The wlevs:application-timestamped
application assembly element supports the following child elements.
wlevs:expression
—Specifies an expression to be used as an application timestamp for event processing.
Table C-2 lists the attributes of the wlevs:application-timestamped
application assembly element.
Table C-2 Attributes of the wlevs:application-timestamped Application Assembly Element
Attribute | Description | Data Type | Required? |
---|---|---|---|
|
Indicates if the application time published is always strictly greater than the last value used. Valid values are For more information, see "Time" in the Oracle Fusion Middleware CQL Language Reference for Oracle Complex Event Processing. |
|
No. |
The following example shows how to use the wlevs:application-timestamped
element in the EPN assembly file to specify an implicitly application timestamped channel:
<wlevs:channel id="fxMarketAmerOut" > <wlevs:application-timestamped> </wlevs:application-timestamped> </wlevs:channel>
In the example, the application handles event timestamps internally.
The following example shows how to use wlevs:application-timestamped
element in the EPN assembly file to specify an explicitly application timestamped channel by specifying the wlevs:expression
element.
<wlevs:channel id="fxMarketAmerOut" > <wlevs:application-timestamped> <wlevs:expression>mytime+10</wlevs:expression> </wlevs:application-timestamped> </wlevs:channel>
In the example, the wlevs:expression
element defines the arithmetic expression used to assign a timestamp to each event.
Use this element to declare a cache to the Spring application context.
The wlevs:cache
application assembly element supports the following child elements.
wlevs:caching-system
—Specifies the caching system to which this cache belongs.
Note:
This child element is different from the wlevs:caching-system
element used to declare a caching system. The child element of the wlevs:cache
element takes a single attribute, ref
, that references the id
attribute of a declared caching system.
wlevs:cache-loader
—Specifies the cache loader for this cache.
wlevs:cache-store
—Specifies a cache store for this cache.
wlevs:cache-listener
—Specifies a listener for this cache, or a component to which the cache sends events.
Table C-3 lists the attributes of the wlevs:cache
application assembly element.
Table C-3 Attributes of the wlevs:cache Application Assembly Element
Attribute | Description | Data Type | Required? |
---|---|---|---|
|
Unique identifier for this component. This identifier must correspond to the |
|
Yes. |
|
Specifies an alternate name for this cache. If not specified, then the name of the cache is the same as its |
|
No. |
|
Specifies a comma-separated list of names of the properties that together form the unique key value for the objects in the cache, or cache key. A cache key may be composed of a single property or multiple properties. When you configure a cache as a listener in an event processing network, Oracle CEP inserts events that reach the cache using the unique key value as a key. If you specify a key class using the |
|
No. |
|
Specifies the name of the Java class used for the cache key when the key is a composite key. If you do not specify the |
|
No. |
|
Specifies the type for the values contained in the cache. Must be a valid type name in the event type repository. This attribute is required only if the cache is referenced in an Oracle CQL or EPL query. This is because the query processor needs to know the type of events in the cache. |
|
No. |
|
Specifies the caching system in which this cache is contained. The value of this attribute corresponds to the |
|
Yes. |
|
Advertises this service in the OSGi registry. Valid values are |
|
No. |
The following example shows how to use the wlevs:cache
element 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 element 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 element is always a child of wlevs:cache
.
Table C-4 lists the attributes of the wlevs:cache-listener
application assembly element.
Table C-4 Attributes of the wlevs:cache-listener Application Assembly Element
Attribute | Description | Data Type | Required? |
---|---|---|---|
|
Specifies the component that listens to this cache. Set this attribute to the value of the |
|
No. |
The following example shows how to use the wlevs:cache-listener
element 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.
spring-wlevs-v11_1_1_6.xsdSpecifies the Spring bean that implements an object that loads data into a cache.
This element is always a child of wlevs:cache
.
Table C-5 lists the attributes of the wlevs:cache-loader
application assembly element.
Table C-5 Attributes of the wlevs:cache-loader Application Assembly Element
Attribute | Description | Data Type | Required? |
---|---|---|---|
|
Specifies the Spring bean that implements the class that loads data into the cache. Set this attribute to the value of the id attribute of the Spring bean. The Spring bean must implement the |
|
Yes. |
The following example shows how to use the wlevs:cache-loader
element 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 Oracle CQL or EPL query that directly references the cache.
Use the value-type
attribute of the wlevs:cache
element to declare the event type of the data supplied by the cache.
This element is a child of only wlevs:processor
element.
Table C-6 lists the attributes of the wlevs:cache-source
application assembly element.
The following example shows how to use the wlevs:cache-source
element 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:channel 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
channel as usual; however, the Oracle CQL or 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 element is always a child of wlevs:cache
.
Table C-7 lists the attributes of the wlevs:cache-store
application assembly element.
Table C-7 Attributes of the wlevs:cache-store Application Assembly Element
Attribute | Description | Data Type | Required? |
---|---|---|---|
|
Specifies the Spring bean that implements the custom store. Set this attribute to the value of the The Spring bean must implement the |
|
Yes. |
The following example shows how to use the wlevs:cache-store
element 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 element supports the following child element:
Table C-8 lists the attributes of the wlevs:caching-system
application assembly element.
Table C-8 Attributes of the wlevs:caching-system Application Assembly Element
Attribute | Description | Data Type | Required? |
---|---|---|---|
|
Specifies the unique identifier for this caching system. This identifier must correspond to the |
|
Yes. |
|
Advertises this service in the OSGi registry. Valid values are |
|
No. |
|
Specifies the provider of the caching system if you are using a third-party implementation, such as Oracle Coherence: <wlevs:caching-system id="myCachingSystem" provider=coherence" /> Typically this attribute corresponds to the If you do not specify the |
|
No. |
|
Specifies the Java class that implements this caching system; use this attribute to specify a third-party implementation rather than the Oracle CEP native caching implementation. If you specify this attribute, it is assumed that the third-party implementation code resides inside the Oracle CEP application bundle itself. The class file to which this attribute points must implement the If you do not specify the |
|
No |
The following example shows the simplest use of the wlevs:caching-system
element 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 element to declare a channel to the Spring application context.
By default, channels assume that events are system timestamped. To configure application timestamped events, see child element wlevs:application-timestamped
.
The wlevs:channel
application assembly element supports the following child elements:
Table C-9 lists the attributes of the wlevs:channel
application assembly element.
Table C-9 Attributes of the wlevs:channel Application Assembly Element
Attribute | Description | Data Type | Required? |
---|---|---|---|
|
Advertises this service in the OSGi registry. Valid values are |
|
No. |
|
Specifies whether batching of events should be enabled for the event channel. Valid values are For more information, see Section 9.1.6, "Batch Processing Channels". |
|
No. |
|
Specifies the type of events that are allowed to pass through the event channel. |
|
Yes. |
|
Unique identifier for this component. This identifier must correspond to the |
|
Yes. |
|
Specifies the kind of events that are allowed to pass through the event channel. Two kind of events are supported: streams and relations. Streams are append-only. Relations support insert, delete, and updates. The default value for this attribute is |
|
No. |
|
Specifies the components that listen to this component. Separate multiple components using commas. Set this attribute to the value of the |
|
No. |
|
Specifies the maximum size of the FIFO buffer for this channel as When When If The default value for this attribute is |
|
No. |
|
Specifies the maximum number of threads that will be used to process events for this channel. When When You can change If the The default value for this attribute is 1. |
|
No. |
|
Specifies the primary key of a relation, as a list of event property names, separated by " For more information, see Section 9.1.2.2, "Channels as Relations". |
|
No. |
|
Specifies the streaming provider. Valid values are:
Default value is |
|
No. |
|
Specifies the component from which the channel sources events. Set this attribute to the value of the |
|
No. |
Use this element to specify the fully-qualified name of the JavaBean class to use as an event type implementation. This element must be a child of the wlevs:event-type
element.
Use this element 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 element supports the following child elements:
Table C-10 lists the attributes of the wlevs:event-bean
application assembly element.
Table C-10 Attributes of the wlevs:event-bean Application Assembly Element
Attribute | Description | Data Type | Required? |
---|---|---|---|
|
Unique identifier for this component. This identifier must correspond to the |
|
Yes. |
|
Advertises this service in the OSGi registry. Valid values are |
|
No. |
|
Specifies the components that listen to this component. Set this attribute to the value of the |
|
No. |
|
Specifies the Java class that implements this event bean. The bean is not required to implement any Oracle CEP interfaces. You must specify either the |
||
|
Specifies the service provider. In this case, an EDE factory registered with this specific provider name must exist in the application. You must specify either the |
|
No. |
|
Specifies the method of the event bean implementation that corresponds to the lifecycle Oracle CEP invokes this method when the event bean receives an event. By using this lifecycle attribute, the event bean implementation does not have to explicitly implement an Oracle CEP interface. |
|
No |
|
Specifies the method of the event bean implementation that corresponds to the lifecycle Oracle CEP invokes this method after it has set all the supplied instance properties. This method allows the bean instance to perform initialization only possible when all bean properties have been set and to throw an exception in the event of misconfiguration. By using this lifecycle attribute, the event bean implementation does not have to explicitly implement an Oracle CEP interface. |
|
No |
|
Specifies the method of the event bean implementation that corresponds to the lifecycle Oracle CEP invokes this method after the dynamic configuration of the bean has completed. This method allows the bean instance to perform initialization only possible when all dynamic bean properties have been set and the EPN has been wired. By using this lifecycle attribute, the event bean implementation does not have to explicitly implement an Oracle CEP interface. |
|
No |
|
Specifies the method of the event bean implementation that corresponds to the lifecycle Oracle CEP invokes this method when the application is suspended. By using this lifecycle attribute, the event bean implementation does not have to explicitly implement an Oracle CEP interface. |
|
No |
|
Specifies the method of the event bean implementation that corresponds to the lifecycle Oracle CEP invokes this method when the application is stopped. By using this lifecycle attribute, the event bean implementation does not have to explicitly implement an Oracle CEP interface. |
|
No |
The following example shows how to use the wlevs:event-bean
element 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.
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 Oracle CQL rules.
You can define an event type in the following ways:
Create a JavaBean class that represents your event type and specify its fully qualified classname using the wlevs:class
child element.
Specify event type properties declaratively by using a wlevs:properties
child element.
You can specify one of either wlevs:class
or wlevs:properties
as a child of wlevs:event-type
, but not both.
The best practice is to define your event type by using the wlevs:class
child element because you can then reuse the specified JavaBean class, and you control exactly what the event type looks like.
The wlevs:event-type
application assembly element supports the following child elements:
wlevs:metadata
(deprecated)
Table C-11 lists the attributes of the wlevs:event-type
application assembly element.
Table C-11 Attributes of the wlevs:event-type Application Assembly Element
Attribute | Description | Data Type | Required? |
---|---|---|---|
|
Specifies the unique identifier for this event type. If you do not specify this attribute, Oracle CEP automatically generates an identifier for you. |
|
No. |
|
Specifies the name of this event type. This is the name you use whenever you reference the event type in the adapter, business POJO, or Oracle CQL or EPL rules. |
|
Yes. |
The following example shows how to use the wlevs:event-type
element in the EPN assembly file:
<wlevs:event-type-repository> <wlevs:event-type type-name="SimpleEvent"> <wlevs:properties> <wlevs:property name="msg" type="char" /> <wlevs:property name="count" type="long" /> <wlevs:property name="time_stamp" type="timestamp" /> </wlevs:properties> </wlevs:event-type> ... </wlevs:event-type-repository>
In the example, the name of the event type is SimpleEvent
and its definition is determined by the wlevs:property
elements. The values for the type attribute must conform to the com.bea.wlevs.ede.api.Type
class.
For more information, see Section 2.1.3, "Event Type Data Types".
Use this element to group together one or more wlevs:event-type
elements, each of which is used to register an event type used throughout the application.
This element does not have any attributes.
The wlevs:event-type-repository
application assembly element supports the following child element:
The following example shows how to use the wlevs:event-type-repository
element 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
element groups a single wlevs:event-type
element to declare a single event type: HelloWorldEvent
. See Section C.13, "wlevs:event-type"
for additional details.
Use this element to specify an arithmetic expression in wlevs:application-timestamped
to be used as an application timestamp for event processing.
For more information, see "arith_expr" in the Oracle Fusion Middleware CQL Language Reference for Oracle Complex Event Processing.
The following example shows how to use wlevs:expression
element in the EPN assembly file to specify an explicitly application timestamped channel.
<wlevs:channel id="fxMarketAmerOut" >
<wlevs:application-timestamped>
<wlevs:expression>mytime + 10</wlevs:expression>
</wlevs:application-timestamped>
</wlevs:channel>
In the example, the wlevs:expression
element defines the arithmetic expression used to assign a timestamp to each event.
Use this element to register a factory class as a service. Use of this element 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 element does not allow you to specify service properties. If you need to specify service properties, then you must use the Spring- OSGi osgi:service
element instead.
This element does not have any child elements.
Table C-12 lists the attributes of the wlevs:factory
application assembly element.
Table C-12 Attributes of the wlevs:factory Application Assembly Element
Attribute | Description | Data Type | Required? |
---|---|---|---|
|
Specifies the Java class that implements the factory. This class must implement the |
|
Yes. |
|
Specifies the name of this provider. Reference this name later in the component that uses this factory. |
|
Yes. |
The following example shows how to use the wlevs:factory
element 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 element to specify a bean that contains user-defined functions for a processor. Oracle CEP supports both single-row and aggregate functions.
This element always has a standard Spring bean
element either as a child or as a reference that specifies the Spring bean
that implements the user-defined function.
For a single-row function for an Oracle CQL processor, you may specify one method on the implementing class as the function using the exec-method
attribute. In this case, the method must be public and must be uniquely identifiable by its name (that is, the method cannot have been overridden). You may define an alias for the exec-method
name using the function-name
attribute. In the Oracle CQL query, you may call only the exec-method
(either by its name or the function-name
alias).
For a single-row function on an EPL processor, you may define an alias for the implementing class name using the function-name
attribute. The exec-method
name is not applicable in this case. In the EPL query, you may call any public or static method on the implementing class using either the implementing class name or the function-name
alias.
For an aggregate function on either an Oracle CQL or EPL processor, the Spring bean
must implement the following interfaces from the com.bea.wlevs.processor
package:
AggregationFunctionFactory
AggregationFunction
For an aggregate function, the exec-method
attribute is not applicable on both an Oracle CQL processor and an EPL processor.
For more information, see:
"User-Defined Functions" in the Oracle Fusion Middleware CQL Language Reference for Oracle Complex Event Processing
"EPL Reference: Functions" in the Oracle Fusion Middleware EPL Language Reference for Oracle Complex Event Processing
Table C-13 lists the attributes of the wlevs:function
application assembly element.
Table C-13 Attributes of the wlevs:function Application Assembly Element
Attribute | Description | Data Type | Required? |
---|---|---|---|
|
For a user-defined single-row function on an Oracle CQL processor, this element specifies the method name of the Spring For a user-defined single-row or aggregate function on an EPL processor or a user-defined aggregate function on an Oracle CQL processor, this attribute is not applicable. |
String |
No. |
|
For a user-defined single-row function on an Oracle CQL processor, use this attribute to define an alias for the For a user-defined single-row function on an EPL processor, use this attribute to define an alias for the implementing Spring For a user-defined aggregate function on an Oracle CQL or EPL processor, use this attribute to define an alias for the implementing Spring The default value is the Spring bean name. |
|
No. |
|
Specifies the Spring Set this attribute to the value of the This is an alternative to making the Spring |
|
No. |
The following examples show how to use the wlevs:function
element and its attributes on both Oracle CQL and EPL processors:
Section C.17.2.1, "Single-Row User-Defined Function on an Oracle CQL Processor"
Section C.17.2.2, "Single-Row User-Defined Function on an EPL Processor"
Section C.17.2.3, "Aggregate User-Defined Function on an Oracle CQL Processor"
Section C.17.2.4, "Aggregate User-Defined Function on an EPL Processor"
Section C.17.2.5, "Specifying the Implementation Class: Nested Bean or Reference"
Example C-1 shows how you implement a single-row user-defined the function for an Oracle CQL processor.
Example C-1 Single-Row User Defined Function Implementation Class
package com.bea.wlevs.example.function; public class MyMod { public Object execute(int arg0, int arg1) { return new Integer(arg0 % arg1); } }
Example C-2 shows how to use the wlevs:function
to define a single-row function on an Oracle CQL processor in the EPN assembly file.
Example C-2 Single-Row User Defined Function for an Oracle CQL Processor
<wlevs:processor id="testProcessor"> <wlevs:listener ref="providerCache"/> <wlevs:listener ref="outputCache"/> <wlevs:cache-source ref="testCache"/> <wlevs:function function-name="mymod" exec-method=”execute” /> <bean class="com.bea.wlevs.example.function.MyMod"/> </wlevs:function> </wlevs:processor>
Example C-3 shows how you invoke the function in an Oracle CQL query.
Example C-4 shows how you implement a single-row user-defined the function for an EPL processor.
Example C-4 Single-Row User Defined Function Implementation Class
package com.bea.wlevs.example.function; public class LegacyMathBean { public Object square(Object[] args) { ... } public Object cube(Object[] args) { ... } }
Example C-5 shows how to use the wlevs:function
to define a single-row function for an EPL processor in the EPN assembly file.
Example C-5 Single-Row User Defined Function for an EPL Processor
<wlevs:processor id="testProcessor" provider="epl"> <wlevs:listener ref="providerCache"/> <wlevs:listener ref="outputCache"/> <wlevs:cache-source ref="testCache"/> <wlevs:function function-name="math" /> <bean class="com.bea.wlevs.example.function.LegacyMathBean"/> </wlevs:function> </wlevs:processor>
Example C-6 shows how you invoke the function in an EPL query.
Example C-7 shows how to implement a user-defined aggregate function for an Oracle CQL processor.
Example C-7 Aggregate User Defined Function Implementation Class
package com.bea.wlevs.test.functions; import com.bea.wlevs.processor.AggregationFunction; import com.bea.wlevs.processor.AggregationFunctionFactory; public class Variance implements AggregationFunctionFactory, AggregationFunction { private int count; private float sum; private float sumSquare; public Class<?>[] getArgumentTypes() { return new Class<?>[] {Integer.class}; } public Class<?> getReturnType() { return Float.class; } public AggregationFunction newAggregationFunction() { return new Variance(); } public void releaseAggregationFunction(AggregationFunction function) { } public Object handleMinus(Object[] params) { if (params != null && params.length == 1) { Integer param = (Integer) params[0]; count--; sum -= param; sumSquare -= (param * param); } if (count == 0) { return null; } else { return getVariance(); } } public Object handlePlus(Object[] params) { if (params != null && params.length == 1) { Integer param = (Integer) params[0]; count++; sum += param; sumSquare += (param * param); } if (count == 0) { return null; } else { return getVariance(); } } public Float getVariance() { float avg = sum / (float) count; float avgSqr = avg * avg; float var = sumSquare / (float)count - avgSqr; return var; } public void initialize() { count = 0; sum = 0.0F; sumSquare = 0.0F; } }
Example C-8 shows how to use the wlevs:function
to define an aggregate function on an Oracle CQL processor in the EPN assembly file.
Example C-8 Aggregate User Defined Function for an Oracle CQL Processor
<wlevs:processor id="testProcessor"> <wlevs:listener ref="providerCache"/> <wlevs:listener ref="outputCache"/> <wlevs:cache-source ref="testCache"/> <wlevs:function function-name="var"> <bean class="com.bea.wlevs.test.functions.Variance"/> </wlevs:function> </wlevs:processor>
Example C-9 shows how you invoke the function in an Oracle CQL query.
Example C-10 shows how to implement a user-defined aggregate function for an EPL processor.
Example C-10 Aggregate User Defined Function Implementation Class
package com.bea.wlevs.test.functions; import com.bea.wlevs.processor.AggregationFunction; import com.bea.wlevs.processor.AggregationFunctionFactory; public class Variance implements AggregationFunctionFactory, AggregationFunction { private int count; private float sum; private float sumSquare; public Class<?>[] getArgumentTypes() { return new Class<?>[] {Integer.class}; } public Class<?> getReturnType() { return Float.class; } public AggregationFunction newAggregationFunction() { return new Variance(); } public void releaseAggregationFunction(AggregationFunction function) { } public Object handleMinus(Object[] params) { if (params != null && params.length == 1) { Integer param = (Integer) params[0]; count--; sum -= param; sumSquare -= (param * param); } if (count == 0) { return null; } else { return getVariance(); } } public Object handlePlus(Object[] params) { if (params != null && params.length == 1) { Integer param = (Integer) params[0]; count++; sum += param; sumSquare += (param * param); } if (count == 0) { return null; } else { return getVariance(); } } public Float getVariance() { float avg = sum / (float) count; float avgSqr = avg * avg; float var = sumSquare / (float)count - avgSqr; return var; } public void initialize() { count = 0; sum = 0.0F; sumSquare = 0.0F; } }
Example C-11 shows how to use the wlevs:function
to define an aggregate function on an EPL processor in the EPN assembly file.
Example C-11 Aggregate User Defined Function for an EPL Processor
<wlevs:processor id="testProcessor" provider="epl"> <wlevs:listener ref="providerCache"/> <wlevs:listener ref="outputCache"/> <wlevs:cache-source ref="testCache"/> <wlevs:function function-name="var"> <bean class="com.bea.wlevs.test.functions.Variance"/> </wlevs:function> </wlevs:processor>
Example C-12 shows how you invoke the function in an EPL query.
Example C-13 shows how to use the wlevs:function
element with a nested bean
element in the EPN assembly file.
Example C-13 User Defined Function Using Nested Bean Element
<wlevs:processor id="testProcessor"> <wlevs:listener ref="providerCache"/> <wlevs:listener ref="outputCache"/> <wlevs:cache-source ref="testCache"/> <wlevs:function function-name="testfunction"> <bean class="com.bea.wlevs.example.cache.function.TestFunction"/> </wlevs:function> </wlevs:processor>
Example C-14 shows how to use the wlevs:function
element and its ref
attribute to reference a bean
element defined outside of the wlevs:function
element in the EPN assembly file.
Example C-14 User Defined Function Using Reference
<wlevs:processor id="testProcessor"> <wlevs:listener ref="providerCache"/> <wlevs:listener ref="outputCache"/> <wlevs:cache-source ref="testCache"/> <wlevs:function function-name="testfunction" ref="testFunctionID" /> </wlevs:processor> ... <bean id="testFunctionID" class="com.bea.wlevs.example.cache.function.TestFunction"/>
Specifies the properties that apply to the create stage instance of the component to which this is a child element. This allows declarative configuration of user-defined stage properties.
For example, when you specify an wlevs:instance-property
for a wlevs:event-bean
, Oracle CEP will look for a corresponding setter method on the Java class you implement, not on the com.bea.wlevs.spring.EventBeanFactoryBean
that instantiates your class. To specify a property on the factory, use wlevs:property
This element is used only as a child of wlevs:adapter
, wlevs:event-bean
, wlevs:processor
, wlevs:channel
, or wlevs:caching-system
.
The wlevs:instance-property
element is defined as the Spring propertyType
type; for additional details of this Spring data type, the definition of the allowed child elements, and so on, see the http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
.
You can specify one of the following standard Spring elements as a child element of the wlevs:instance-property
element:
meta
bean
ref
idref
value
null
list
set
map
props
Table C-14 lists the attributes of the wlevs:instance-property
application assembly element.
Table C-14 Attributes of the wlevs:instance-property Application Assembly Element
Attribute | Description | Data Type | Required? |
---|---|---|---|
|
Specifies the name of the property, following JavaBean naming conventions. |
|
Yes. |
|
A short-cut alternative to a nested |
|
No. |
|
A short-cut alternative to a nested |
|
No. |
The following example shows how to use the wlevs:instance-property
element in the EPN assembly file:
<wlevs:event-bean id="pubsubCounterBeanRemote"
class="com.oracle.cep.example.httppubsub.RemoteEventCounter">
<wlevs:listener ref="pubsubRemote" />
<wlevs:instance-property name="expectedEvents" value="4000" />
</wlevs:event-bean>
In the example, the event bean com.oracle.cep.example.httppubsub.RemoteEventCounter
class provides an appropriate setter method:
... private int expectedEvents; public void setExpectedEvents(String expectedEvents) { this.expectedEvents = new Integer(expectedEvents).intValue(); } ...
Note that the instance-property
is of type String
. Your setter method must convert this if necessary. In this example, the String
is converted to an int
value.
The name of the setter method must conform to JavaBean naming conventions. In this example, the setter name is setExpectedEvents
and this corresponds to the wlevs:instance-property
element name
attribute value expectedEvents
, according to JavaBean conventions. If the name
attribute value is obj
and the setter method name is setObject
, Oracle CEP will throw an Invalid Property exception. In this case, the setter name should be setObj
.
Specifies the component that listens to the component to which this element 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.
Caution:
Nested definitions are not eligible for dynamic configuration or monitoring.
This element is always a child of wlevs:adapter
, wlevs:processor
, wlevs:channel
, or wlevs:caching-system
.
Table C-15 lists the attributes of the wlevs:listener
application assembly element.
Table C-15 Attributes of the wlevs:listener Application Assembly Element
Attribute | Description | Data Type | Required? |
---|---|---|---|
|
Specifies the component that listens to the parent component . Set this attribute to the value of the You do not specify this attribute if you are nesting listeners. |
|
No. |
The following example shows how to use the wlevs:listener
element 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:channel
, or wlevs:processor
element whose unique identifier is helloworldOutstream
.
Specifies the definition of an event type by listing its fields as a group of Spring entry
elements. When you define an event type this way, Oracle CEP automatically generates the Java class for you.
Use the key
attribute of the entry
element to specify the name of a field and the value
attribute to specify the Java class that represents the field's data type.
This element is used only as a child of wlevs:event-type
.
The wlevs:metadata
element is defined as the Spring mapType
type; for additional details of this Spring data type, see the http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
.
The wlevs:metadata
element can have one or more standard Spring entry
child elements as defined in the http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
.
Table C-16 lists the attributes of the wlevs:metadata
application assembly element.
The following example shows how to use the wlevs:metadata
element 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
element groups together four standard Spring entry
elements 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 element to declare a processor to the Spring application context.
Table C-17 lists the attributes of the wlevs:processor
application assembly element.
Table C-17 Attributes of the wlevs:processor Application Assembly Element
Attribute | Description | Data Type | Required? |
---|---|---|---|
|
Unique identifier for this component. This identifier must correspond to the |
|
Yes. |
|
Advertises this service in the OSGi registry. Valid values are |
|
No. |
|
Specifies the components that listen to this component. Set this attribute to the value of the |
|
No. |
|
Specifies the language provider of the processor, such as the Oracle Continuous Query Language (Oracle CQL) or Event Processor Language (EPL). Valid values are:
The default value is |
|
No. |
|
Specifies a URL that points to an Oracle CQL or EPL rules definition file for this processor. |
|
No. |
The following example shows how to use the wlevs:processor
element 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 Oracle CQL rules for this processor, the name
element must contain the value spreader
. This way Oracle CEP knows which Oracle CQL or EPL rules it must file for this particular processor.
Defines the list of properties for an event type. Use this element when you are defining an event type declaratively, such as for a type based on a tuple or java.util.Map
. For an event type created from a JavaBean class, allow properties to be defined by accessor methods in the class.
The wlevs:properties
application assembly element supports the following child elements:
Table C-18 lists the attributes of the wlevs:event-type
application assembly element.
Table C-18 Attributes of the wlevs:properties Application Assembly Element
Attribute | Description | Data Type | Required? |
---|---|---|---|
|
Specifies the type that this event type should be created from. Allowable values are tuple and map; default is tuple. If this attribute's value is |
|
No. |
The following example shows how to use the wlevs:properties
element in the EPN assembly file:
<wlevs:event-type-repository> <wlevs:event-type type-name="SimpleEvent"> <wlevs:properties> <wlevs:property name="msg" type="char" /> <wlevs:property name="count" type="long" /> <wlevs:property name="time_stamp" type="timestamp" /> </wlevs:properties> </wlevs:event-type> ... </wlevs:event-type-repository>
In the example, the name of the event type is SimpleEvent
and its definition is determined by the wlevs:property
elements. The values for the type attribute must conform to the com.bea.wlevs.ede.api.Type
class.
For more information, see Section 2.1.3, "Event Type Data Types".
Defines the property of an event type that you create declaratively, such as an event type based on a tuple or java.util.Map
. You use this wlevs:property element as a child of the wlevs:properties
element.
Note that this element is different from the wlevs:property
element that is an extension of the Spring beans property element. This element must always be used as a child of the wlevs:properties
element.
Table C-19 lists the attributes of the wlevs:property
application assembly element.
Table C-19 Attributes of the wlevs:property Application Assembly Element
Attribute | Description | Data Type | Required? |
---|---|---|---|
|
Name of the event property. |
|
Yes. |
|
Type of the event property. If this event type is defined as a tuple, then the type attribute value must be one of the OCEP native types defined by If this event type is defined as a map, then the type attribute value is the fully qualified name of a Java class that must be available in the class loader of the application that defines the event type. The string used as the Java class name must conform to the same rules as Finally, you can specify an array by appending the characters "[]" to the Java class name. |
|
Yes. |
|
If the property is of array type, this specifies the length of the array. If the type is not an array and length is specified, it will be ignored. . |
|
No. |
The following example shows how to use the wlevs:property
element in the EPN assembly file:
<wlevs:event-type-repository> <wlevs:event-type type-name="SimpleEvent"> <wlevs:properties> <wlevs:property name="msg" type="char" /> <wlevs:property name="count" type="long" /> <wlevs:property name="time_stamp" type="timestamp" /> </wlevs:properties> </wlevs:event-type> ... </wlevs:event-type-repository>
In the example, the name of the event type is SimpleEvent
and its definition is determined by the wlevs:property
elements. The values for the type attribute must conform to the com.bea.wlevs.ede.api.Type
class.
For more information, see Section 2.1.3, "Event Type Data Types".
Specifies a custom property to apply to the event type.
For example, when you specify a wlevs:property
for a wlevs:event-bean
, Oracle CEP will look for a corresponding setter method on the com.bea.wlevs.spring.EventBeanFactoryBean
that instantiates your Java class, not on the Java class you implement. To specify a property on your Java class, use wlevs:instance-property
.
This element is used only as a child of wlevs:adapter
, wlevs:event-bean
, wlevs:event-type
, wlevs:processor
, wlevs:channel
, or wlevs:caching-system
.
The wlevs:property
element is defined as the Spring propertyType
type; for additional details of this Spring data type, the definition of the allowed child elements, and so on, see the http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
.
You can specify one of the following standard Spring elements as a child element of the wlevs:property
element:
meta
bean
ref
idref
value
null
list
set
map
props
Table C-20 lists the attributes of the wlevs:property
application assembly element.
Table C-20 Attributes of the wlevs:property Application Assembly Element
Attribute | Description | Data Type | Required? |
---|---|---|---|
|
Specifies the name of the property, following JavaBean naming conventions. |
|
Yes. |
|
A short-cut alternative to a nested |
|
No. |
|
A short-cut alternative to a nested |
|
No. |
The following example shows how to use the wlevs:property
element 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"> <bean id="builderFactory" class="com.bea.wlevs.example.fx.ForeignExchangeBuilderFactory"/> </wlevs:property> </wlevs:event-type>
In the example, the wlevs:property
element defines a custom property of the ForeignExchangeEvent
called builderFactory
. The property uses the standard Spring bean
element 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.
Caution:
Nested definitions are not eligible for dynamic configuration or monitoring.
This element is a child of wlevs:channel
or wlevs:processor
.
Table C-21 lists the attributes of the wlevs:source
application assembly element.
Table C-21 Attributes of the wlevs:source Application Assembly Element
Attribute | Description | Data Type | Required? |
---|---|---|---|
|
Specifies the source of the channel to which this element is a child. Set this attribute to the value of the You do not specify this attribute if you are nesting sources. |
|
No. |
The following example shows how to use the wlevs:source
element in the EPN assembly file:
<wlevs:channel id="helloworldInstream">
<wlevs:listener ref="helloworldProcessor"/>
<wlevs:source ref="helloworldAdapter"/>
</wlevs:channel>
In the example, the component with id
helloworldAdapter
is the source of the helloworldInstream
channel component.
Specifies a relational database table that supplies data to one or more processor components. The processor components in turn are associated with an Oracle CQL query that directly references the table.
Table C-22 lists the attributes of the wlevs:table
application assembly element.
Table C-22 Attributes of the wlevs:table Application Assembly Element
Attribute | Description | Data Type | Required? |
---|---|---|---|
|
Unique identifier for this component. This identifier must correspond to the |
|
Yes. |
|
The name of the event type associated with this table as defined in the event type repository. |
|
Yes. |
|
The name of the relational data source defined in the Oracle CEP server configuration file used to access this database table. |
|
Yes. |
The following example shows how to use the wlevs:table
element in the EPN assembly file:
<wlevs:table id="Stock" event-type="StockEvent" data-source="StockDs" /> <wlevs:processor id="proc"> <wlevs:table-source ref="Stock" /> </wlevs:processor>
In this example, a wlevs:processor
references the table using its wlevs:table-source
element.
Specifies a relational database table that supplies data to this processor component. The processor component in turn is associated with an Oracle CQL query that directly references the table.
This element is a child of only wlevs:processor
element.
Table C-23 lists the attributes of the wlevs:table-source
application assembly element.
Table C-23 Attributes of the wlevs:table-source Application Assembly Element
Attribute | Description | Data Type | Required? |
---|---|---|---|
|
Specifies the relational database table that is a source of data for the processor component. Set this attribute to the value of the |
|
Yes. |