![]() ![]() ![]() ![]() ![]() ![]() |
This section contains information on the following subjects:
The business logic component is typically the last component in your event network, the one that receives results from the EPL queries associated with the processor components. This is also the component in which you program your application business code. For example, the business logic component might publish the events to a Web site, pass the events on to a legacy application, and so on.
This component is a plain old Java object, or POJO. Programming the component is very simple with few required guidelines. You can also use the JDBC API to access data in a relational database, as described in Accessing a Relational Database
The simplest way to describe the guidelines to programming the business POJO is to show an example.
The following sample code shows the business logic POJO for the HelloWorld application; see the explanation after the example for the code shown in bold:
package com.bea.wlevs.example.helloworld;
import java.util.List;
import com.bea.wlevs.ede.api.EventRejectedException;
import com.bea.wlevs.ede.api.EventSink;import com.bea.wlevs.event.example.helloworld.HelloWorldEvent;
public class HelloWorldBean implements EventSink {
public void onEvent(List newEvents)
throws EventRejectedException {
for (Object event : newEvents) {if (event instanceof HelloWorldEvent) {
}
HelloWorldEvent helloWorldEvent = (HelloWorldEvent) event;
System.out.println("Message: " + helloWorldEvent.getMessage());
}
}
}
The programming guidelines shown in the preceding example are as follows:
HelloWorldEvent
:import com.bea.wlevs.event.example.helloworld.HelloWorldEvent;
com.bea.wlevs.ede.api.EventSink
interface:public class HelloWorldBean implements EventSink {...
EventSink
interface has a single method that you must implement, onEvent(java.util.List)
, which is a callback method for receiving events. The parameter of the method is a List
that contains the actual events that the POJO received from the processor, typically via a stream:public void onEvent(List newEvents)
HelloWorldEvent
; the code first ensures that the received event is truly a HelloWorldEvent
:if (event instanceof HelloWorldEvent) {
HelloWorldEvent helloWorldEvent = (HelloWorldEvent) event;
This event type is a JavaBean that was configured in the EPN assembly file as shown:
<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>
See Creating the EPN Assembly File for procedural information about creating the EPN assembly file, and WebLogic Event Server Spring Tag Reference for reference information.
getXXX() methods
. In the example, the HelloWorldEvent
has a property called message
:System.out.println("Message: " + helloWorldEvent.getMessage());
For complete API reference information about the WebLogic Event Server APIs described in this section, see the Javadocs.
You can use the Java Database Connectivity (JDBC) APIs in your business logic POJO to access data contained in a relational database. WebLogic Event Server supports JDBC 3.0.
Follow these steps to use JDBC in your business logic POJO:
For details, see Configuring Access to a Relational Database.
DataSource
or instantiating a DriverManager
. For example:OracleDataSource ods = new OracleDataSource();
ods.setURL("jdbc:oracle:thin:user/passwd@localhost:1521/XE");
Connection conn =
ods.getConnection();
See Getting Started with the JDBC API for additional programming information.
![]() ![]() ![]() |