You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ode.apache.org by ms...@apache.org on 2007/09/06 07:46:57 UTC
svn commit: r573153 [3/9] - in /ode/trunk: ./
axis2/src/main/java/org/apache/ode/axis2/ bpel-api/src/
bpel-api/src/main/java/org/apache/ode/bpel/explang/
bpel-api/src/main/java/org/apache/ode/bpel/iapi/
bpel-api/src/main/java/org/apache/ode/bpel/pmapi/...
Modified: ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelProcess.java
URL: http://svn.apache.org/viewvc/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelProcess.java?rev=573153&r1=573152&r2=573153&view=diff
==============================================================================
--- ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelProcess.java (original)
+++ ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelProcess.java Wed Sep 5 22:46:42 2007
@@ -20,19 +20,29 @@
import java.io.InputStream;
import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
+import java.util.Random;
import java.util.Set;
import java.util.concurrent.Callable;
+import java.util.concurrent.Future;
+import javax.wsdl.Operation;
import javax.xml.namespace.QName;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.apache.ode.bpel.common.CorrelationKey;
import org.apache.ode.bpel.common.FaultException;
import org.apache.ode.bpel.dao.BpelDAOConnection;
+import org.apache.ode.bpel.dao.CorrelatorDAO;
+import org.apache.ode.bpel.dao.MessageDAO;
+import org.apache.ode.bpel.dao.MessageExchangeDAO;
+import org.apache.ode.bpel.dao.MessageRouteDAO;
import org.apache.ode.bpel.dao.ProcessDAO;
import org.apache.ode.bpel.dao.ProcessInstanceDAO;
import org.apache.ode.bpel.evt.ProcessInstanceEvent;
@@ -42,14 +52,23 @@
import org.apache.ode.bpel.iapi.BpelEngineException;
import org.apache.ode.bpel.iapi.Endpoint;
import org.apache.ode.bpel.iapi.EndpointReference;
+import org.apache.ode.bpel.iapi.InvocationStyle;
import org.apache.ode.bpel.iapi.MessageExchange;
+import org.apache.ode.bpel.iapi.MyRoleMessageExchange;
import org.apache.ode.bpel.iapi.PartnerRoleChannel;
import org.apache.ode.bpel.iapi.ProcessConf;
+import org.apache.ode.bpel.iapi.MessageExchange.AckType;
+import org.apache.ode.bpel.iapi.MessageExchange.FailureType;
+import org.apache.ode.bpel.iapi.MessageExchange.Status;
+import org.apache.ode.bpel.iapi.MyRoleMessageExchange.CorrelationStatus;
+import org.apache.ode.bpel.iapi.Scheduler.JobInfo;
+import org.apache.ode.bpel.iapi.Scheduler.JobProcessorException;
+import org.apache.ode.bpel.intercept.FailMessageExchangeException;
+import org.apache.ode.bpel.intercept.FaultMessageExchangeException;
import org.apache.ode.bpel.intercept.InterceptorInvoker;
import org.apache.ode.bpel.intercept.MessageExchangeInterceptor;
-import org.apache.ode.bpel.o.OElementVarType;
+import org.apache.ode.bpel.memdao.BpelDAOConnectionFactoryImpl;
import org.apache.ode.bpel.o.OExpressionLanguage;
-import org.apache.ode.bpel.o.OMessageVarType;
import org.apache.ode.bpel.o.OPartnerLink;
import org.apache.ode.bpel.o.OProcess;
import org.apache.ode.bpel.o.Serializer;
@@ -58,8 +77,8 @@
import org.apache.ode.bpel.runtime.PropertyAliasEvaluationContext;
import org.apache.ode.bpel.runtime.channels.FaultData;
import org.apache.ode.jacob.soup.ReplacementMap;
+import org.apache.ode.utils.GUID;
import org.apache.ode.utils.ObjectPrinter;
-import org.apache.ode.utils.DOMUtils;
import org.apache.ode.utils.msg.MessageBundle;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
@@ -69,10 +88,10 @@
/**
* Entry point into the runtime of a BPEL process.
*
- * @author mszefler
+ * @author Maciej Szefler <mszefler at gmail dot com>
* @author Matthieu Riou <mriou at apache dot org>
*/
-public class BpelProcess {
+class BpelProcess {
static final Log __log = LogFactory.getLog(BpelProcess.class);
private static final Messages __msgs = MessageBundle.getMessages(Messages.class);
@@ -101,8 +120,6 @@
/** Last time the process was used. */
private volatile long _lastUsed;
- BpelEngineImpl _engine;
-
DebuggerSupport _debugger;
ExpressionLanguageRuntimeRegistry _expLangRuntimeRegistry;
@@ -115,31 +132,66 @@
private final List<MessageExchangeInterceptor> _mexInterceptors = new ArrayList<MessageExchangeInterceptor>();
/** Latch-like thing to control hydration/dehydration. */
- private HydrationLatch _hydrationLatch;
+ HydrationLatch _hydrationLatch;
+
+ protected Contexts _contexts;
+
+ final BpelInstanceWorkerCache _instanceWorkerCache = new BpelInstanceWorkerCache(this);
+
+ private final Set<InvocationStyle> _invocationStyles;
+
+ private BpelDAOConnectionFactoryImpl _inMemDao;
- public BpelProcess(ProcessConf conf) {
+ private Random _random = new Random();
+
+ final BpelServerImpl _server;
+
+ /** Weak-reference cache of all the my-role message exchange objects. */
+ final private MyRoleMessageExchangeCache _myRoleMexCache = new MyRoleMessageExchangeCache(this);
+
+ BpelProcess(BpelServerImpl server, ProcessConf conf, BpelEventListener debugger) {
+ _server = server;
_pid = conf.getProcessId();
_pconf = conf;
_hydrationLatch = new HydrationLatch();
+ _contexts = server._contexts;
+ _inMemDao = new BpelDAOConnectionFactoryImpl(_contexts.txManager);
+
+ // TODO : do this on a per-partnerlink basis, support transacted styles.
+ HashSet<InvocationStyle> istyles = new HashSet<InvocationStyle>();
+ istyles.add(InvocationStyle.UNRELIABLE);
+
+ if (!conf.isTransient()) {
+ istyles.add(InvocationStyle.RELIABLE);
+ } else {
+ istyles.add(InvocationStyle.TRANSACTED);
+ }
+
+ _invocationStyles = Collections.unmodifiableSet(istyles);
}
public String toString() {
return "BpelProcess[" + _pid + "]";
}
- public void recoverActivity(ProcessInstanceDAO instanceDAO, String channel, long activityId, String action, FaultData fault) {
+ void recoverActivity(ProcessInstanceDAO instanceDAO, final String channel, final long activityId, final String action, final FaultData fault) {
if (__log.isDebugEnabled())
__log.debug("Recovering activity in process " + instanceDAO.getInstanceId() + " with action " + action);
markused();
- BpelRuntimeContextImpl processInstance = createRuntimeContext(instanceDAO, null, null);
- processInstance.recoverActivity(channel, activityId, action, fault);
- }
+ BpelInstanceWorker iworker = _instanceWorkerCache.get(instanceDAO.getInstanceId());
+ final BpelRuntimeContextImpl processInstance = new BpelRuntimeContextImpl(iworker,instanceDAO);
+ try {
+ iworker.execInCurrentThread(new Callable<Void> () {
- static String generateMessageExchangeIdentifier(String partnerlinkName, String operationName) {
- StringBuffer sb = new StringBuffer(partnerlinkName);
- sb.append('.');
- sb.append(operationName);
- return sb.toString();
+ public Void call() throws Exception {
+ processInstance.recoverActivity(channel, activityId, action, fault);
+ return null;
+ }
+
+ });
+ } catch (Exception e) {
+ throw new BpelEngineException(e);
+ }
}
/**
@@ -147,59 +199,223 @@
*
* @param mex
*/
- void invokeProcess(MyRoleMessageExchangeImpl mex) {
+ void invokeProcess(final MessageExchangeDAO mexdao) {
+ InvocationStyle istyle = mexdao.getInvocationStyle();
+
+ _hydrationLatch.latch(1);
try {
- _hydrationLatch.latch(1);
- PartnerLinkMyRoleImpl target = getMyRoleForService(mex.getServiceName());
+ // The following check is mostly for sanity purposes. MexImpls should prevent this from
+ // happening.
+ PartnerLinkMyRoleImpl target = getMyRoleForService(mexdao.getCallee());
+ Status oldstatus = mexdao.getStatus();
if (target == null) {
- String errmsg = __msgs.msgMyRoleRoutingFailure(mex.getMessageExchangeId());
+ String errmsg = __msgs.msgMyRoleRoutingFailure(mexdao.getMessageExchangeId());
__log.error(errmsg);
- mex.setFailure(MessageExchange.FailureType.UNKNOWN_ENDPOINT, errmsg, null);
+ MexDaoUtil.setFailed(mexdao, MessageExchange.FailureType.UNKNOWN_ENDPOINT, errmsg);
+ onMyRoleMexAck(mexdao, oldstatus);
return;
}
- mex.getDAO().setProcess(getProcessDAO());
+ Operation op = target._plinkDef.getMyRoleOperation(mexdao.getOperation());
+ if (op == null) {
+ String errmsg = __msgs.msgMyRoleRoutingFailure(mexdao.getMessageExchangeId());
+ __log.error(errmsg);
+ MexDaoUtil.setFailed(mexdao, MessageExchange.FailureType.UNKNOWN_OPERATION, errmsg);
+ onMyRoleMexAck(mexdao, oldstatus);
+ return;
+ }
- if (!processInterceptors(mex, InterceptorInvoker.__onProcessInvoked)) {
- __log.debug("Aborting processing of mex " + mex + " due to interceptors.");
+ if (!processInterceptors(mexdao, InterceptorInvoker.__onProcessInvoked)) {
+ __log.debug("Aborting processing of mex " + mexdao.getMessageExchangeId() + " due to interceptors.");
+ onMyRoleMexAck(mexdao, oldstatus);
return;
}
+ // "Acknowledge" any one-way invokes
+ if (op.getOutput() == null) {
+ mexdao.setStatus(Status.ACK);
+ mexdao.setAckType(AckType.ONEWAY);
+ onMyRoleMexAck(mexdao, oldstatus);
+ }
+
+ mexdao.setProcess(getProcessDAO());
+
markused();
- target.invokeMyRole(mex);
- markused();
+ CorrelationStatus cstatus = target.invokeMyRole(mexdao);
+ if (cstatus == null) {
+ ; // do nothing
+ } else if (cstatus == CorrelationStatus.CREATE_INSTANCE) {
+ doInstanceWork(mexdao.getInstance().getInstanceId(), new Callable<Void>() {
+ public Void call() {
+ executeCreateInstance(mexdao);
+ return null;
+ }
+ });
+
+ } else if (cstatus == CorrelationStatus.MATCHED) {
+ // This should not occur for in-memory processes, since they are technically not allowed to
+ // have any <receive>/<pick> elements that are not start activities.
+ if (isInMemory())
+ __log.warn("In-memory process " + _pid + " is participating in a non-createinstance exchange!");
+
+ // We don't like to do the work in the same TX that did the matching, since this creates fertile
+ // conditions for deadlock in the correlation tables. However if invocation style is transacted,
+ // we need to do the work right then and there.
+
+ if (istyle == InvocationStyle.TRANSACTED || istyle == InvocationStyle.P2P) {
+ doInstanceWork(mexdao.getInstance().getInstanceId(), new Callable<Void>() {
+ public Void call() {
+ executeContinueInstanceMyRoleRequestReceived(mexdao);
+ return null;
+ }
+ });
+ } else /* non-transacted style */{
+ WorkEvent we = new WorkEvent();
+ we.setType(WorkEvent.Type.MYROLE_INVOKE);
+ we.setIID(mexdao.getInstance().getInstanceId());
+ we.setMexId(mexdao.getMessageExchangeId());
+ we.setProcessId(_pid);
+
+ scheduleWorkEvent(we, null);
+ }
+ } else if (cstatus == CorrelationStatus.QUEUED) {
+ ; // do nothing
+ }
} finally {
_hydrationLatch.release(1);
+
+ // If we did not get an ACK during this method, then mark this MEX as needing an ASYNC wake-up
+ if (mexdao.getStatus() != Status.ACK)
+ mexdao.setStatus(Status.ASYNC);
+
+ assert mexdao.getStatus() == Status.ACK || mexdao.getStatus() == Status.ASYNC;
+ }
+
+ }
+
+ void executeCreateInstance(MessageExchangeDAO mexdao) {
+ assert _hydrationLatch.isLatched(1);
+
+ BpelInstanceWorker worker = _instanceWorkerCache.get(mexdao.getInstance().getInstanceId());
+ assert worker.isWorkerThread();
+ BpelRuntimeContextImpl instanceCtx = new BpelRuntimeContextImpl(worker, mexdao.getInstance(), new PROCESS(_oprocess),
+ mexdao);
+ instanceCtx.execute();
+ }
+
+ void executeContinueInstanceMyRoleRequestReceived(MessageExchangeDAO mexdao) {
+ assert _hydrationLatch.isLatched(1);
+
+ BpelInstanceWorker worker = _instanceWorkerCache.get(mexdao.getInstance().getInstanceId());
+ assert worker.isWorkerThread();
+
+ BpelRuntimeContextImpl instance = new BpelRuntimeContextImpl(worker, mexdao.getInstance());
+ int amp = mexdao.getChannel().indexOf('&');
+ String groupId = mexdao.getChannel().substring(0, amp);
+ int idx = Integer.valueOf(mexdao.getChannel().substring(amp + 1));
+ instance.injectMyRoleMessageExchange(groupId, idx, mexdao);
+ instance.execute();
+ }
+
+ void executeContinueInstanceResume(ProcessInstanceDAO instanceDao) {
+ BpelInstanceWorker worker = _instanceWorkerCache.get(instanceDao.getInstanceId());
+ assert worker.isWorkerThread();
+
+ BpelRuntimeContextImpl brc = new BpelRuntimeContextImpl(worker, instanceDao);
+ brc.execute();
+
+ }
+
+ void executeContinueInstanceTimerReceived(ProcessInstanceDAO instanceDao, String timerChannel) {
+ BpelInstanceWorker worker = _instanceWorkerCache.get(instanceDao.getInstanceId());
+ assert worker.isWorkerThread();
+
+ BpelRuntimeContextImpl brc = new BpelRuntimeContextImpl(worker, instanceDao);
+ if (brc.injectTimerEvent(timerChannel))
+ brc.execute();
+
+ }
+
+ private void executeContinueInstanceMatcherEvent(ProcessInstanceDAO instanceDao, String correlatorId,
+ CorrelationKey correlationKey) {
+
+ if (__log.isDebugEnabled()) {
+ __log.debug("MatcherEvent handling: correlatorId=" + correlatorId + ", ckey=" + correlationKey);
}
- // For a one way, once the engine is done, the mex can be safely released.
- if (mex.getPattern().equals(MessageExchange.MessageExchangePattern.REQUEST_ONLY)) {
- mex.release();
+ CorrelatorDAO correlator = instanceDao.getProcess().getCorrelator(correlatorId);
+
+ // Find the route first, this is a SELECT FOR UPDATE on the "selector" row,
+ // So we want to acquire the lock before we do anthing else.
+ MessageRouteDAO mroute = correlator.findRoute(correlationKey);
+ if (mroute == null) {
+ // Ok, this means that a message arrived before we did, so nothing to do.
+ __log.debug("MatcherEvent handling: nothing to do, route no longer in DB");
+ return;
+ }
+
+ // Now see if there is a message that matches this selector.
+ MessageExchangeDAO mexdao = correlator.dequeueMessage(correlationKey);
+ if (mexdao != null) {
+ __log.debug("MatcherEvent handling: found matching message in DB (i.e. message arrived before <receive>)");
+
+ // We have a match, so we can get rid of the routing entries.
+ correlator.removeRoutes(mroute.getGroupId(), instanceDao);
+
+ // Found message matching one of our selectors.
+ if (__log.isDebugEnabled()) {
+ __log.debug("SELECT: " + mroute.getGroupId() + ": matched to MESSAGE " + mexdao + " on CKEY " + correlationKey);
+ }
+
+ BpelInstanceWorker worker = _instanceWorkerCache.get(instanceDao.getInstanceId());
+ assert worker.isWorkerThread();
+
+ BpelRuntimeContextImpl brc = new BpelRuntimeContextImpl(worker, instanceDao);
+ brc.injectMyRoleMessageExchange(mroute.getGroupId(), mroute.getIndex(), mexdao);
+ brc.execute();
+ } else {
+ __log.debug("MatcherEvent handling: nothing to do, no matching message in DB");
+
+ }
+
+ }
+
+ void executeContinueInstancePartnerRoleResponseReceived(MessageExchangeDAO mexdao) {
+ assert _hydrationLatch.isLatched(1);
+ BpelInstanceWorker worker = _instanceWorkerCache.get(mexdao.getInstance().getInstanceId());
+ assert worker.isWorkerThread();
+
+ BpelRuntimeContextImpl brc = new BpelRuntimeContextImpl(worker, mexdao.getInstance());
+
+ brc.injectPartnerResponse(mexdao.getMessageExchangeId(), mexdao.getChannel());
+ brc.execute();
+ }
+
+ void enqueueInstanceTransaction(Long instanceId, final Runnable runnable) {
+ BpelInstanceWorker iworker = _instanceWorkerCache.get(instanceId);
+ iworker.enqueue(_server.new TransactedRunnable(runnable));
+ }
+
+ private <T> T doInstanceWork(Long instanceId, final Callable<T> callable) {
+ try {
+ BpelInstanceWorker iworker = _instanceWorkerCache.get(instanceId);
+ return iworker.execInCurrentThread(new ProcessCallable<T>(callable));
+
+ } catch (Exception ex) {
+ throw new BpelEngineException(ex);
}
}
private PartnerLinkMyRoleImpl getMyRoleForService(QName serviceName) {
- for (Map.Entry<Endpoint, PartnerLinkMyRoleImpl> e : getEndpointToMyRoleMap().entrySet()) {
+ assert _hydrationLatch.isLatched(1);
+
+ for (Map.Entry<Endpoint, PartnerLinkMyRoleImpl> e : _endpointToMyRoleMap.entrySet()) {
if (e.getKey().serviceName.equals(serviceName))
return e.getValue();
}
return null;
}
- void initMyRoleMex(MyRoleMessageExchangeImpl mex) {
- markused();
- PartnerLinkMyRoleImpl target = null;
- for (Endpoint endpoint : getEndpointToMyRoleMap().keySet()) {
- if (endpoint.serviceName.equals(mex.getServiceName()))
- target = getEndpointToMyRoleMap().get(endpoint);
- }
- if (target != null) {
- mex.setPortOp(target._plinkDef.myRolePortType, target._plinkDef.getMyRoleOperation(mex.getOperationName()));
- } else {
- __log.warn("Couldn't find endpoint from service " + mex.getServiceName() + " when initializing a myRole mex.");
- }
- }
-
/**
* Extract the value of a BPEL property from a BPEL messsage variable.
*
@@ -217,13 +433,12 @@
PropertyAliasEvaluationContext ectx = new PropertyAliasEvaluationContext(msgData, alias);
Node lValue = ectx.getRootNode();
- if (alias.location != null) {
+ if (alias.location != null)
try {
lValue = _expLangRuntimeRegistry.evaluateNode(alias.location, ectx);
} catch (EvaluationException ec) {
throw new FaultException(getOProcess().constants.qnSelectionFailure, alias.getDescription());
}
- }
if (lValue == null) {
String errmsg = __msgs.msgPropertyAliasReturnedNullSet(alias.getDescription(), target);
@@ -236,7 +451,8 @@
if (lValue.getNodeType() == Node.ELEMENT_NODE) {
// This is a bit hokey, we concatenate all the children's values; we
// really should be checking to make sure that we are only dealing
- // with text and attribute nodes.
+ // with
+ // text and attribute nodes.
StringBuffer val = new StringBuffer();
NodeList nl = lValue.getChildNodes();
for (int i = 0; i < nl.getLength(); ++i) {
@@ -251,100 +467,110 @@
}
/**
- * Get the element name for a given WSDL part. If the part is an <em>element</em> part, the name of that element is returned.
- * If the part is an XML schema typed part, then the name of the part is returned in the null namespace.
- *
- * @param part
- * WSDL {@link javax.wsdl.Part}
- * @return name of element containing said part
- */
- static QName getElementNameForPart(OMessageVarType.Part part) {
- return (part.type instanceof OElementVarType) ? ((OElementVarType) part.type).elementType : new QName(null, part.name);
- }
-
- /**
* Process the message-exchange interceptors.
*
* @param mex
* message exchange
* @return <code>true</code> if execution should continue, <code>false</code> otherwise
*/
- boolean processInterceptors(MyRoleMessageExchangeImpl mex, InterceptorInvoker invoker) {
- InterceptorContextImpl ictx = new InterceptorContextImpl(_engine._contexts.dao.getConnection(), getProcessDAO(), _pconf);
+ boolean processInterceptors(MessageExchangeDAO mexdao, InterceptorInvoker invoker) {
+ InterceptorContextImpl ictx = new InterceptorContextImpl(_contexts.dao.getConnection(), mexdao, getProcessDAO(), _pconf);
- for (MessageExchangeInterceptor i : _mexInterceptors)
- if (!mex.processInterceptor(i, mex, ictx, invoker))
- return false;
- for (MessageExchangeInterceptor i : getEngine().getGlobalInterceptors())
- if (!mex.processInterceptor(i, mex, ictx, invoker))
- return false;
+ try {
+ for (MessageExchangeInterceptor interceptor : _mexInterceptors)
+ invoker.invoke(interceptor, ictx);
+
+ for (MessageExchangeInterceptor interceptor : _server._contexts.globalIntereceptors)
+ invoker.invoke(interceptor, ictx);
+ } catch (FailMessageExchangeException e) {
+ MexDaoUtil.setFailed(mexdao,FailureType.ABORTED, e.getMessage());
+ return false;
+ } catch (FaultMessageExchangeException e) {
+ MexDaoUtil.setFaulted(mexdao, e.getFaultName(), e.getFaultData());
+ return false;
+ }
return true;
}
/**
+ * Handle a work event; this method is called from the scheduler thread and should be very quick, i.e. any serious work needs to
+ * be handed off to a separate thread.
+ *
+ * @throws JobProcessorException
* @see org.apache.ode.bpel.engine.BpelProcess#handleWorkEvent(java.util.Map<java.lang.String,java.lang.Object>)
*/
- public void handleWorkEvent(Map<String, Object> jobData) {
- try {
- _hydrationLatch.latch(1);
- markused();
+ void handleWorkEvent(final JobInfo jobInfo) throws JobProcessorException {
+ assert !_contexts.isTransacted() : "work events must be received outside of a transaction";
- if (__log.isDebugEnabled()) {
- __log.debug(ObjectPrinter.stringifyMethodEnter("handleWorkEvent", new Object[] { "jobData", jobData }));
+ markused();
+
+ final WorkEvent we = new WorkEvent(jobInfo.jobDetail);
+ if (__log.isDebugEnabled()) {
+ __log.debug(ObjectPrinter.stringifyMethodEnter("handleWorkEvent", new Object[] { "jobInfo", jobInfo }));
+ }
+
+ enqueueInstanceTransaction(we.getIID(), new Runnable() {
+ public void run() {
+ _contexts.scheduler.jobCompleted(jobInfo.jobName);
+ execInstanceEvent(we);
}
+ });
- WorkEvent we = new WorkEvent(jobData);
+ }
- // Process level events
- if (we.getType().equals(WorkEvent.Type.INVOKE_INTERNAL)) {
- if (__log.isDebugEnabled()) {
- __log.debug("InvokeInternal event for mexid " + we.getMexId());
- }
- MyRoleMessageExchangeImpl mex = (MyRoleMessageExchangeImpl) _engine.getMessageExchange(we.getMexId());
- invokeProcess(mex);
- } else {
- // Instance level events
- ProcessInstanceDAO procInstance = getProcessDAO().getInstance(we.getIID());
- if (procInstance == null) {
- if (__log.isDebugEnabled()) {
- __log.debug("handleWorkEvent: no ProcessInstance found with iid " + we.getIID() + "; ignoring.");
- }
- return;
- }
+ /**
+ * Enqueue a transaction for execution by the engine.
+ *
+ * @param tx
+ * the transaction
+ */
+ <T> Future<T> enqueueTransaction(final Callable<T> tx) {
+ // We have to wrap our transaction to make sure that we are hydrated when the transaction runs.
+ return _server.enqueueTransaction(new ProcessCallable<T>(tx));
+ }
- BpelRuntimeContextImpl processInstance = createRuntimeContext(procInstance, null, null);
- switch (we.getType()) {
- case TIMER:
- if (__log.isDebugEnabled()) {
- __log.debug("handleWorkEvent: TimerWork event for process instance " + processInstance);
- }
- processInstance.timerEvent(we.getChannel());
- break;
- case RESUME:
- if (__log.isDebugEnabled()) {
- __log.debug("handleWorkEvent: ResumeWork event for iid " + we.getIID());
- }
- processInstance.execute();
- break;
- case INVOKE_RESPONSE:
- if (__log.isDebugEnabled()) {
- __log.debug("InvokeResponse event for iid " + we.getIID());
- }
- processInstance.invocationResponse(we.getMexId(), we.getChannel());
- processInstance.execute();
- break;
- case MATCHER:
- if (__log.isDebugEnabled()) {
- __log.debug("Matcher event for iid " + we.getIID());
- }
- processInstance.matcherEvent(we.getCorrelatorId(), we.getCorrelationKey());
- }
+ private void execInstanceEvent(WorkEvent we) {
+ BpelInstanceWorker worker = _instanceWorkerCache.get(we.getIID());
+ assert worker.isWorkerThread();
+
+ ProcessInstanceDAO instanceDAO = getProcessDAO().getInstance(we.getIID());
+ MessageExchangeDAO mexDao = we.getMexId() == null ? null : loadMexDao(we.getMexId());
+
+ if (instanceDAO == null) {
+ if (__log.isDebugEnabled()) {
+ __log.debug("handleWorkEvent: no ProcessInstance found with iid " + we.getIID() + "; ignoring.");
}
- } finally {
- _hydrationLatch.release(1);
+ return;
+ }
+
+ if (__log.isDebugEnabled()) {
+ __log.debug("handleWorkEvent: " + we.getType() + " event for process instance " + we.getIID());
}
+
+ switch (we.getType()) {
+ case MYROLE_INVOKE:
+ executeContinueInstanceMyRoleRequestReceived(mexDao);
+ break;
+ case TIMER:
+ executeContinueInstanceTimerReceived(instanceDAO, we.getChannel());
+ break;
+ case RESUME:
+ executeContinueInstanceResume(instanceDAO);
+ break;
+ case PARTNER_RESPONSE:
+ executeContinueInstancePartnerRoleResponseReceived(mexDao);
+ break;
+ case MATCHER:
+ executeContinueInstanceMatcherEvent(instanceDAO, we.getCorrelatorId(), we.getCorrelationKey());
+ break;
+ }
+ }
+
+ MessageExchangeDAO loadMexDao(String mexId) {
+ return isInMemory() ? _inMemDao.getConnection().getMessageExchange(mexId) : _contexts.dao.getConnection()
+ .getMessageExchange(mexId);
}
private void setRoles(OProcess oprocess) {
@@ -397,8 +623,7 @@
}
ProcessDAO getProcessDAO() {
- return _pconf.isTransient() ? _engine._contexts.inMemDao.getConnection().getProcess(_pid) : getEngine()._contexts.dao
- .getConnection().getProcess(_pid);
+ return isInMemory() ? _inMemDao.getConnection().getProcess(_pid) : _contexts.dao.getConnection().getProcess(_pid);
}
static String genCorrelatorId(OPartnerLink plink, String opName) {
@@ -432,14 +657,14 @@
return endpoints;
}
- void activate(BpelEngineImpl engine) {
- _engine = engine;
+ void activate(Contexts contexts) {
+ _contexts = contexts;
_debugger = new DebuggerSupport(this);
__log.debug("Activating " + _pid);
// Activate all the my-role endpoints.
for (Map.Entry<String, Endpoint> entry : _pconf.getProvideEndpoints().entrySet()) {
- EndpointReference initialEPR = _engine._contexts.bindingContext.activateMyRoleEndpoint(_pid, entry.getValue());
+ EndpointReference initialEPR = _contexts.bindingContext.activateMyRoleEndpoint(_pid, entry.getValue());
__log.debug("Activated " + _pid + " myrole " + entry.getKey() + ": EPR is " + initialEPR);
_myEprs.put(entry.getValue(), initialEPR);
}
@@ -451,14 +676,14 @@
void deactivate() {
// Deactivate all the my-role endpoints.
for (Endpoint endpoint : _myEprs.keySet())
- _engine._contexts.bindingContext.deactivateMyRoleEndpoint(endpoint);
+ _contexts.bindingContext.deactivateMyRoleEndpoint(endpoint);
// TODO Deactivate all the partner-role channels
}
EndpointReference getInitialPartnerRoleEPR(OPartnerLink link) {
+ _hydrationLatch.latch(1);
try {
- _hydrationLatch.latch(1);
PartnerLinkPartnerRoleImpl prole = _partnerRoles.get(link);
if (prole == null)
throw new IllegalStateException("Unknown partner link " + link);
@@ -469,8 +694,8 @@
}
Endpoint getInitialPartnerRoleEndpoint(OPartnerLink link) {
+ _hydrationLatch.latch(1);
try {
- _hydrationLatch.latch(1);
PartnerLinkPartnerRoleImpl prole = _partnerRoles.get(link);
if (prole == null)
throw new IllegalStateException("Unknown partner link " + link);
@@ -481,8 +706,8 @@
}
EndpointReference getInitialMyRoleEPR(OPartnerLink link) {
+ _hydrationLatch.latch(1);
try {
- _hydrationLatch.latch(1);
PartnerLinkMyRoleImpl myRole = _myRoles.get(link);
if (myRole == null)
throw new IllegalStateException("Unknown partner link " + link);
@@ -497,8 +722,8 @@
}
PartnerRoleChannel getPartnerRoleChannel(OPartnerLink partnerLink) {
+ _hydrationLatch.latch(1);
try {
- _hydrationLatch.latch(1);
PartnerLinkPartnerRoleImpl prole = _partnerRoles.get(partnerLink);
if (prole == null)
throw new IllegalStateException("Unknown partner link " + partnerLink);
@@ -532,8 +757,9 @@
* Ask the process to dehydrate.
*/
void dehydrate() {
+ _hydrationLatch.latch(0);
+
try {
- _hydrationLatch.latch(0);
// We don't actually need to do anything, the latch will run the doDehydrate method
// when necessary..
} finally {
@@ -543,44 +769,148 @@
}
void hydrate() {
+ _hydrationLatch.latch(1);
+
try {
- _hydrationLatch.latch(1);
// We don't actually need to do anything, the latch will run the doHydrate method
// when necessary..
} finally {
_hydrationLatch.release(1);
}
}
-
+
OProcess getOProcess() {
+ _hydrationLatch.latch(1);
try {
- _hydrationLatch.latch(1);
return _oprocess;
} finally {
_hydrationLatch.release(1);
}
}
- private Map<Endpoint, PartnerLinkMyRoleImpl> getEndpointToMyRoleMap() {
+ private MyRoleMessageExchangeImpl newMyRoleMex(InvocationStyle istyle, String mexId, QName target, OPartnerLink oplink,
+ Operation operation) {
+ MyRoleMessageExchangeImpl mex;
+ switch (istyle) {
+ case RELIABLE:
+ mex = new ReliableMyRoleMessageExchangeImpl(this, mexId, oplink, operation, target);
+ break;
+ case TRANSACTED:
+ mex = new TransactedMyRoleMessageExchangeImpl(this, mexId, oplink, operation, target);
+ break;
+ case UNRELIABLE:
+ mex = new UnreliableMyRoleMessageExchangeImpl(this, mexId, oplink, operation, target);
+ break;
+ default:
+ throw new AssertionError("Unexpected invocation style: " + istyle);
+
+ }
+
+ _myRoleMexCache.put(mex);
+ return mex;
+ }
+
+ /**
+ * Lookup a {@link MyRoleMessageExchangeImpl} object in the cache, re-creating it if not found.
+ *
+ * @param mexdao
+ * DB representation of the mex.
+ * @return client representation
+ */
+ MyRoleMessageExchangeImpl lookupMyRoleMex(MessageExchangeDAO mexdao) {
+ return _myRoleMexCache.get(mexdao); // this will re-create if necessary
+ }
+
+ /**
+ * Create (or recreate) a {@link MyRoleMessageExchangeImpl} object from data in the db. This method is used by the
+ * {@link MyRoleMessageExchangeCache} to re-create objects when they are not found in the cache.
+ *
+ * @param mexdao
+ * @return
+ */
+ MyRoleMessageExchangeImpl recreateMyRoleMex(MessageExchangeDAO mexdao) {
+ InvocationStyle istyle = mexdao.getInvocationStyle();
+
+ _hydrationLatch.latch(1);
try {
- _hydrationLatch.latch(1);
- return _endpointToMyRoleMap;
+ OPartnerLink plink = (OPartnerLink) _oprocess.getChild(mexdao.getPartnerLinkModelId());
+ if (plink == null) {
+ String errmsg = __msgs.msgDbConsistencyError("MexDao #" + mexdao.getMessageExchangeId()
+ + " referenced unknown pLinkModelId " + mexdao.getPartnerLinkModelId());
+ __log.error(errmsg);
+ throw new BpelEngineException(errmsg);
+ }
+
+ Operation op = plink.getMyRoleOperation(mexdao.getOperation());
+ if (op == null) {
+ String errmsg = __msgs.msgDbConsistencyError("MexDao #" + mexdao.getMessageExchangeId()
+ + " referenced unknown operation " + mexdao.getOperation());
+ __log.error(errmsg);
+ throw new BpelEngineException(errmsg);
+ }
+
+ PartnerLinkMyRoleImpl myRole = _myRoles.get(plink);
+ if (myRole == null) {
+ String errmsg = __msgs.msgDbConsistencyError("MexDao #" + mexdao.getMessageExchangeId()
+ + " referenced non-existant myrole");
+ __log.error(errmsg);
+ throw new BpelEngineException(errmsg);
+ }
+
+ MyRoleMessageExchangeImpl mex = newMyRoleMex(istyle, mexdao.getMessageExchangeId(), myRole._endpoint.serviceName,
+ plink, op);
+ mex.load(mexdao);
+ return mex;
} finally {
_hydrationLatch.release(1);
}
}
- public ReplacementMap getReplacementMap() {
+ PartnerRoleMessageExchangeImpl createPartnerRoleMex(MessageExchangeDAO mexdao) {
+
+ _hydrationLatch.latch(1);
try {
- _hydrationLatch.latch(1);
- return _replacementMap;
+ OPartnerLink plink = (OPartnerLink) _oprocess.getChild(mexdao.getPartnerLinkModelId());
+ PartnerLinkPartnerRoleImpl prole = _partnerRoles.get(plink);
+ return prole.createPartnerRoleMex(mexdao);
} finally {
_hydrationLatch.release(1);
}
+
+ }
+
+ Set<InvocationStyle> getSupportedInvocationStyle(QName serviceId) {
+ return _invocationStyles;
+ }
+
+ /**
+ * Find the partner-link-my-role that corresponds to the given service name.
+ *
+ * @param serviceName
+ * name of service
+ * @return corresponding {@link PartnerLinkMyRoleImpl}
+ */
+ private PartnerLinkMyRoleImpl getPartnerLinkForService(QName serviceName) {
+ assert _hydrationLatch.isLatched(1);
+
+ PartnerLinkMyRoleImpl target = null;
+ for (Endpoint endpoint : _endpointToMyRoleMap.keySet()) {
+ if (endpoint.serviceName.equals(serviceName))
+ target = _endpointToMyRoleMap.get(endpoint);
+ }
+
+ return target;
+
}
- BpelEngineImpl getEngine() {
- return _engine;
+ /**
+ * Used by {@link BpelRuntimeContextImpl} constructor. Should only be called from latched context.
+ *
+ * @return
+ */
+ ReplacementMap getReplacementMap() {
+ assert _hydrationLatch.isLatched(1);
+ return _replacementMap;
}
public boolean isInMemory() {
@@ -603,13 +933,6 @@
_lastUsed = System.currentTimeMillis();
}
- /** Create a version-appropriate runtime context. */
- BpelRuntimeContextImpl createRuntimeContext(ProcessInstanceDAO dao, PROCESS template,
- MyRoleMessageExchangeImpl instantiatingMessageExchange) {
- return new BpelRuntimeContextImpl(this, dao, template, instantiatingMessageExchange);
-
- }
-
/**
* If necessary, create an object in the data store to represent the process. We'll re-use an existing object if it already
* exists and matches the GUID.
@@ -651,7 +974,153 @@
}
}
- private class HydrationLatch extends NStateLatch {
+ MessageExchangeDAO createMessageExchange(String mexId, final char dir) {
+ if (isInMemory()) {
+ return _inMemDao.getConnection().createMessageExchange(mexId, dir);
+ } else {
+ return _contexts.dao.getConnection().createMessageExchange(mexId, dir);
+ }
+ }
+
+ MessageExchangeDAO getInMemMexDAO(String mexId) {
+ return _inMemDao.getConnection().getMessageExchange(mexId);
+ }
+
+ /**
+ * Schedule process-level work. This method defers to the server to do the scheduling and wraps the {@link Runnable} in a
+ * try-finally block that ensures that the process is hydrated.
+ *
+ * @param runnable
+ */
+ void scheduleRunnable(final Runnable runnable) {
+ if (__log.isDebugEnabled())
+ __log.debug("schedulingRunnable for process " + _pid + ": " + runnable);
+
+ _server.scheduleRunnable(new ProcessRunnable(runnable));
+ }
+
+ void enqueueRunnable(BpelInstanceWorker worker) {
+ if (__log.isDebugEnabled())
+ __log.debug("enqueuRunnable for process " + _pid + ": " + worker);
+
+ _server.enqueueRunnable(new ProcessRunnable(worker));
+ }
+
+ MyRoleMessageExchange createNewMyRoleMex(final InvocationStyle istyle, final QName targetService, final String operation,
+ final String clientKey) {
+
+ final String mexId = new GUID().toString();
+ _hydrationLatch.latch(1);
+ try {
+
+ final PartnerLinkMyRoleImpl target = getPartnerLinkForService(targetService);
+ if (target == null)
+ throw new BpelEngineException("NoSuchService: " + targetService);
+ final Operation op = target._plinkDef.getMyRoleOperation(operation);
+ if (op == null)
+ throw new BpelEngineException("NoSuchOperation: " + operation);
+
+ return newMyRoleMex(istyle, mexId, target._endpoint.serviceName, target._plinkDef, op);
+
+ } finally {
+ _hydrationLatch.release(1);
+ }
+ }
+
+ void onMyRoleMexAck(MessageExchangeDAO mexdao, Status old) {
+
+ if (mexdao.getPipedMessageExchangeId() != null) /* p2p */{
+
+ BpelProcess caller = _server.getBpelProcess(mexdao.getPipedPID());
+ if (caller == null) {
+ // process no longer deployed....
+
+ return;
+ }
+
+ MessageExchangeDAO pmex = caller.loadMexDao(mexdao.getPipedMessageExchangeId());
+ if (pmex == null) {
+ // Mex no longer there.... odd..
+
+ return;
+ }
+
+ // Need to copy the response and state from myrolemex --> partnerrolemex
+
+ boolean compat = !(caller.isInMemory() ^ isInMemory());
+ if (compat) {
+ // both processes are in-mem or both are persisted, can share the message
+ pmex.setResponse(mexdao.getResponse());
+ } else /* one process in-mem, other persisted */{
+
+ MessageDAO presponse = pmex.createMessage(mexdao.getResponse().getType());
+ presponse.setData(mexdao.getResponse().getData());
+ pmex.setResponse(presponse);
+ }
+ pmex.setStatus(mexdao.getStatus());
+ pmex.setAckType(mexdao.getAckType());
+ pmex.setFailureType(mexdao.getFailureType());
+
+ if (old == Status.ASYNC)
+ caller.p2pWakeup(pmex);
+
+ } else /* not p2p */{
+ // Do an Async wakeup if we are in the ASYNC state. If we're not, we'll pick up the ACK when we unwind
+ // the stack.
+ if (old == Status.ASYNC) {
+ MyRoleMessageExchangeImpl mymex = _myRoleMexCache.get(mexdao);
+ mymex.onAsyncAck(mexdao);
+
+ try {
+ _contexts.mexContext.onMyRoleMessageExchangeStateChanged(mymex);
+ } catch (Throwable t) {
+ __log.error("Integration layer threw an unexepcted exception.", t);
+ }
+ }
+
+ }
+
+ }
+
+ class ProcessRunnable implements Runnable {
+ Runnable _work;
+
+ ProcessRunnable(Runnable work) {
+ _work = work;
+ }
+
+ public void run() {
+ _hydrationLatch.latch(1);
+ try {
+ _work.run();
+ } finally {
+ _hydrationLatch.release(1);
+ }
+
+ }
+
+ }
+
+ class ProcessCallable<T> implements Callable<T> {
+ Callable<T> _work;
+
+ ProcessCallable(Callable<T> work) {
+ _work = work;
+ }
+
+ public T call() throws Exception {
+ _hydrationLatch.latch(1);
+ try {
+ return _work.call();
+ } finally {
+ _hydrationLatch.release(1);
+ }
+
+ }
+
+ }
+
+ class HydrationLatch extends NStateLatch {
HydrationLatch() {
super(new Runnable[2]);
@@ -708,7 +1177,7 @@
if (!_hydratedOnce) {
for (PartnerLinkPartnerRoleImpl prole : _partnerRoles.values()) {
- PartnerRoleChannel channel = _engine._contexts.bindingContext.createPartnerRoleChannel(_pid,
+ PartnerRoleChannel channel = _contexts.bindingContext.createPartnerRoleChannel(_pid,
prole._plinkDef.partnerRolePortType, prole._initialPartner);
prole._channel = channel;
_partnerChannels.put(prole._initialPartner, prole._channel);
@@ -734,21 +1203,20 @@
}
}
-
if (isInMemory()) {
- bounceProcessDAO(_engine._contexts.inMemDao.getConnection(), _pid, _pconf.getVersion(), _oprocess);
- } else if (_engine._contexts.scheduler.isTransacted()) {
+ bounceProcessDAO(_inMemDao.getConnection(), _pid, _pconf.getVersion(), _oprocess);
+ } else if (_contexts.isTransacted()) {
// If we have a transaction, we do this in the current transaction.
- bounceProcessDAO(_engine._contexts.dao.getConnection(), _pid, _pconf.getVersion(), _oprocess);
+ bounceProcessDAO(_contexts.dao.getConnection(), _pid, _pconf.getVersion(), _oprocess);
} else {
- // If we do not have a transaction we need to create one.
+ // If we do not have a transaction we need to create one.
try {
- _engine._contexts.scheduler.execIsolatedTransaction(new Callable<Object>() {
+ _contexts.execTransaction(new Callable<Object>() {
public Object call() throws Exception {
- bounceProcessDAO(_engine._contexts.dao.getConnection(), _pid, _pconf.getVersion(), _oprocess);
+ bounceProcessDAO(_contexts.dao.getConnection(), _pid, _pconf.getVersion(), _oprocess);
return null;
}
- }).get(); // needs to be synchronous
+ });
} catch (Exception ex) {
String errmsg = "DbError";
__log.error(errmsg, ex);
@@ -758,4 +1226,125 @@
}
}
-}
+
+ public void scheduleWorkEvent(WorkEvent we, Date timeToFire) {
+ // if (isInMemory())
+ // throw new InvalidProcessException("In-mem process execution resulted in event scheduling.");
+
+ _contexts.scheduler.schedulePersistedJob(we.getDetail(), timeToFire);
+ }
+
+ void invokePartner(MessageExchangeDAO mexdao) {
+ OPartnerLink oplink = (OPartnerLink) _oprocess.getChild(mexdao.getPartnerLinkModelId());
+ PartnerLinkPartnerRoleImpl partnerRole = _partnerRoles.get(oplink);
+ Endpoint partnerEndpoint = getInitialPartnerRoleEndpoint(oplink);
+ BpelProcess p2pProcess = null;
+ if (partnerEndpoint != null)
+ p2pProcess = _server.route(partnerEndpoint.serviceName, new DbBackedMessageImpl(mexdao.getRequest()));
+
+ Operation operation = oplink.getPartnerRoleOperation(mexdao.getOperation());
+
+ if (!processInterceptors(mexdao, InterceptorInvoker.__onPartnerInvoked)) {
+ __log.debug("Partner invocation intercepted.");
+ return;
+ }
+
+ try {
+ if (p2pProcess != null) {
+ /* P2P (process-to-process) invocation, special logic */
+ invokeP2P(p2pProcess, partnerEndpoint.serviceName, operation, mexdao);
+ } else {
+ partnerRole.invokeIL(mexdao);
+ }
+ } finally {
+ if (mexdao.getStatus() != Status.ACK)
+ mexdao.setStatus(Status.ASYNC);
+
+ }
+
+ assert mexdao.getStatus() == Status.ACK || mexdao.getStatus() == Status.ASYNC;
+
+ }
+
+ /**
+ * Invoke a partner process directly (via the engine), bypassing the Integration Layer. Obviously this can only be used when an
+ * process is partners with another process hosted on the same engine.
+ *
+ * @param operation
+ * @param outgoingMessage
+ * @param partnerRoleMex
+ */
+ private void invokeP2P(BpelProcess target, QName serviceName, Operation operation, MessageExchangeDAO partnerRoleMex) {
+ if (BpelProcess.__log.isDebugEnabled()) {
+ __log
+ .debug("Invoking in a p2p interaction, partnerrole " + partnerRoleMex.getMessageExchangeId() + " target="
+ + target);
+ }
+
+ partnerRoleMex.setInvocationStyle(InvocationStyle.P2P);
+
+ MessageExchangeDAO myRoleMex = target.createMessageExchange(new GUID().toString(),
+ MessageExchangeDAO.DIR_PARTNER_INVOKES_MYROLE);
+ myRoleMex.setStatus(Status.REQ);
+ myRoleMex.setCallee(serviceName);
+
+ myRoleMex.setOperation(partnerRoleMex.getOperation());
+ myRoleMex.setPattern(partnerRoleMex.getPattern());
+ myRoleMex.setTimeout(partnerRoleMex.getTimeout());
+ myRoleMex.setRequest(partnerRoleMex.getRequest());
+ myRoleMex.setInvocationStyle(partnerRoleMex.getInvocationStyle());
+
+ // Piped cross-references.
+ myRoleMex.setPipedMessageExchangeId(partnerRoleMex.getMessageExchangeId());
+ myRoleMex.setPipedPID(getPID());
+ partnerRoleMex.setPipedPID(target.getPID());
+ partnerRoleMex.setPipedMessageExchangeId(myRoleMex.getMessageExchangeId());
+
+ // Properties used by stateful-exchange protocol.
+ String mySessionId = partnerRoleMex.getPartnerLink().getMySessionId();
+ String partnerSessionId = partnerRoleMex.getPartnerLink().getPartnerSessionId();
+
+ if (BpelProcess.__log.isDebugEnabled()) {
+ __log.debug("Setting myRoleMex session ids for p2p interaction, mySession " + partnerSessionId + " - partnerSess "
+ + mySessionId);
+ }
+
+ if (mySessionId != null)
+ partnerRoleMex.setProperty(MessageExchange.PROPERTY_SEP_MYROLE_SESSIONID, mySessionId);
+ if (partnerSessionId != null)
+ partnerRoleMex.setProperty(MessageExchange.PROPERTY_SEP_PARTNERROLE_SESSIONID, partnerSessionId);
+
+ if (partnerSessionId != null)
+ myRoleMex.setProperty(MessageExchange.PROPERTY_SEP_MYROLE_SESSIONID, partnerSessionId);
+ if (mySessionId != null)
+ myRoleMex.setProperty(MessageExchange.PROPERTY_SEP_PARTNERROLE_SESSIONID, mySessionId);
+
+ if (__log.isDebugEnabled())
+ __log.debug("INVOKE PARTNER (SEP): sessionId=" + mySessionId + " partnerSessionId=" + partnerSessionId);
+
+ target.invokeProcess(myRoleMex);
+
+ }
+
+ /**
+ * Handle in-line P2P responses. Called from the child's transaction.
+ *
+ * @param myrolemex
+ */
+ private void p2pWakeup(final MessageExchangeDAO prolemex) {
+
+ try {
+ doInstanceWork(prolemex.getInstance().getInstanceId(), new Callable<Void>() {
+
+ public Void call() throws Exception {
+ executeContinueInstancePartnerRoleResponseReceived(prolemex);
+ return null;
+ }
+
+ });
+ } catch (Exception ex) {
+ throw new BpelEngineException(ex);
+ }
+ }
+
+}
\ No newline at end of file
Modified: ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelProcessDatabase.java
URL: http://svn.apache.org/viewvc/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelProcessDatabase.java?rev=573153&r1=573152&r2=573153&view=diff
==============================================================================
--- ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelProcessDatabase.java (original)
+++ ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelProcessDatabase.java Wed Sep 5 22:46:42 2007
@@ -18,53 +18,53 @@
*/
package org.apache.ode.bpel.engine;
-import org.apache.ode.bpel.dao.BpelDAOConnectionFactory;
-import org.apache.ode.bpel.dao.ProcessDAO;
-import org.apache.ode.bpel.iapi.Scheduler;
-
import javax.xml.namespace.QName;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.apache.ode.bpel.dao.BpelDAOConnectionFactory;
+import org.apache.ode.bpel.dao.ProcessDAO;
/**
* Encapusulates access to a BPEL process database.
*/
class BpelProcessDatabase extends BpelDatabase {
- static Log __log = LogFactory.getLog(BpelProcessDatabase.class);
+ static Log __log = LogFactory.getLog(BpelProcessDatabase.class);
+
+ private QName _processId;
+
+ /**
+ * Constructor.
+ *
+ * @param sscf
+ * BPEL state store connection factory
+ * @param txm
+ * JTA transaction manager
+ * @param processId
+ * name of the process
+ */
+ BpelProcessDatabase(Contexts contexts, QName processId) {
+ super(contexts);
+ _processId = processId;
+ }
+
+ QName getProcessId() {
+ return _processId;
+ }
- private QName _processId;
+ ProcessDAO getProcessDAO() {
+ return getConnection().getProcess(_processId);
- /**
- * Constructor.
- * @param sscf BPEL state store connection factory
- * @param txm JTA transaction manager
- * @param processId name of the process
- */
- BpelProcessDatabase(BpelDAOConnectionFactory sscf,
- Scheduler scheduler,
- QName processId) {
- super(sscf,scheduler);
- _processId = processId;
- }
-
- QName getProcessId() {
- return _processId;
- }
-
- ProcessDAO getProcessDAO() {
- return getConnection().getProcess(_processId);
-
- }
-
- abstract class Callable<T> implements BpelDatabase.Callable<T> {
- public T exec() throws Exception {
- return BpelProcessDatabase.this.exec(this);
}
- protected ProcessDAO getProcessDAO() {
- return BpelProcessDatabase.this.getProcessDAO();
+ abstract class Callable<T> implements BpelDatabase.Callable<T> {
+ public T exec() throws Exception {
+ return BpelProcessDatabase.this.exec(this);
+ }
+
+ protected ProcessDAO getProcessDAO() {
+ return BpelProcessDatabase.this.getProcessDAO();
+ }
}
- }
}