ode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mszef...@apache.org
Subject svn commit: r550908 - /incubator/ode/branches/bart/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/MyRoleMessageExchangeImpl.java
Date Tue, 26 Jun 2007 18:44:47 GMT
Author: mszefler
Date: Tue Jun 26 11:44:46 2007
New Revision: 550908

URL: http://svn.apache.org/viewvc?view=rev&rev=550908
Log:
BART

Added:
    incubator/ode/branches/bart/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/MyRoleMessageExchangeImpl.java
  (with props)

Added: incubator/ode/branches/bart/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/MyRoleMessageExchangeImpl.java
URL: http://svn.apache.org/viewvc/incubator/ode/branches/bart/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/MyRoleMessageExchangeImpl.java?view=auto&rev=550908
==============================================================================
--- incubator/ode/branches/bart/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/MyRoleMessageExchangeImpl.java
(added)
+++ incubator/ode/branches/bart/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/MyRoleMessageExchangeImpl.java
Tue Jun 26 11:44:46 2007
@@ -0,0 +1,172 @@
+package org.apache.ode.bpel.engine;
+
+import java.util.concurrent.Future;
+import java.util.concurrent.TimeoutException;
+
+import javax.xml.namespace.QName;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.ode.bpel.dao.MessageDAO;
+import org.apache.ode.bpel.dao.MessageExchangeDAO;
+import org.apache.ode.bpel.iapi.BpelEngineException;
+import org.apache.ode.bpel.iapi.Message;
+import org.apache.ode.bpel.iapi.MessageExchange;
+import org.apache.ode.bpel.iapi.MyRoleMessageExchange;
+import org.apache.ode.bpel.iapi.MessageExchange.Status;
+import org.apache.ode.bpel.intercept.AbortMessageExchangeException;
+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.intercept.MessageExchangeInterceptor.InterceptorContext;
+
+class MyRoleMessageExchangeImpl extends MessageExchangeImpl implements MyRoleMessageExchange
{
+
+    private static final Log __log = LogFactory.getLog(MyRoleMessageExchangeImpl.class);
+    
+    protected CorrelationStatus _cstatus;
+
+    protected String _clientId;
+
+    protected QName _callee;
+
+    public MyRoleMessageExchangeImpl(BpelEngineImpl engine, String mexId) {
+        super(engine, mexId);
+    }
+
+    public CorrelationStatus getCorrelationStatus() {
+        return _cstatus;
+    }
+
+    @Override
+    void load(MessageExchangeDAO dao) {
+        super.load(dao);
+        if (_cstatus == null)
+            _cstatus = CorrelationStatus.valueOf(dao.getCorrelationStatus());
+        if (_clientId == null)
+            _clientId = dao.getCorrelationId();
+        if (_callee == null)
+            _callee = dao.getCallee();
+    }
+
+    @Override
+    public void save(MessageExchangeDAO dao) {
+        super.save(dao);
+        dao.setCorrelationStatus(_cstatus.toString());
+        dao.setCorrelationId(_clientId);
+    }
+
+    public String getClientId() {
+        return _clientId;
+    }
+
+    public Future<Status> invokeAsync() {
+        throw new BpelEngineException("Unsupported InvocationStyle");
+    }
+
+    public Status invokeBlocking() throws BpelEngineException, TimeoutException {
+        throw new BpelEngineException("Unsupported InvocationStyle");
+    }
+
+    public void invokeReliable() {
+        throw new BpelEngineException("Unsupported InvocationStyle");
+
+    }
+
+    public Status invokeTransacted() throws BpelEngineException {
+        throw new BpelEngineException("Unsupported InvocationStyle");
+    }
+
+    public void setRequest(final Message request) {
+        _request = (MessageImpl) request;
+        _changes.add(Change.REQUEST);
+    }
+
+    public QName getServiceName() {
+        return _callee;
+    }
+
+    public String toString() {
+        try {
+            return "{MyRoleMex#" + _mexId + " [Client " + _clientId + "] calling " + _callee
+ "." + _opname + "(...)}";
+        } catch (Throwable t) {
+            return "{MyRoleMex#???}";
+        }
+    }
+
+    public void complete() {
+        // TODO Auto-generated method stub
+
+    }
+
+    protected void scheduleInvoke(BpelProcess target) {
+        // Schedule a new job for invocation
+        final WorkEvent we = new WorkEvent();
+        we.setType(WorkEvent.Type.INVOKE_INTERNAL);
+        we.setInMem(target.isInMemory());
+        we.setProcessId(target.getPID());
+        we.setMexId(_mexId);
+
+        // Schedule a timeout 
+        final WorkEvent we1 = new WorkEvent();
+        we1.setType(WorkEvent.Type.INVOKE_TIMEOUT);
+        we1.setInMem(target.isInMemory());
+        we1.setProcessId(target.getPID());
+        we1.setMexId(_mexId);
+        
+        setStatus(Status.ASYNC);
+        if (target.isInMemory()) {
+            _engine._contexts.scheduler.scheduleVolatileJob(true, we.getDetail());
+            _engine._contexts.scheduler.scheduleVolatileJob(true, we1.getDetail());
+        } else {
+            doInTX(new InDbAction<Void>() {
+
+                public Void call(MessageExchangeDAO mexdao) {
+                    _engine._contexts.scheduler.schedulePersistedJob(we.getDetail(), null);
+                    _engine._contexts.scheduler.schedulePersistedJob(we1.getDetail(), null);
+                    return null;
+                }
+
+            });
+
+        }
+    }
+    
+
+    /**
+     * Process the message-exchange interceptors.
+     * 
+     * @param mex
+     *            message exchange
+     * @return <code>true</code> if execution should continue, <code>false</code>
otherwise
+     */
+    protected boolean processInterceptors(InterceptorInvoker invoker, MessageExchangeDAO
mexDao) {
+        InterceptorContextImpl ictx = new InterceptorContextImpl(_engine._contexts.dao.getConnection(),
mexDao.getProcess(), null);
+
+        for (MessageExchangeInterceptor i : _engine.getGlobalInterceptors())
+            if (!processInterceptor(i, this, ictx, invoker))
+                return false;
+
+        return true;
+    }
+
+    protected boolean processInterceptor(MessageExchangeInterceptor i, MyRoleMessageExchangeImpl
mex, InterceptorContext ictx,
+            InterceptorInvoker invoker) {
+        __log.debug(invoker + "--> interceptor " + i);
+        try {
+            invoker.invoke(i, mex, ictx);
+        } catch (FaultMessageExchangeException fme) {
+            __log.debug("interceptor " + i + " caused invoke on " + this + " to be aborted
with FAULT " + fme.getFaultName());
+            mex.setFault(fme.getFaultName(), fme.getFaultData());
+            return false;
+        } catch (AbortMessageExchangeException ame) {
+            __log.debug("interceptor " + i + " cause invoke on " + this + " to be aborted
with FAILURE: " + ame.getMessage());
+            mex.setFailure(MessageExchange.FailureType.ABORTED, __msgs.msgInterceptorAborted(mex.getMessageExchangeId(),
i
+                    .toString(), ame.getMessage()), null);
+            return false;
+        }
+        return true;
+    }
+
+    
+}

Propchange: incubator/ode/branches/bart/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/MyRoleMessageExchangeImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message