Tuesday, November 23, 2010

Apache ODE Jacob part 1 - Introduction

Here I am going to introduce some topics related to Jacob which is the framework which provides the mechanism necessary to deal with two key issues in implementing BPEL constructs in Apache ODE. The interesting part of this framework is it can be use to achieve,

  1. Resistance of execution state
  2. Concurrency
without using Java Thread (I must say it's a Java framework). 

Here I am not going to talk about how BPEL constructs are designed using Jacob, instead what I am going to talk is the behavior, how to use it to write programs etc...  This is my first post and will continue till I am not find anything new in Jacob. In this first post I like to introduce some basic Jacob concepts. If you don't understand this don't worry, because it is necessary to see them in a program to understand. So just remember there are such things as follows.
  • JacobObject/ JacobRunnable
JacobObject is the simplest element use in Jacob which can be created by extending a Java class using JacobRunnable. JacobRunnable is a command pattern which implement run() method. Further we can say all the JacobObjects should have this run() method implemented. 
  • Channels
Channels are use to communicate between JacobObjects. In this channels we should defined the methods which we use the channels to invoke. There are various channel types which we can found in Jacob and we will discuss them in later.
  • Channel Listeners or Method Lists
When we create a channel there should be a JacobObject which listening to the channel till the other JacobObject invoke a method. This is done using a Channel Listener.
  • JacobVPU, ExecutionQueueImpl
This is where Jacob is processed. JacobVPU uses ExecutionQueueImpl to put all the artifacts (mostly channels and reactions) used in processing. When we add JacobObjects to the VPU queue in runtime, VPU popped them up and executed them, and that's it. 
According to references (I listed them below) "Jacob VPU is responsible for persisting and its internal state, like serialize or de-serialize the object", but I don't have and idea yet about it. 

There is an short way to create Channels and ChannelListeners in compile time using a channel interface, by adding @ChannelType annotation as follows,

Channel interface

import org.apache.ode.jacob.ap.ChannelType;

@ChannelType
public interface Call {
public void answer();
public void reject();
public void engage();
}

Channel

public interface CallChannel extends 
org.apache.ode.jacob.
Channel, 
org.apache.ode.jacob.examples.HelloWorld.Call
{
}

ChannelListener

import org.apache.commons.logging.LogFactory;
import org.apache.commons.logging.Log;

public abstract class CallChannelListener
 extends org.apache.ode.jacob.ChannelListener <
org.apache.ode.jacob.examples.HelloWorld.CallChannel
>
 implements 
org.apache.ode.jacob.examples.HelloWorld.Call
{

    /**
*/
private static final long serialVersionUID = 1L;
private static final Log __log = LogFactory.getLog(
org.apache.ode.jacob.examples.HelloWorld.Call
.class);

    protected Log log() { return __log; } 

    protected CallChannelListener(
org.apache.ode.jacob.examples.HelloWorld.
CallChannel channel) {
       super(channel);
    }
}

To write this article I used three articles which were previously published,
  1. Exploring ODE part II: Jacob Framework by Jeff Yu http://jeff.familyyu.net/2010/01/exploring-apache-ode-source-code-part.html
  2. Wiki page of Apache ODE Jacob http://wiki.apache.org/ode/Jacob
  3. Documentation of Apache ODE Jacob http://ode.apache.org/jacob.html
When you read this you may find some places where I misunderstood, please let me and others know about it.