Creating WebLogic Event Server Applications

     Previous  Next    Open TOC in new window    View as PDF - New Window  Get Adobe Reader - New Window
Content starts here

Programming the Business Logic Component

This section contains information on the following subjects:

 


Overview of Programming the Business Logic Component

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

 


Programming Business Logic: Guidelines

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:

For complete API reference information about the WebLogic Event Server APIs described in this section, see the Javadocs.

 


Accessing a Relational Database

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:

  1. Configure JDBC for WebLogic Event Server.
  2. For details, see Configuring Access to a Relational Database.

  3. In your business logic POJO Java code, you can start using the JDBC APIs as usual, by using a DataSource or instantiating a DriverManager. For example:
  4.    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.


  Back to Top       Previous  Next