2 Application Assembly Schema

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:

2.1 Application Assembly Element Hierarchy

Oracle Stream Explorer 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 Explorer 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

2.2 wlevs:adapter

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

Attribute Description Data Type Required?

id

Unique identifier for this component.

This identifier must correspond to the <name> element in the XML configuration file for this adapter, if one exists.

String

Yes.

advertise

Advertises this service in the OSGi registry.

Valid values are true and false. Default value is false.

Boolean

No.

listeners

Specifies the components that listen to this component.

Set this attribute to the value of the id attribute of the element that declared the component.

String

No.

provider

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 csvgen or loadgen utilities to simulate a data feed, use the hard-coded csvgen or loadgen values, respectively, such as:

provider="csvgen"

If you are using one of the built-in HTTP publish-subscribe adapters, then specify the following hard-coded values:

  • For the built-in pub-sub adapter used for publishing, specify the hard-coded httppub value, such as:

    provider="httppub"
    
  • For the built-in pub-sub adapter used for subscribing, specify the hard-coded httpsub value, such as:

    provider="httpsub"

If you are using a JMS adapter, then specify one of the following hard-coded values:

  • For the inbound JMS adapter, specify the jms-inbound value, such as:

    provider="jms-inbound"
  • For the outbound JMS adapter, specify the jms-outbound value, such as:

    provider="jms-outbound"

You must specify either the provider or class attribute, but not both, otherwise an exception is raised.

String

No.

class

Specifies the Java class that implements this adapter.

You must specify either the provider or class attribute, but not both, otherwise an exception is raised.

String

No

onevent-method

Specifies the method of the adapter implementation that corresponds to the life cycle onEvent method.

Oracle Stream Explorer invokes this method when the adapter receives an event.

String

No

init-method

Specifies the method of the adapter implementation that corresponds to the life cycle init method.

Oracle Stream Explorer 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 mis-configuration.

String

No

activate-method

Specifies the method of the adapter implementation that corresponds to the life cycle activate method.

Oracle Stream Explorer 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.

String

No

suspend-method

Specifies the method of the adapter implementation that corresponds to the life cycle suspend method.

Oracle Stream Explorer invokes this method when the application is suspended.

String

No

destroy-method

Specifies the method of the adapter implementation that corresponds to the life cycle destroy method.

Oracle Stream Explorer invokes this method when the application is stopped.

String

No

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>

2.3 wlevs:application-timestamped

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 Explorer 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

Attribute Description Data Type Required?

is-total-order

When true, indicates that the application time published is always strictly greater than the last value used.

Valid values are true or false. Default: false.

Boolean

No.

is-silent-relation

When true, indicates that a relation is silent. A silent relation does not emit changes frequently. This setting applies only when the wlevs:channel element attribute is-relation is true.

Valid values are true and false. Default is false.

Boolean

No.

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>

2.4 wlevs:cache

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

Attribute Description Data Type Required?

id

Unique identifier for this component.

This identifier must correspond to the <name> element in the XML configuration file for this cache.

String

Yes.

name

Specifies an alternate name for this cache. If not specified, then the name of the cache is the same as its id attribute.

String

No.

key-properties

Specifies a comma-separated list of property names that form the unique key value for the objects in the cache, or cache key. A cache key can be composed of a single property or multiple properties. When you configure a cache as a listener in an event processing network, Oracle Stream Explorer inserts events that reach the cache using the unique key value as a key.

If you specify a key class with the key-class attribute, then this attribute is optional. If you specify neither key-properties nor key-class, then Oracle Stream Explorer uses the event object itself as both the key and value when it inserts the event object into the cache.

String

No.

key-class

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 key-properties attribute, then all properties on the key-class are assumed to be key properties. If you specify neither key-properties nor key-class, then Oracle Stream Explorer uses the event object itself as both the key and value when it inserts the event object into the cache

String

No.

value-type

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 query. This is because the query processor needs to know the type of events in the cache.

String

No.

caching-system

Specifies the caching system where this cache is contained.

The value of this attribute corresponds to the id attribute of the appropriate wlevs:caching-system element.

String

Yes.

advertise

Advertises this service in the OSGi registry.

Valid values are true and false. Default value is false.

Boolean

No.

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>

2.5 wlevs:cache-listener

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

Attribute Description Data Type Required?

ref

Specifies the component that listens to this cache.

Set this attribute to the value of the id attribute of the listening component. The listening component can be an adapter or a Spring bean.

String

No.

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"/>

2.6 wlevs:cache-loader

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

Attribute Description Data Type Required?

ref

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 com.bea.cache.jcache.CacheLoader interface.

String

Yes.

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"/>

2.7 wlevs:cache-source

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

Attribute Description Data Type Required?

ref

Specifies the cache that is a source of data for the processor component.

Set this attribute to the value of the id attribute of the cache.

String

Yes.

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>

2.8 wlevs:cache-store

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

Attribute Description Data Type Required?

ref

Specifies the Spring bean that implements the custom store.

Set this attribute to the value of the id attribute of the Spring bean.

The Spring bean must implement the com.bea.cache.jcache.CacheStore interface.

String

Yes.

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"/>

2.9 wlevs:caching-system

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

Attribute Description Data Type Required?

id

Specifies the unique identifier for this caching system.

This identifier must correspond to the <name> element in the XML configuration file for this caching system

String

Yes.

advertise

Advertises this service in the OSGi registry.

Valid values are true and false. Default value is false.

Boolean

No.

provider

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 provider-name attribute of a <factory> Spring element that specifies the factory class that creates instances of the third-party caching system.

If you do not specify the provider or class attribute, then the default value is the Oracle Stream Explorer native caching implementation for local single-JVM caches; this implementation uses an in-memory store.

String

No.

class

Specifies the Java class that implements this caching system; use this attribute to specify a third-party implementation rather than the Oracle Stream Explorer native caching implementation.

If you specify this attribute, it is assumed that the third-party implementation code resides inside the Oracle Stream Explorer application bundle itself. The class file to which this attribute points must implement the com.bea.wlevs.cache.api.CachingSystem interface.

If you do not specify the provider or class attribute, then the default value is the Oracle Stream Explorer native caching implementation for local single-JVM caches; this implementation uses an in-memory store.

String

No

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>

2.10 wlevs:channel

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

Attribute Description Data Type Required?

advertise

Advertises this service in the OSGi registry.

Valid values are true and false. Default value is false.

Boolean

No.

batching

Specifies whether batching of events should be enabled for the event channel.

Valid values are true and false. Default value is false.

Boolean

No.

event-type

Specifies the type of events that are allowed to pass through the event channel.

String

Yes.

id

Unique identifier for this component.

This identifier must correspond to the <name> element in the XML configuration file for this channel, if one exists.

String

Yes.

is-relation

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 false.

Boolean

No.

listeners

Specifies the components that listen to this component. Separate multiple components using commas.

Set this attribute to the value of the id attribute of the element (wlevs:adapter, wlevs:channel, or wlevs:processor) that defines the listening component.

String

No.

max-size

Specifies the maximum size of the FIFO buffer for this channel as max-size number of events.

When max-size = 0, the channel synchronously passes-through events.

When max-size > 0, the channel processes events asynchronously, buffering events by the requested size.

If max-threads is zero, then max-size is zero.

The default value for this attribute is 1024.

integer

No.

max-threads

Specifies the maximum number of threads that will be used to process events for this channel.

When max-threads = 0, the channel acts as a pass-through. Event ordering is preserved.

When max-threads > 0, the channel acts as classic blocking queue, where upstream components are producers of events and the downstream components are the consumers of events. The queue size is defined by the configuration max-size. There will be up to max-threads number of threads consuming events from the queue. Event ordering is non-deterministic.

You can change max-threads from 0 to a positive integer (that is, from a pass through to multiple threads) without redeploying. However, if you change max-threads from a positive integer to 0 (that is, from multiple threads to a pass through), then you must redeploy your application.

If the max-size attribute is 0, then setting a value for max-threads has no effect.

The default value for this attribute is 1.

integer

No.

primary-key

Specifies the primary key of a relation, as a list of event property names, separated by "," or white-spaces.

String

No.

provider

Specifies the streaming provider.

Valid values are:

  • oracle.channel

Default value is oracle.channel, which is the out-of-the-box streaming provider.

String

No.

source

Specifies the component from which the channel sources events.

Set this attribute to the value of the id attribute of the element (wlevs:adapter, wlevs:channel, or wlevs:processor) that defines the source component.

String

No.

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" />

2.11 wlevs:class

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>

2.12 wlevs:event-bean

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 Explorer 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 Explorer.

For example, you can monitor an event bean using the Oracle Stream Explorer 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 Explorer bean life cycle by specifying methods in its EPN assembly file declaration, rather than by implementing Oracle Stream Explorer 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

Attribute Description Data Type Required?

id

Unique identifier for this component.

This identifier must correspond to the <name> element in the XML configuration file for this event-bean, if one exists.

String

Yes.

advertise

Advertises this service in the OSGi registry.

Valid values are true and false. Default is false.

Boolean

No.

listeners

Specifies the components that listen to this component.

Set this attribute to the value of the id attribute of the element that declared the component.

String

No.

class

Specifies the Java class that implements this event bean. The bean is not required to implement any Oracle Stream Explorer interfaces.

You must specify either the provider or class attribute, but not both, otherwise an exception is raised.

provider

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 provider or class attribute, but not both, otherwise an exception is raised.

String

No.

onevent-method

Specifies the method of the event bean implementation that corresponds to the life cycle onEvent method.

Oracle Stream Explorer invokes this method when the event bean receives an event.

By using this life cycle attribute, the event bean implementation does not have to explicitly implement an Oracle Stream Explorer interface.

String

No

init-method

Specifies the method of the event bean implementation that corresponds to the life cycle init method.

Oracle Stream Explorer 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 life cycle attribute, the event bean implementation does not have to explicitly implement an Oracle Stream Explorer interface.

String

No

activate-method

Specifies the method of the event bean implementation that corresponds to the life cycle activate method.

Oracle Stream Explorer 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 life cycle attribute, the event bean implementation does not have to explicitly implement an Oracle Stream Explorer interface.

String

No

suspend-method

Specifies the method of the event bean implementation that corresponds to the life cycle suspend method.

Oracle Stream Explorer invokes this method when the application is suspended.

By using this life cycle attribute, the event bean implementation does not have to explicitly implement an Oracle Stream Explorer interface.

String

No

destroy-method

Specifies the method of the event bean implementation that corresponds to the life cycle destroy method.

Oracle Stream Explorer invokes this method when the application is stopped.

By using this life cycle attribute, the event bean implementation does not have to explicitly implement an Oracle Stream Explorer interface.

String

No

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>

2.13 wlevs:event-type

Specifies the definition of an event type used in the Oracle Stream Explorer 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:

Attributes

Table 2-11 Attributes of the wlevs:event-type Application Assembly Element

Attribute Description Data Type Required?

id

Specifies the unique identifier for this event type.

If you do not specify this attribute, Oracle Stream Explorer automatically generates an identifier for you.

String

No.

type-name

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 rules.

String

Yes.

object-support

Specifies if Java objects should be fully supported. Allowable values are true, false, and object-relational; default is object-relational.

If set to false, then the Java primitive wrappers (for example, java.lang.Integer) and java.lang.String are treated as primitive types.

If set to true, then Java primitive wrappers are treated as classes.

If set to object-relational, then Java primitive wrappers are treated as relations, rather than as streams.

String

No.

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>

2.14 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>

2.15 wlevs:expression

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 for Oracle Stream Explorer.

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>

2.16 wlevs:factory

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

Attribute Description Data Type Required?

class

Specifies the Java class that implements the factory. This class must implement the com.bea.wlevs.ede.api.Factory interface.

String

Yes.

provider-name

Specifies the name of this provider. Reference this name later in the component that uses this factory.

String

Yes.

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" />

2.17 wlevs:function

Use this element to specify a bean that contains user-defined functions for a processor.Developing Applications for Event Processing with Oracle Stream Explorer 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 for Oracle Stream Explorer.

Attributes

Table 2-13 Attributes of the wlevs:function Application Assembly Element

Attribute Description Data Type Required?

exec-method

For a user-defined single-row function on an Oracle CQL processor, this element specifies the method name of the Spring bean that implements the function. In this case, the method must be public and must be uniquely identifiable by its name (that is, the method cannot have been overridden).

For a user-defined aggregate function on an Oracle CQL processor, this attribute is not applicable.

String

No.

function-name

For a user-defined single-row function on an Oracle CQL processor, use this attribute to define an alias for the exec-method name. You can then use the function-name in your Oracle CQL query instead of the exec-name.

For a user-defined aggregate function on an Oracle CQL processor, use this attribute to define an alias for the implementing Spring bean class name.

The default value is the Spring bean name.

String

No.

ref

Specifies the Spring bean that implements the function.

Set this attribute to the value of the id attribute of the Spring bean.

This is an alternative to making the Spring bean element a child of the wlevs:function element.

String

No.

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"/>

2.18 wlevs:instance-property

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 Explorer 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

Attribute Description Data Type Required?

name

Specifies the name of the property, following JavaBean naming conventions.

String

Yes.

ref

A short-cut alternative to a nested <ref bean='...'/> element.

String

No.

value

A short-cut alternative to a nested <value>...</value> element.

String

No.

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 Explorer will throw an Invalid Property exception. In this case, the setter name should be setObj.

2.19 wlevs:listener

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?

ref

Specifies the component that listens to the parent component.

Set this attribute to the value of the id attribute of the listener component.

You do not specify this attribute if you are nesting listeners.

String

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>

2.20 wlevs:metadata

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 Explorer 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

Attribute Description Data Type Required?

key-type

The default fully qualified class name of a Java data type for nested entry elements.

You use this attribute only if you have nested entry elements.

String

No.

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>

2.21 wlevs:processor

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

Attribute Description Data Type Required?

id

Unique identifier for this component.

This identifier must correspond to the <name> element in the XML configuration file for this processor; this is how Oracle Stream Explorer knows which Oracle CQL rules to execute for which processor component in your network.

String

Yes.

advertise

Advertises this service in the OSGi registry.

Valid values are true and false. Default value is false.

Boolean

No.

listeners

Specifies the components that listen to this component.

Set this attribute to the value of the id attribute of the element that declared the component.

String

No.

provider

Specifies the language provider of the processor, such as Oracle CQL.

Valid value is cql.

The default value is cql.

String

No.

queryURL

Specifies a URL that points to an Oracle CQL rules definition file for this processor.

String.

No.

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 Explorer knows which Oracle CQL rules it must file for this particular processor.

<wlevs:processor id="spreader" />

2.22 wlevs:properties

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

Attribute Description Data Type Required?

type

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 map, then Oracle Stream Explorer will instantiate the event type as a java.util.Map instance. Otherwise, the type will be instantiated as a tuple.

String

No.

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>

2.23 wlevs:property

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

Attribute Description Data Type Required?

name

Name of the event property.

String

Yes.

type

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 com.bea.wlevs.ede.api.Type. Those include bigint, boolean, byte, char, double, float, int, interval, object, sqlxml, timestamp, unknown, and xmltype.

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 Class.forName(). In addition, Java primitives can be used (such as int and float).

Finally, you can specify an array by appending the characters '[]' to the Java class name

String

Yes.

length

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.

.

String

No.

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>

2.24 wlevs:property

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 Explorer 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

Attribute Description Data Type Required?

name

Specifies the name of the property, following JavaBean naming conventions.

String

Yes.

ref

A short-cut alternative to a nested <ref bean='...'/> element.

String

No.

value

A short-cut alternative to a nested <value>...</value> element.

String

No.

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>

2.25 wlevs:source

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

Attribute Description Data Type Required?

ref

Specifies the source of the channel to which this element is a child.

Set this attribute to the value of the id attribute of the source component.

You do not specify this attribute if you are nesting sources.

String

No.

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>

2.26 wlevs:table

Specifies a relational database table that can work as an event sink or an event source.

2.26.1 Table 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

Attribute Description Data Type Required?

id

Unique identifier for this component.

This identifier must correspond to the <name> element in the XML configuration file for this table.

String

Yes.

event-type

The name of the event type associated with this table as defined in the event type repository.

String

Yes.

data-source

The name of the relational data source defined in the Oracle Stream Explorer server configuration file used to access this database table.

String

Yes.

table-name

The name of the relational database table. When you use wlevs:table as a table source, the table-name is optional. When you use wlevs:table as a table sink, the table-name is required.

String

No

external-rows-threshold

Specify the external rows threshold when you use a table source as an external source for joining. Does not apply to table sinks.

Long

No

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>

2.26.2 Table Sink

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

Attribute Description Data Type Required?

id

Unique identifier for this component.

This identifier must correspond to the <name> element in the XML configuration file for this table.

String

Yes

event-type

The name of the event type associated with this table as defined in the event type repository.

String

Yes

data-source

The name of the relational data source defined in the Oracle Stream Explorer server configuration file used to access this database table.

String

Yes

table-name

The name of the relational database table. When you use wlevs:table as a table source, the table-name is optional. When you use wlevs:table as a table sink, the table-name is required.

String

Yes

key-properties

Forms the unique key value for the relational database table. The unique key is required for update and delete operations executed by an event sink.

String

Yes

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"/>

2.27 wlevs:table-source

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

Attribute Description Data Type Required?

ref

Specifies the relational database table that is a source of data for the processor component. Set ref to the id attribute value of a wlevs:table element.

String

Yes.

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>