Chapter 11. Embedding OpenWFE

Table of Contents

The embedded engine
Using the FsPersistedEngine
Using the DbPersistedEngine
Embedded worklists
Using the the InMemoryWorklist

A set pre-embeddable OpenWFE objects to run from your java code is available.

The embedded engine

This is the java interface for an OpenWFE embedded engine :


package openwfe.org.embed.engine;

import openwfe.org.ApplicationContext;
import openwfe.org.engine.launch.LaunchException;
import openwfe.org.engine.control.ControlSession;
import openwfe.org.engine.workitem.LaunchItem;
import openwfe.org.engine.workitem.InFlowWorkItem;
import openwfe.org.engine.expressions.ReplyException;


/**
 * The interface of an embedded OpenWFE engine
 */
public interface Engine
{
    
    /**
     * Given a launch item, launches a flow in the embedded engine.
     *
     * @param async when this param is set to false, the launch call will only
     * return when the flow has been completely launched. With async set to
     * true, the method call will return immediately with the launch resuming
     * in another tread.
     */
    public String launch (LaunchItem li, boolean async)
        throws LaunchException;

    /**
     * Given the URL of a process definition, launches an instance of
     * it in the embedded engine.
     *
     * @param async when this param is set to false, the launch call will only
     * return when the flow has been completely launched. With async set to
     * true, the method call will return immediately with the launch resuming
     * in another tread.
     */
    public String launch (String flowUrl, boolean async)
        throws LaunchException;

    /**
     * Registers a participant in the participant map of the embedded engine.
     */
    public void registerParticipant (EmbeddedParticipant p);

    /**
     * When a participant has finished working with a workitem, it uses this
     * method to give it back to the engine.
     */
    public void reply (InFlowWorkItem wi)
        throws ReplyException;

    /**
     * Returns the context where the embedded engine components are located.
     */
    public ApplicationContext getContext ();

    /**
     * Returns the name of this embedded engine.
     */
    public String getName ();

    /**
     * Returns a control session on this engine.
     */
    public ControlSession getControlSession ();

}

It shows the various thing you are able to do with such an engine. Of course, you'd better have a look too at the usage examples that follow.