Try OpenEdge Now
skip to main content
Application Developer's Guide
Developing BPM Workflow adapters : Developing custom adapters : Sample adapter code for BP Server-style adapters
 

Sample adapter code for BP Server-style adapters

Use the following sample Adapter code as a template to create custom BP Server-style Adapters.
Note: When compiling the java source for this adapter, please make sure to add bpmworkflow.jar and common.jar to the classpath of your compilation environment (example, JBuilder, command line interfaces, and so on).
package com.savvion.BPM WebFlow.beans;
import com.tdiinc.common.AdapterInterface;
import java.util.Hashtable;
import java.util.Enumeration;
import java.lang.reflect.*;
public class DummyBP Server_TestEP implements AdapterInterface
{    private String stringA;
    private String stringB;
    public void setAllInputDataslots(Hashtable h)
    throws BPMWebFlowRuntimeException
    {
    Field [] myFields = null;
    try {
        myFields = this.getClass().getDeclaredFields();
        AccessibleObject.setAccessible(myFields, true);
    } catch (SecurityException se) {
        // give up, log and pass the error
        se.printStackTrace();
        Log.log(se.toString());
        throw new BPMWebFlowRuntimeException(se.toString());
    }
    for (int i=0; i<myFields.length; i++) {
    Field f = myFields[i];
        Object myVar = h.get(f.getName());
        try {
        if(myVar!=null)
            f.set(this, myVar);
            } catch (Exception ex) {
        // give up, log and pass the error
        ex.printStackTrace();
        Log.log(ex.toString());
        throw new BPM WorkflowRuntimeException(ex.toString());
        }
    }
    AccessibleObject.setAccessible(myFields, false);
    }
    public Hashtable getAllOutputDataslots()
    throws BPM WorkflowRuntimeException
    {
    Hashtable h = new Hashtable();
    Field [] myFields = null;
    try {
        myFields = this.getClass().getDeclaredFields();
        AccessibleObject.setAccessible(myFields, true);
    } catch (SecurityException se) {
        // give up, log and pass the error
        se.printStackTrace();
        Log.log(se.toString());
        throw new BPM WorkflowRuntimeException(se.toString());
    }
    for (int i=0; i<myFields.length; i++) {
        Field f = myFields[i];
        try {
        Object myVar = f.get(this);
        if(myVar == null)
            myVar = "";
        h.put(f.getName(), myVar);
        } catch (Exception ex) {
        // give up, log and pass the error
        ex.printStackTrace();
        Log.log(ex.toString());
        throw new BPM WorkflowRuntimeException(ex.toString());
        }
    }
    AccessibleObject.setAccessible(myFields, false);
    return h;
    }
    public void callMe()
    {
    String msg = "That's all folks :)";
    String className = this.getClass().getName();
    pr(className);
    pr(stringA);
    pr(stringB);
    pr(msg);
    Log.log(className);
    Log.log(stringA);
    Log.log(stringB);
    Log.log(msg);
    }
    public void setProcessContextData(Hashtable processCtx)
    {
    // not required by BPM Workflow, only by BP Server
    }
    private void pr(String msg)
    {
    System.err.println(msg);
    }
}