The application assembly schema is behind the assembly file where you declare EPN components. This chapter provides a reference to the elements of the spring-wlevs-v12_1_3_0.xsd
schema.
This chapter includes the following sections:
Oracle Stream Analytics 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 Stream Analytics 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
Use the wlevs:adapter
element to declare an adapter component to the Spring application context.
Child Elements
The wlevs:adapter
application assembly element supports the following child elements:
Attributes
Table 2-1 Attributes of the wlevs:adapter Application Assembly Element
|
Example
The following example shows how to use the wlevs:adapter
element in the EPN assembly file. 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.
<wlevs:adapter id="helloworldAdapter" provider="hellomsgs"> <wlevs:instance-property name="message" value="HelloWorld - the current time is:"/> </wlevs:adapter>
Use this element to specify if an wlevs:channel
is application time stamped, that is, if the application is responsible for assigning a time stamp to each event, using any time domain.
Otherwise, wlevs:channel
is system time stamped, that is, the Oracle Stream Analytics server is responsible for assigning a time stamp to each event using System.nanoTime
.
Child Elements
The wlevs:application-timestamped
application assembly element supports the following child elements.
wlevs:expression:
Specifies an expression to be used as an application time stamp for event processing.
Attributes
Table 2-2 Attributes of the wlevs:application-timestamped Application Assembly Element
|
Example
The following example shows how to use the wlevs:application-timestamped
element in the EPN assembly file to specify an implicitly application time stamped channel. In the example, the application handles event time stamps internally.
<wlevs:channel id="fxMarketAmerOut" > <wlevs:application-timestamped> </wlevs:application-timestamped> </wlevs:channel>
The following example shows how to use wlevs:application-timestamped
element in the EPN assembly file to specify an explicitly application time stamped channel by specifying the wlevs:expression
element. In the example, the wlevs:expression
element defines the arithmetic expression used to assign a time stamp to each event.
<wlevs:channel id="fxMarketAmerOut" > <wlevs:application-timestamped> <wlevs:expression>mytime+10</wlevs:expression> </wlevs:application-timestamped> </wlevs:channel>
The following example adds the is-silent-relation
and is-relation
attributes set to true. These settings mean that the channel does not emit changes very frequently.
<wlevs:channel id="AppTimeStampedChannel"/> <wlevs:application-timestamped is-silent-relation="true" is-relation="true"> <wlevs:expression>mytime+10</wlevs:expression> </wlevs:application-timestamped>
Use this element to declare a cache to the Spring application context.
Child Elements
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 differs 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.
Attributes
Table 2-3 Attributes of the wlevs:cache Application Assembly Element
|
Example
The following example shows how to use the wlevs:cache
element in the EPN assembly file. 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
.
<wlevs:cache id="cache-id" name="alternative-cache-name">
<wlevs:caching-system ref="caching-system-id"/>
<wlevs:cache-listener ref="tradeListener" />
</wlevs:cache>
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
.
Attributes
Table 2-4 Attributes of the wlevs:cache-listener Application Assembly Element
|
Example
The following example shows how to use the wlevs:cache-listener
element in the EPN assembly file. 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.
<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"/>
spring-wlevs-v12_1_3_0.xsd specifies the Spring bean that implements an object that loads data into a cache.
This element is always a child of wlevs:cache
.
Attributes
Table 2-5 Attributes of the wlevs:cache-loader Application Assembly Element
|
Example
The following example shows how to use the wlevs:cache-loader
element in the EPN assembly file. 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.
<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"/>
Specifies a cache that supplies data to this processor component. The processor component in turn is associated with an Oracle CQL 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.
Attributes
Table 2-6 Attributes of the wlevs:cache-source Application Assembly Element
|
Example
The following example shows how to use the wlevs:cache-source
element in the EPN assembly file. In the example, the processor will have data pushed to it from the stream-id
channel as usual; however, the Oracle CQL 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.
<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>
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
.
Attributes
Table 2-7 Attributes of the wlevs:cache-store Application Assembly Element
|
Example
The following example shows how to use the wlevs:cache-store
element in the EPN assembly file. 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.
<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"/>
Specifies the caching system used by the application.
Child Elements
The wlevs:caching-system
application assembly element supports the following child elements:
Attributes
Table 2-8 Attributes of the wlevs:caching-system Application Assembly Element
|
Example
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. 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.
<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>
Use this element to declare a channel to the Spring application context.
By default, channels assume that events are system time stamped. To configure application time stamped events, see child element wlevs:application-timestamped
.
Child Elements
The wlevs:channel
application assembly element supports the following child elements:
Attributes
Table 2-9 Attributes of the wlevs:channel Application Assembly Element
|
Example
The following example shows how to use the wlevs:channel
element in the EPN assembly file. The example shows how to declare a channel service with unique identifier fxMarketAmerOut
.
<wlevs:channel id="fxMarketAmerOut" />
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.
The following example shows how to use the wlevs:class
element in the EPN assembly file:
<wlevs:event-type-repository> <wlevs:event-type type-name="SimpleEvent"> <wlevs:class>com.example.myapp.MyEventType</wlevs:class> </wlevs:event-type> ... </wlevs:event-type-repository>
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 Stream Analytics 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 Stream Analytics.
For example, you can monitor an event bean using the Oracle Stream Analytics 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 Stream Analytics bean life cycle by specifying methods in its EPN assembly file declaration, rather than by implementing Oracle Stream Analytics API interfaces.
Child Elements
The wlevs:event-bean
application assembly element supports the following child elements:
Attributes
Table 2-10 Attributes of the wlevs:event-bean Application Assembly Element
|
Example
The following example shows how to use the wlevs:event-bean
element in the EPN assembly file. 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.
<wlevs:event-bean id="myBean" class="com.customer.SomeEventBean" > <wlevs:listener ref="myProcessor" /> </wlevs:event-bean>
Specifies the definition of an event type used in the Oracle Stream Analytics 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 class name using the wlevs:class
child element.
Specify event type properties declaratively with 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.
Child Elements
The wlevs:event-type
application assembly element supports the following child elements:
wlevs:metadata
(deprecated)
Attributes
Table 2-11 Attributes of the wlevs:event-type Application Assembly Element
|
Example
The following example shows how to use the wlevs:event-type
element in the EPN assembly file. 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.
<wlevs:event-type-repository> <wlevs:event-type id="messagecounts" 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>
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.
Child Element
The wlevs:event-type-repository
application assembly element supports the wlevs:event-type child element:
Example
The following example shows how to use the wlevs:event-type-repository
element in the EPN assembly file:
In the example, the wlevs:event-type-repository
element groups a single wlevs:event-type
element to declare a single event type: HelloWorldEvent
. See wlevs:event-type
for additional details.
<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>
Use this element to specify an arithmetic expression in wlevs:application-timestamped
to be used as an application time stamp for event processing. See Oracle CQL Language Reference.
Example
The following example shows how to use wlevs:expression
element in the EPN assembly file to specify an explicitly application time stamped channel. In the example, the wlevs:expression
element defines the arithmetic expression used to assign a time stamp to each event.
<wlevs:channel id="fxMarketAmerOut" >
<wlevs:application-timestamped>
<wlevs:expression>mytime + 10</wlevs:expression>
</wlevs:application-timestamped>
</wlevs:channel>
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.
Attributes
Table 2-12 Attributes of the wlevs:factory Application Assembly Element
|
Example
The following example shows how to use the wlevs:factory
element in the EPN assembly file. In the example, the factory implemented by the com.customer.MyEventSourceFactory
goes by the provider name of myEventSourceFactory
.
<wlevs:factory provider-name="myEventSourceFactory" class="com.customer.MyEventSourceFactory" />
Use this element to specify a bean that contains user-defined functions for a processor.Developing Applications for Event Processing with Oracle Stream Analytics 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 can 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. 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 an aggregate function on an Oracle CQL 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 an Oracle CQL processor.
For more information, see the Oracle CQL Language Reference.
Attributes
Table 2-13 Attributes of the wlevs:function Application Assembly Element
|
Examples
The following examples show how to use the wlevs:function
element and its attributes on both Oracle CQL processors.
Example 2-1 Implement a single-row, user-defined function for an Oracle CQL processor
package com.bea.wlevs.example.function; public class MyMod { public Object execute(int arg0, int arg1) { return new Integer(arg0 % arg1); } }
Example 2-2 Define a single-row function on an Oracle CQL processor in the assembly file
<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 2-3 Invoke the function in an Oracle CQL query
... <view id="v1" schema="c1 c2 c3 c4"><![CDATA[ select mymod(c1, 100), c2, c3, c4 from S1 ></view> ... <query id="q1"><![CDATA[ select * from v1 [partition by c1 rows 1] where c4 - c3 = 2.3 ></query> ...
Example 2-4 Implement a user-defined aggregate function for an Oracle CQL processor
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 2-5 Invoke an aggregate function on an Oracle CQL processor in the assembly file.
<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 2-6 Invoke an aggregate function in an Oracle CQL query
... <query id="uda6"><![CDATA[ select var(c2) from S4[range 3] ></query> ...
Example 2-7 Nest a bean element in the assembly file
<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 2-8 Reference a bean element defined outside of the function in the assembly file
<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 a wlevs:instance-property
for a wlevs:event-bean
, Oracle Stream Analytics looks 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 more information about the Spring data type, see http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
.
Child Elements
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
.
Attributes
Table 2-14 Attributes of the wlevs:instance-property Application Assembly Element
|
Examples
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 Stream Analytics 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
.
Attributes
Table 2-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. |
Example
The following example shows how to use the wlevs:listener
element in the EPN assembly file. 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
.
<wlevs:processor id="helloworldProcessor">
<wlevs:listener ref="helloworldOutstream"/>
</wlevs:processor>
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 Stream Analytics 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
.
Child Elements
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
.
Attributes
Table 2-16 Attributes of the wlevs:metadata Application Assembly Element
|
Example
The following example shows how to use the wlevs:metadata
element in the EPN assembly file. 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.
<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>
Use this element to declare a processor to the Spring application context.
Child Elements
The wlevs:processor
Spring element supports the following child elements:
Attributes
Table 2-17 Attributes of the wlevs:processor Application Assembly Element
|
Example
The following example shows how to use the wlevs:processor
element in the EPN assembly file. 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 Stream Analytics knows which Oracle CQL rules it must file for this particular processor.
<wlevs:processor id="spreader" />
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.
Child Elements
The wlevs:properties
application assembly element supports the wlevs:property child elements:
Attributes
Table 2-18 Attributes of the wlevs:properties Application Assembly Element
|
Example
The following example shows how to use the wlevs:properties
element in the EPN assembly file. 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.
<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>
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.
Attributes
Table 2-19 Attributes of the wlevs:property Application Assembly Element
|
Example
The following example shows how to use the wlevs:property
element in the EPN assembly file. 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.
<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>
Specifies a custom property to apply to the event type.
For example, when you specify a wlevs:property
for a wlevs:event-bean
, Oracle Stream Analytics looks 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 more information about the Spring data type, see http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
Child Elements
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
.
Attributes
Table 2-20 Attributes of the wlevs:property Application Assembly Element
|
Example
The following example shows how to use the wlevs:property
element in the EPN assembly file. 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
.
<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>
Specifies an event source for this component. The event source is the component from which the events are coming. 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. This element is a child of wlevs:channel
or wlevs:processor
.
Caution:
Nested definitions are not eligible for dynamic configuration or monitoring.
Attributes
Table 2-21 Attributes of the wlevs:source Application Assembly Element
|
Example
The following example shows how to use the wlevs:source
element in the EPN assembly file. In the example, the component with id
helloworldAdapter
is the source of the helloworldInstream
channel component.
<wlevs:channel id="helloworldInstream">
<wlevs:listener ref="helloworldProcessor"/>
<wlevs:source ref="helloworldAdapter"/>
</wlevs:channel>
Specifies a relational database table that can work as an event sink or an event source.
A relational database table that supplies event data to one or more processor components. You associate the processor components with an Oracle CQL query that directly references the table source.
Attributes
Table 2-22 Attributes of the wlevs:table Application Assembly Element
|
Example
The following example shows how to use the wlevs:table
element in the EPN assembly file. In this example, a wlevs:processor
references the table using its wlevs:table-source
element.
<wlevs:table id="Stock" event-type="StockEvent" data-source="StockDs" /> <wlevs:processor id="proc"> <wlevs:table-source ref="Stock" /> </wlevs:processor>
A relational database table component that is a table tag in an Oracle CQL processor that receives event data coming into the EPN and stores that data in a persistent data store. This feature is more flexible than the recording feature because you can control the structure of the relational database table. In contrast, the recording feature stores events in a format that works best for the record and playback feature.
After events are stored in the persistent data source, they are sent to the next stage in the EPN. When you create the persistent database table, make sure the column names are the same as the event type property names.
Attributes
Table 2-23 Attributes of the wlevs:table Application Assembly Element
|
Example
The following example is an added final stage in the HelloWorld example that is a table sink. The table sink stores events of type HelloWorldEvent
to a data source named helloDataSource
.
<wlevs:channel id="helloworldOutputChannel" event-type="HelloWorldEvent" advertise="true"> <wlevs:listener ref="tableSink"/> <wlevs:source ref="helloworldProcessor"/> </wlevs:channel> <wlevs:table id="tableSink" event-type="HelloWorldEvent" key-properties="message" data-source="helloDataSource" table-name="HelloMessages"/>
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.
Attributes
Table 2-24 Attributes of the wlevs:table-source Application Assembly Element
|
Example
The following example shows how to use the wlevs:table-source
element in the assembly file:
<wlevs:table id="Stock" event-type="StockEvent" data-source="StockDs" /> <wlevs:processor id="proc"> <wlevs:table-source ref="Stock" /> </wlevs:processor>