Author: heiko.braun(a)jboss.com
Date: 2009-11-05 15:01:06 -0500 (Thu, 05 Nov 2009)
New Revision: 235
Added:
branches/hbraun/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/ws/MessageContextAssoc.java
Modified:
branches/hbraun/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/engine/ode/BPELEngineImpl.java
branches/hbraun/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/engine/ode/JAXWSBindingContext.java
branches/hbraun/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/ws/AbstractWebServiceEndpoint.java
branches/hbraun/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/ws/MessageContext.java
Log:
Introduce outbound MessageContext
Modified:
branches/hbraun/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/engine/ode/BPELEngineImpl.java
===================================================================
---
branches/hbraun/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/engine/ode/BPELEngineImpl.java 2009-11-05
19:01:14 UTC (rev 234)
+++
branches/hbraun/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/engine/ode/BPELEngineImpl.java 2009-11-05
20:01:06 UTC (rev 235)
@@ -42,13 +42,17 @@
import org.jboss.soa.bpel.runtime.engine.BPELFault;
import org.jboss.soa.bpel.runtime.engine.IntegrationLayer;
import org.jboss.soa.bpel.runtime.ws.AbstractWebServiceEndpoint;
+import org.jboss.soa.bpel.runtime.ws.MessageContext;
+import org.jboss.soa.bpel.runtime.ws.MessageContextAssoc;
+import org.jboss.soa.bpel.runtime.ws.SOAPMessageAdapter;
import org.w3c.dom.Element;
import javax.sql.DataSource;
import javax.transaction.*;
import javax.transaction.xa.XAResource;
+import javax.wsdl.Definition;
import javax.xml.namespace.QName;
-import javax.xml.soap.SOAPEnvelope;
+import javax.xml.soap.*;
import java.util.StringTokenizer;
import java.util.concurrent.*;
@@ -65,7 +69,7 @@
protected final Log __logTx = LogFactory.getLog("org.apache.ode.tx");
protected BpelServerImpl _bpelServer;
- protected ProcessStoreImpl _store;
+ public ProcessStoreImpl _store;
protected OdeConfigProperties _odeConfig;
protected TransactionManager _txMgr;
protected BpelDAOConnectionFactory _daoCF;
@@ -107,6 +111,7 @@
boolean success = true;
MyRoleMessageExchange odeMex = null;
Future responseFuture = null;
+ boolean wsInvocation = (message instanceof SOAPEnvelope);
try {
_txMgr.begin();
if (__log.isDebugEnabled()) __log.debug("Starting transaction.");
@@ -123,13 +128,15 @@
//_converter.parseSoapRequest(odeRequest, msgContext.getEnvelope(),
odeMex.getOperation());
// distinguish WS and ESB invocation
- if(message instanceof SOAPEnvelope)
+ if(wsInvocation)
{
- // TODO: Use SOAPMessageAdapter here
+ // TODO: Use SOAPMessageAdapter here
+ //SOAPMessageAdapter soapAdapter = new SOAPMessageAdapter(null,
odeMex.getServiceName(), odeMex.get)
odeRequest.setMessage(AbstractWebServiceEndpoint.getMessagePayload((SOAPEnvelope)message));
}
else
{
+ wsInvocation = false;
odeRequest.setMessage(message);
}
@@ -197,7 +204,7 @@
try {
// Refreshing the message exchange
odeMex = (MyRoleMessageExchange)
_bpelServer.getEngine().getMessageExchange(odeMex.getMessageExchangeId());
- ret = onResponse(odeMex);
+ ret = onResponse(odeMex, wsInvocation);
__log.debug("Returning: "+ret);
@@ -239,7 +246,7 @@
return(ret);
}
- private Element onResponse(MyRoleMessageExchange mex) throws BPELFault, Exception {
+ private Element onResponse(MyRoleMessageExchange mex, boolean wsInvocation) throws
BPELFault, Exception {
Element ret=null;
switch (mex.getStatus()) {
@@ -249,8 +256,24 @@
throw new BPELFault(mex.getFault(), mex.getFaultResponse().getMessage());
case ASYNC:
- case RESPONSE:
- ret = mex.getResponse().getMessage();
+ case RESPONSE:
+ if(wsInvocation)
+ {
+ // create SOAPEnvelope
+ SOAPMessage soapResponse = MessageFactory.newInstance().createMessage();
+ SOAPBody responseBody = soapResponse.getSOAPBody();
+ SOAPFactory soapFactory = SOAPFactory.newInstance();
+ SOAPElement responseElement =
soapFactory.createElement(mex.getResponse().getMessage());
+ responseBody.appendChild(responseElement);
+ ret = soapResponse.getSOAPPart().getEnvelope();
+
+ MessageContextAssoc.createOutbound().setMessage(soapResponse);
+ }
+ else
+ {
+ // ESB response
+ ret = mex.getResponse().getMessage();
+ }
if (__log.isDebugEnabled())
__log.debug("Response message " + ret);
break;
Modified:
branches/hbraun/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/engine/ode/JAXWSBindingContext.java
===================================================================
---
branches/hbraun/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/engine/ode/JAXWSBindingContext.java 2009-11-05
19:01:14 UTC (rev 234)
+++
branches/hbraun/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/engine/ode/JAXWSBindingContext.java 2009-11-05
20:01:06 UTC (rev 235)
@@ -27,14 +27,12 @@
import org.jboss.soa.bpel.runtime.ws.WSDLReference;
import javax.wsdl.Definition;
-import javax.wsdl.Import;
import javax.wsdl.PortType;
import javax.wsdl.factory.WSDLFactory;
import javax.wsdl.xml.WSDLReader;
import javax.xml.namespace.QName;
import java.io.File;
import java.net.URL;
-import java.util.Iterator;
import java.util.List;
import java.util.UUID;
@@ -48,12 +46,12 @@
{
protected final Log log = LogFactory.getLog(getClass());
- private BPELEngineImpl server;
+ private BPELEngineImpl engine;
private EndpointManager endpointManager;
public JAXWSBindingContext(BPELEngineImpl server) {
- this.server = server;
- this.endpointManager = new EndpointManager(this.server);
+ this.engine = server;
+ this.endpointManager = new EndpointManager(this.engine);
}
public org.apache.ode.bpel.iapi.EndpointReference activateMyRoleEndpoint(QName
processId, Endpoint myRoleEndpoint)
@@ -65,7 +63,7 @@
if(ref!=null)
{
- // might happend when processes are retired.
+ // might happen when processes are retired.
// See
https://jira.jboss.org/jira/browse/RIFTSAW-57
log.warn("Endpoint does already exist: "
+ myRoleEndpoint.serviceName + "/"+myRoleEndpoint.portName);
@@ -105,7 +103,7 @@
private File findWSDLFile(QName processId, Endpoint myRoleEndpoint)
{
- ProcessConf pconf = server._store.getProcessConfiguration(processId);
+ ProcessConf pconf = engine._store.getProcessConfiguration(processId);
List<File> files = pconf.getFiles();
File targetWsdlFile = null;
for(File f : files)
@@ -133,7 +131,7 @@
}
if(null==targetWsdlFile)
- throw new ContextException("Unable to find target WDL file for "+
myRoleEndpoint);
+ throw new ContextException("Unable to find target WSDL file for "+
myRoleEndpoint);
return targetWsdlFile;
}
@@ -185,7 +183,7 @@
private Definition getWSDLDefinition(QName processId, QName serviceName)
{
- ProcessConf pconf = server._store.getProcessConfiguration(processId);
+ ProcessConf pconf = engine._store.getProcessConfiguration(processId);
Definition wsdl = pconf.getDefinitionForService(serviceName);
if (wsdl == null)
throw new ContextException("Unable to access WSDL definition to activate
MyRole endpoint for service " + serviceName
Modified:
branches/hbraun/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/ws/AbstractWebServiceEndpoint.java
===================================================================
---
branches/hbraun/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/ws/AbstractWebServiceEndpoint.java 2009-11-05
19:01:14 UTC (rev 234)
+++
branches/hbraun/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/ws/AbstractWebServiceEndpoint.java 2009-11-05
20:01:06 UTC (rev 235)
@@ -26,7 +26,6 @@
import org.apache.commons.logging.LogFactory;
import org.apache.ode.utils.DOMUtils;
import org.jboss.soa.bpel.runtime.engine.BPELEngine;
-import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
@@ -34,11 +33,7 @@
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.wsdl.Definition;
-import javax.wsdl.factory.WSDLFactory;
-import javax.wsdl.xml.WSDLReader;
import javax.xml.namespace.QName;
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.soap.*;
import javax.xml.ws.Provider;
@@ -118,20 +113,24 @@
if(log.isDebugEnabled())
log.debug( "ODE outbound message: \n" +DOMWriter.printNode(odeResponse,
true) );
- SOAPMessage soapResponse = MessageFactory.newInstance().createMessage();
- soapResponse.getSOAPPart().appendChild(odeResponse);
-
+ if(null==MessageContextAssoc.getOutbound())
+ throw new IllegalArgumentException("No outbound MessageContext");
+
/* SOAPBody responseBody = soapResponse.getSOAPBody();
SOAPFactory soapFactory = SOAPFactory.newInstance();
SOAPElement responseElement = soapFactory.createElement(odeResponse);
responseBody.appendChild(responseElement);*/
-
- return soapResponse;
+ SOAPMessage responseMessage = MessageContextAssoc.getOutbound().getMessage();
+ return responseMessage;
}
catch (Exception e)
{
throw new RuntimeException("Failed to invoke BPEL process", e);
}
+ finally
+ {
+ MessageContextAssoc.clearAll();
+ }
}
Modified:
branches/hbraun/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/ws/MessageContext.java
===================================================================
---
branches/hbraun/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/ws/MessageContext.java 2009-11-05
19:01:14 UTC (rev 234)
+++
branches/hbraun/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/ws/MessageContext.java 2009-11-05
20:01:06 UTC (rev 235)
@@ -21,21 +21,13 @@
*/
package org.jboss.soa.bpel.runtime.ws;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-
import javax.xml.soap.SOAPMessage;
-import java.util.HashMap;
-import java.util.Map;
/**
* @author Heiko Braun <hbraun(a)redhat.com>
*/
public class MessageContext
-{
- private static ThreadLocal<MessageContext> inbound;
- private static ThreadLocal<MessageContext> outbound;
-
+{
private SOAPMessage message;
protected MessageContext()
@@ -51,24 +43,4 @@
{
return message;
}
-
- public static MessageContext getInbound()
- {
- if(inbound.get()==null)
- inbound.set(new MessageContext());
- return inbound.get();
- }
-
- public static MessageContext getOutbound()
- {
- if(outbound.get()==null)
- outbound.set(new MessageContext());
- return outbound.get();
- }
-
- public static void clearAll()
- {
- inbound.set(null);
- outbound.set(null);
- }
}
Added:
branches/hbraun/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/ws/MessageContextAssoc.java
===================================================================
---
branches/hbraun/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/ws/MessageContextAssoc.java
(rev 0)
+++
branches/hbraun/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/ws/MessageContextAssoc.java 2009-11-05
20:01:06 UTC (rev 235)
@@ -0,0 +1,63 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.soa.bpel.runtime.ws;
+
+/**
+ * @author Heiko Braun <hbraun(a)redhat.com>
+ */
+public class MessageContextAssoc
+{
+ private static ThreadLocal<MessageContext> inbound = new
ThreadLocal<MessageContext>();
+ private static ThreadLocal<MessageContext> outbound = new
ThreadLocal<MessageContext>();
+
+ public static MessageContext createInbound()
+ {
+ if(inbound.get()!=null)
+ throw new IllegalStateException("inbound MessageContext already
exists");
+ inbound.set(new MessageContext());
+ return inbound.get();
+ }
+
+ public static MessageContext createOutbound()
+ {
+ if(outbound.get()!=null)
+ throw new IllegalStateException("outbound MessageContext already
exists");
+ outbound.set(new MessageContext());
+ return outbound.get();
+ }
+
+ public static MessageContext getInbound()
+ {
+ return inbound.get();
+ }
+
+ public static MessageContext getOutbound()
+ {
+ return outbound.get();
+ }
+
+ public static void clearAll()
+ {
+ inbound.set(null);
+ outbound.set(null);
+ }
+}