Author: mriou
Date: Wed Jul 5 17:10:37 2006
New Revision: 419390
URL: http://svn.apache.org/viewvc?rev=419390&view=rev
Log:
Implemented invocation of external services using Axis2. More testing is needed
but that's a good start.
Added:
incubator/ode/scratch/pxe-iapi/axis/src/main/java/com/fs/pxe/axis/AxisInvoker.java
incubator/ode/scratch/pxe-iapi/axis/src/main/java/com/fs/pxe/axis/MessageExchangeContextImpl.java
incubator/ode/scratch/pxe-iapi/axis/src/main/java/com/fs/pxe/axis/OMUtils.java
incubator/ode/scratch/pxe-iapi/axis/src/main/java/com/fs/pxe/axis/epr/
incubator/ode/scratch/pxe-iapi/axis/src/main/java/com/fs/pxe/axis/epr/EndpointFactory.java
incubator/ode/scratch/pxe-iapi/axis/src/main/java/com/fs/pxe/axis/epr/MutableEndpoint.java
incubator/ode/scratch/pxe-iapi/axis/src/main/java/com/fs/pxe/axis/epr/URLEndpoint.java
incubator/ode/scratch/pxe-iapi/axis/src/main/java/com/fs/pxe/axis/epr/WSAEndpoint.java
incubator/ode/scratch/pxe-iapi/axis/src/main/java/com/fs/pxe/axis/epr/WSDL11Endpoint.java
incubator/ode/scratch/pxe-iapi/axis/src/main/java/com/fs/pxe/axis/epr/WSDL20Endpoint.java
incubator/ode/scratch/pxe-iapi/axis/src/main/java/com/fs/pxe/axis/hooks/PXEAxisDispatcher.java
Modified:
incubator/ode/scratch/pxe-iapi/axis/src/main/java/com/fs/pxe/axis/DeploymentPoller.java
incubator/ode/scratch/pxe-iapi/axis/src/main/java/com/fs/pxe/axis/DeploymentUnit.java
incubator/ode/scratch/pxe-iapi/axis/src/main/java/com/fs/pxe/axis/DocumentRegistry.java
incubator/ode/scratch/pxe-iapi/axis/src/main/java/com/fs/pxe/axis/EndpointReferenceContextImpl.java
incubator/ode/scratch/pxe-iapi/axis/src/main/java/com/fs/pxe/axis/PXEServer.java
incubator/ode/scratch/pxe-iapi/axis/src/main/java/com/fs/pxe/axis/PXEService.java
incubator/ode/scratch/pxe-iapi/bpel-api/src/main/java/com/fs/pxe/bpel/iapi/EndpointReference.java
incubator/ode/scratch/pxe-iapi/bpel-runtime/src/main/java/com/fs/pxe/bpel/engine/BpelServerImpl.java
Added:
incubator/ode/scratch/pxe-iapi/axis/src/main/java/com/fs/pxe/axis/AxisInvoker.java
URL:
http://svn.apache.org/viewvc/incubator/ode/scratch/pxe-iapi/axis/src/main/java/com/fs/pxe/axis/AxisInvoker.java?rev=419390&view=auto
==============================================================================
---
incubator/ode/scratch/pxe-iapi/axis/src/main/java/com/fs/pxe/axis/AxisInvoker.java
(added)
+++
incubator/ode/scratch/pxe-iapi/axis/src/main/java/com/fs/pxe/axis/AxisInvoker.java
Wed Jul 5 17:10:37 2006
@@ -0,0 +1,98 @@
+package com.fs.pxe.axis;
+
+import com.fs.pxe.axis.epr.MutableEndpoint;
+import com.fs.pxe.bpel.iapi.Message;
+import com.fs.pxe.bpel.iapi.MessageExchange;
+import com.fs.pxe.bpel.iapi.PartnerRoleMessageExchange;
+import com.fs.pxe.bpel.scheduler.quartz.QuartzSchedulerImpl;
+import org.apache.axiom.om.OMElement;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.addressing.EndpointReference;
+import org.apache.axis2.client.Options;
+import org.apache.axis2.client.ServiceClient;
+import org.apache.axis2.client.async.AsyncResult;
+import org.apache.axis2.client.async.Callback;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.util.concurrent.Callable;
+
+/**
+ * Invoke external services using Axis2 and eventually gets the service
+ * reply.
+ */
+public class AxisInvoker {
+
+ private static final Log __log = LogFactory.getLog(AxisInvoker.class);
+
+ private QuartzSchedulerImpl _scheduler;
+
+ public AxisInvoker(QuartzSchedulerImpl scheduler) {
+ _scheduler = scheduler;
+ }
+
+ public void invokePartner(PartnerRoleMessageExchange pxeMex) {
+ boolean isTwoWay = pxeMex.getMessageExchangePattern() ==
+
com.fs.pxe.bpel.iapi.MessageExchange.MessageExchangePattern.REQUEST_RESPONSE;
+ try {
+ OMElement payload = OMUtils.toOM(pxeMex.getRequest().getMessage());
+
+ Options options = new Options();
+ EndpointReference axisEPR = new
EndpointReference(((MutableEndpoint)pxeMex.getEndpointReference()).getUrl());
+ options.setTo(axisEPR);
+
+ ServiceClient serviceClient = new ServiceClient();
+ serviceClient.setOptions(options);
+
+ if (isTwoWay)
+ serviceClient.sendReceiveNonBlocking(payload, new
AxisResponseCallback(pxeMex));
+ else
+ serviceClient.sendRobust(payload);
+ } catch (AxisFault axisFault) {
+ String errmsg = "Error sending message to Axis2 for PXE mex " + pxeMex;
+ __log.error(errmsg, axisFault);
+ pxeMex.replyWithFailure(MessageExchange.FailureType.COMMUNICATION_ERROR,
errmsg, null);
+ }
+ }
+
+ private class AxisResponseCallback extends Callback {
+
+ private PartnerRoleMessageExchange _pxeMex;
+
+ public AxisResponseCallback(PartnerRoleMessageExchange pxeMex) {
+ _pxeMex = pxeMex;
+ }
+
+ public void onComplete(AsyncResult asyncResult) {
+ final Message response =
_pxeMex.createMessage(_pxeMex.getOperation().getOutput().getMessage().getQName());
+ try {
+
response.setMessage(OMUtils.toDOM(asyncResult.getResponseEnvelope().getBody()));
+ _scheduler.execTransaction(new Callable<Object>() {
+ public Object call() throws Exception {
+ _pxeMex.reply(response);
+ return null;
+ }
+ });
+ } catch (AxisFault axisFault) {
+ __log.error("Error translating message.", axisFault);
+ _pxeMex.replyWithFailure(MessageExchange.FailureType.FORMAT_ERROR,
axisFault.getMessage(), null);
+ } catch (Exception e) {
+ __log.error("Error delivering response.", e);
+ }
+ }
+
+ public void onError(final Exception exception) {
+ try {
+ _scheduler.execTransaction(new Callable<Object>() {
+ public Object call() throws Exception {
+ _pxeMex.replyWithFailure(MessageExchange.FailureType.OTHER,
+ "Error received from invoked service: " +
exception.toString(), null);
+ return null;
+ }
+ });
+ } catch (Exception e) {
+ __log.error("Error delivering failure.", e);
+ }
+ }
+ }
+}
Modified:
incubator/ode/scratch/pxe-iapi/axis/src/main/java/com/fs/pxe/axis/DeploymentPoller.java
URL:
http://svn.apache.org/viewvc/incubator/ode/scratch/pxe-iapi/axis/src/main/java/com/fs/pxe/axis/DeploymentPoller.java?rev=419390&r1=419389&r2=419390&view=diff
==============================================================================
---
incubator/ode/scratch/pxe-iapi/axis/src/main/java/com/fs/pxe/axis/DeploymentPoller.java
(original)
+++
incubator/ode/scratch/pxe-iapi/axis/src/main/java/com/fs/pxe/axis/DeploymentPoller.java
Wed Jul 5 17:10:37 2006
@@ -69,9 +69,13 @@
// Checking for new deployment directories
for (File file : files) {
if (checkIsNew(new File(file, "deploy.xml"))) {
- DeploymentUnit du = new DeploymentUnit(file, _pxeServer);
- _inspectedFiles.add(du);
- du.deploy(!_initDone);
+ try {
+ DeploymentUnit du = new DeploymentUnit(file, _pxeServer);
+ _inspectedFiles.add(du);
+ du.deploy(!_initDone);
+ } catch (Exception e) {
+ __log.error("Deployment of " + file.getName() + " failed, aborting
for now.", e);
+ }
}
}
@@ -125,16 +129,16 @@
}
public void run(){
- try{
- while(_active){
+ try {
+ while(_active) {
check();
synchronized(this){
try{
this.wait(POLL_TIME);
- }catch(InterruptedException e){}
+ } catch(InterruptedException e){}
}
}
- }catch(Throwable t){
+ } catch(Throwable t){
__log.fatal("Encountered an unexpected error. Exiting poller...", t);
}
}
Modified:
incubator/ode/scratch/pxe-iapi/axis/src/main/java/com/fs/pxe/axis/DeploymentUnit.java
URL:
http://svn.apache.org/viewvc/incubator/ode/scratch/pxe-iapi/axis/src/main/java/com/fs/pxe/axis/DeploymentUnit.java?rev=419390&r1=419389&r2=419390&view=diff
==============================================================================
---
incubator/ode/scratch/pxe-iapi/axis/src/main/java/com/fs/pxe/axis/DeploymentUnit.java
(original)
+++
incubator/ode/scratch/pxe-iapi/axis/src/main/java/com/fs/pxe/axis/DeploymentUnit.java
Wed Jul 5 17:10:37 2006
@@ -13,7 +13,11 @@
import javax.wsdl.WSDLException;
import javax.wsdl.xml.WSDLReader;
import javax.xml.namespace.QName;
-import java.io.*;
+import java.io.File;
+import java.io.FileFilter;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
import java.util.HashMap;
/**
Modified:
incubator/ode/scratch/pxe-iapi/axis/src/main/java/com/fs/pxe/axis/DocumentRegistry.java
URL:
http://svn.apache.org/viewvc/incubator/ode/scratch/pxe-iapi/axis/src/main/java/com/fs/pxe/axis/DocumentRegistry.java?rev=419390&r1=419389&r2=419390&view=diff
==============================================================================
---
incubator/ode/scratch/pxe-iapi/axis/src/main/java/com/fs/pxe/axis/DocumentRegistry.java
(original)
+++
incubator/ode/scratch/pxe-iapi/axis/src/main/java/com/fs/pxe/axis/DocumentRegistry.java
Wed Jul 5 17:10:37 2006
@@ -5,7 +5,11 @@
*/
package com.fs.pxe.axis;
-import com.fs.pxe.bom.wsdl.*;
+import com.fs.pxe.bom.wsdl.Definition4BPEL;
+import com.fs.pxe.bom.wsdl.PartnerLinkType;
+import com.fs.pxe.bom.wsdl.Property;
+import com.fs.pxe.bom.wsdl.PropertyAlias;
+import com.fs.pxe.bom.wsdl.XMLSchemaType;
import com.fs.pxe.bpel.capi.CompilationException;
import com.fs.utils.xsd.SchemaModel;
import com.fs.utils.xsd.SchemaModelImpl;
@@ -23,7 +27,11 @@
import javax.xml.namespace.QName;
import java.net.URI;
import java.net.URISyntaxException;
-import java.util.*;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
/**
Modified:
incubator/ode/scratch/pxe-iapi/axis/src/main/java/com/fs/pxe/axis/EndpointReferenceContextImpl.java
URL:
http://svn.apache.org/viewvc/incubator/ode/scratch/pxe-iapi/axis/src/main/java/com/fs/pxe/axis/EndpointReferenceContextImpl.java?rev=419390&r1=419389&r2=419390&view=diff
==============================================================================
---
incubator/ode/scratch/pxe-iapi/axis/src/main/java/com/fs/pxe/axis/EndpointReferenceContextImpl.java
(original)
+++
incubator/ode/scratch/pxe-iapi/axis/src/main/java/com/fs/pxe/axis/EndpointReferenceContextImpl.java
Wed Jul 5 17:10:37 2006
@@ -1,5 +1,6 @@
package com.fs.pxe.axis;
+import com.fs.pxe.axis.epr.EndpointFactory;
import com.fs.pxe.bpel.iapi.EndpointReference;
import com.fs.pxe.bpel.iapi.EndpointReferenceContext;
import org.w3c.dom.Element;
@@ -9,7 +10,7 @@
public class EndpointReferenceContextImpl implements EndpointReferenceContext {
public EndpointReference resolveEndpointReference(Element element) {
- return null;
+ return EndpointFactory.createEndpoint(element);
}
public EndpointReference activateEndpoint(QName qName, QName qName1, Element
element) {
Added:
incubator/ode/scratch/pxe-iapi/axis/src/main/java/com/fs/pxe/axis/MessageExchangeContextImpl.java
URL:
http://svn.apache.org/viewvc/incubator/ode/scratch/pxe-iapi/axis/src/main/java/com/fs/pxe/axis/MessageExchangeContextImpl.java?rev=419390&view=auto
==============================================================================
---
incubator/ode/scratch/pxe-iapi/axis/src/main/java/com/fs/pxe/axis/MessageExchangeContextImpl.java
(added)
+++
incubator/ode/scratch/pxe-iapi/axis/src/main/java/com/fs/pxe/axis/MessageExchangeContextImpl.java
Wed Jul 5 17:10:37 2006
@@ -0,0 +1,36 @@
+package com.fs.pxe.axis;
+
+import com.fs.pxe.bpel.iapi.BpelEngineException;
+import com.fs.pxe.bpel.iapi.ContextException;
+import com.fs.pxe.bpel.iapi.MessageExchangeContext;
+import com.fs.pxe.bpel.iapi.MyRoleMessageExchange;
+import com.fs.pxe.bpel.iapi.PartnerRoleMessageExchange;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * Implementation of the PXE [EMAIL PROTECTED]
com.fs.pxe.bpel.iapi.MessageExchangeContext}
+ * interface. This class is used by the PXE engine to make invocation of
external
+ * services using Axis.
+ */
+public class MessageExchangeContextImpl implements MessageExchangeContext {
+
+ private static final Log __log =
LogFactory.getLog(MessageExchangeContextImpl.class);
+
+ private PXEServer _server;
+ private AxisInvoker _invoker;
+
+ public MessageExchangeContextImpl(PXEServer server) {
+ _server = server;
+ _invoker = _server.createInvoker();
+ }
+
+ public void invokePartner(PartnerRoleMessageExchange
partnerRoleMessageExchange) throws ContextException {
+ _invoker.invokePartner(partnerRoleMessageExchange);
+ }
+
+ public void onAsyncReply(MyRoleMessageExchange myRoleMessageExchange) throws
BpelEngineException {
+ PXEService service =
_server.getService(myRoleMessageExchange.getServiceName());
+ service.notifyResponse(myRoleMessageExchange);
+ }
+}
Added:
incubator/ode/scratch/pxe-iapi/axis/src/main/java/com/fs/pxe/axis/OMUtils.java
URL:
http://svn.apache.org/viewvc/incubator/ode/scratch/pxe-iapi/axis/src/main/java/com/fs/pxe/axis/OMUtils.java?rev=419390&view=auto
==============================================================================
---
incubator/ode/scratch/pxe-iapi/axis/src/main/java/com/fs/pxe/axis/OMUtils.java
(added)
+++
incubator/ode/scratch/pxe-iapi/axis/src/main/java/com/fs/pxe/axis/OMUtils.java
Wed Jul 5 17:10:37 2006
@@ -0,0 +1,43 @@
+package com.fs.pxe.axis;
+
+import com.fs.utils.DOMUtils;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.impl.builder.StAXOMBuilder;
+import org.apache.axis2.AxisFault;
+import org.w3c.dom.Element;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamReader;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+
+/**
+ * Utility methods to convert from/to AxiOM and DOM.
+ */
+public class OMUtils {
+
+ public static Element toDOM(OMElement element) throws AxisFault {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ try {
+ element.serialize(baos);
+ ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
+ return DOMUtils.parse(bais).getDocumentElement();
+ } catch (Exception e) {
+ throw new AxisFault("Unable to read Axis input messag.e", e);
+ }
+ }
+
+ public static OMElement toOM(Element element) throws AxisFault {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ try {
+ DOMUtils.serialize(element, baos);
+ ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
+ XMLStreamReader parser =
XMLInputFactory.newInstance().createXMLStreamReader(bais);
+ StAXOMBuilder builder = new StAXOMBuilder(parser);
+ return builder.getDocumentElement();
+ } catch (Exception e) {
+ throw new AxisFault("Unable to read Axis input messag.e", e);
+ }
+ }
+
+}
Modified:
incubator/ode/scratch/pxe-iapi/axis/src/main/java/com/fs/pxe/axis/PXEServer.java
URL:
http://svn.apache.org/viewvc/incubator/ode/scratch/pxe-iapi/axis/src/main/java/com/fs/pxe/axis/PXEServer.java?rev=419390&r1=419389&r2=419390&view=diff
==============================================================================
---
incubator/ode/scratch/pxe-iapi/axis/src/main/java/com/fs/pxe/axis/PXEServer.java
(original)
+++
incubator/ode/scratch/pxe-iapi/axis/src/main/java/com/fs/pxe/axis/PXEServer.java
Wed Jul 5 17:10:37 2006
@@ -55,8 +55,6 @@
private static final Log __log = LogFactory.getLog(PXEServer.class);
private static final Messages __msgs = Messages.getMessages(Messages.class);
- private boolean _init = false;
- private boolean _started = false;
private File _appRoot;
private BpelServerImpl _server;
@@ -106,7 +104,6 @@
_poller.start();
__log.info(__msgs.msgPollingStarted(deploymentDir.getAbsolutePath()));
- _started = true;
__log.info(__msgs.msgPxeStarted());
}
@@ -187,6 +184,15 @@
_services.remove(serviceName);
}
+ public PXEService getService(QName serviceName) {
+ return _services.get(serviceName);
+ }
+
+ public AxisInvoker createInvoker() {
+ AxisInvoker invoker = new AxisInvoker(_scheduler);
+ return invoker;
+ }
+
private void initTxMgr() throws ServletException {
try {
_jotm = new Jotm(true, false);
@@ -340,9 +346,6 @@
// we'll do that explcitly
_server.setAutoActivate(false);
- // TODO Provide implementation for these
-// _mexContext = new MessageExchangeContextImpl(_pxe);
-
_executorService = Executors.newCachedThreadPool();
_scheduler = new QuartzSchedulerImpl();
_scheduler.setBpelServer(_server);
@@ -353,8 +356,7 @@
_server.setDaoConnectionFactory(_daoCF);
_server.setEndpointReferenceContext(new EndpointReferenceContextImpl());
- // TODO Set these
-// _server.setMessageExchangeContext(_pxe._mexContext);
+ _server.setMessageExchangeContext(new MessageExchangeContextImpl(this));
_server.setScheduler(_scheduler);
_server.init();
}
Modified:
incubator/ode/scratch/pxe-iapi/axis/src/main/java/com/fs/pxe/axis/PXEService.java
URL:
http://svn.apache.org/viewvc/incubator/ode/scratch/pxe-iapi/axis/src/main/java/com/fs/pxe/axis/PXEService.java?rev=419390&r1=419389&r2=419390&view=diff
==============================================================================
---
incubator/ode/scratch/pxe-iapi/axis/src/main/java/com/fs/pxe/axis/PXEService.java
(original)
+++
incubator/ode/scratch/pxe-iapi/axis/src/main/java/com/fs/pxe/axis/PXEService.java
Wed Jul 5 17:10:37 2006
@@ -2,11 +2,9 @@
import com.fs.pxe.bpel.engine.BpelServerImpl;
import com.fs.pxe.bpel.iapi.Message;
-import com.fs.pxe.bpel.iapi.MessageExchange;
import com.fs.pxe.bpel.iapi.MyRoleMessageExchange;
import com.fs.utils.DOMUtils;
import org.apache.axiom.om.OMElement;
-import org.apache.axiom.om.impl.builder.StAXOMBuilder;
import org.apache.axiom.soap.SOAPEnvelope;
import org.apache.axiom.soap.SOAPFactory;
import org.apache.axis2.AxisFault;
@@ -21,11 +19,10 @@
import javax.transaction.TransactionManager;
import javax.wsdl.Part;
import javax.xml.namespace.QName;
-import javax.xml.stream.XMLInputFactory;
-import javax.xml.stream.XMLStreamReader;
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
+import java.util.Collections;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
/**
* A running service, encapsulates the Axis service, its receivers and
@@ -34,15 +31,18 @@
public class PXEService {
private static final Log __log = LogFactory.getLog(PXEService.class);
+ private static final int TIMEOUT = 2 * 60 * 1000;
private AxisService _axisService;
private BpelServerImpl _server;
private TransactionManager _txManager;
+ private Map<String,ResponseCallback> _waitingCallbacks;
public PXEService(AxisService axisService, BpelServerImpl server,
TransactionManager txManager) {
_axisService = axisService;
_server = server;
_txManager = txManager;
+ _waitingCallbacks = Collections.synchronizedMap(new HashMap<String,
ResponseCallback>());
}
public void onAxisMessageExchange(MessageContext msgContext, MessageContext
outMsgContext,
@@ -62,20 +62,29 @@
Message pxeRequest =
pxeMex.createMessage(pxeMex.getOperation().getInput().getMessage().getQName());
convertMessage(msgdef, pxeRequest,
msgContext.getEnvelope().getBody().getFirstElement());
+ ResponseCallback callback = null;
+ if (pxeMex.getOperation().getOutput() != null) {
+ callback = new ResponseCallback();
+ _waitingCallbacks.put(pxeMex.getMessageExchangeId(), callback);
+ }
+
pxeMex.invoke(pxeRequest);
- // Handle the response if it is immediately available.
- if (pxeMex.getStatus() != MessageExchange.Status.ASYNC &&
outMsgContext != null) {
+ // Handle the response if necessary.
+ if (pxeMex.getOperation().getOutput() != null) {
__log.debug("PXE MEX " + pxeMex + " completed SYNCHRONOUSLY.");
SOAPEnvelope envelope = soapFactory.getDefaultEnvelope();
outMsgContext.setEnvelope(envelope);
+ // Waiting for a callback
+ pxeMex = callback.getResponse(TIMEOUT);
+ // Hopefully we have a response
onResponse(pxeMex, envelope);
} else {
__log.debug("PXE MEX " + pxeMex + " completed ASYNCHRONOUSLY.");
}
success = true;
} else {
- __log.error("PXE MEX " +pxeMex + " was unroutable.");
+ __log.error("PXE MEX " + pxeMex + " was unroutable.");
}
} catch(Exception e) {
throw new AxisFault("An exception occured when invoking PXE.", e);
@@ -99,10 +108,20 @@
if (!success) throw new AxisFault("Message was unroutable!");
}
+ public void notifyResponse(MyRoleMessageExchange mex) {
+ ResponseCallback callback =
_waitingCallbacks.get(mex.getMessageExchangeId());
+ if (callback == null) {
+ __log.error("No active service for message exchange: " + mex);
+ } else {
+ callback.onResponse(mex);
+ _waitingCallbacks.remove(mex.getMessageExchangeId());
+ }
+ }
+
private void onResponse(MyRoleMessageExchange mex, SOAPEnvelope envelope)
throws AxisFault {
switch (mex.getStatus()) {
case FAULT:
- throw new AxisFault(null, mex.getFault(), null, null,
toOM(mex.getFaultResponse().getMessage()));
+ throw new AxisFault(null, mex.getFault(), null, null,
OMUtils.toOM(mex.getFaultResponse().getMessage()));
case RESPONSE:
fillEnvelope(mex.getResponse(), envelope);
break;
@@ -115,7 +134,7 @@
}
private void convertMessage(javax.wsdl.Message msgdef, Message dest,
OMElement body) throws AxisFault {
- Element srcel = toDOM(body);
+ Element srcel = OMUtils.toDOM(body);
Document pxemsgdoc = DOMUtils.newDocument();
Element pxemsg = pxemsgdoc.createElement("message");
@@ -143,32 +162,37 @@
private void fillEnvelope(Message resp, SOAPEnvelope envelope) throws
AxisFault {
Element srcPartEl = DOMUtils.getFirstChildElement(resp.getMessage());
while (srcPartEl != null) {
- envelope.getBody().addChild(toOM(srcPartEl));
+ envelope.getBody().addChild(OMUtils.toOM(srcPartEl));
srcPartEl = DOMUtils.getNextSiblingElement(srcPartEl);
}
}
- private Element toDOM(OMElement element) throws AxisFault {
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- try {
- element.serialize(baos);
- ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
- return DOMUtils.parse(bais).getDocumentElement();
- } catch (Exception e) {
- throw new AxisFault("Unable to read Axis input messag.e", e);
+ class ResponseCallback {
+ private MyRoleMessageExchange _mmex;
+ private boolean _timedout;
+
+ synchronized boolean onResponse(MyRoleMessageExchange mmex) {
+ if (_timedout) {
+ return false;
+ }
+ _mmex = mmex;
+ this.notify();
+ return true;
}
- }
- private OMElement toOM(Element element) throws AxisFault {
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- try {
- DOMUtils.serialize(element, baos);
- ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
- XMLStreamReader parser =
XMLInputFactory.newInstance().createXMLStreamReader(bais);
- StAXOMBuilder builder = new StAXOMBuilder(parser);
- return builder.getDocumentElement();
- } catch (Exception e) {
- throw new AxisFault("Unable to read Axis input messag.e", e);
+ synchronized MyRoleMessageExchange getResponse(long timeout) {
+ long etime = timeout == 0 ? Long.MAX_VALUE : System.currentTimeMillis()
+ timeout;
+ long ctime;
+ try {
+ while (_mmex == null && (ctime = System.currentTimeMillis()) < etime) {
+ this.wait(etime - ctime);
+ }
+ }
+ catch (InterruptedException ie) {
+ // ignore
+ }
+ _timedout = _mmex == null;
+ return _mmex;
}
}
Added:
incubator/ode/scratch/pxe-iapi/axis/src/main/java/com/fs/pxe/axis/epr/EndpointFactory.java
URL:
http://svn.apache.org/viewvc/incubator/ode/scratch/pxe-iapi/axis/src/main/java/com/fs/pxe/axis/epr/EndpointFactory.java?rev=419390&view=auto
==============================================================================
---
incubator/ode/scratch/pxe-iapi/axis/src/main/java/com/fs/pxe/axis/epr/EndpointFactory.java
(added)
+++
incubator/ode/scratch/pxe-iapi/axis/src/main/java/com/fs/pxe/axis/epr/EndpointFactory.java
Wed Jul 5 17:10:37 2006
@@ -0,0 +1,76 @@
+package com.fs.pxe.axis.epr;
+
+import com.fs.utils.Namespaces;
+import org.w3c.dom.Node;
+
+import javax.xml.namespace.QName;
+import java.util.Map;
+
+/**
+ * Factory for [EMAIL PROTECTED] com.fs.pxe.sfwk.core.ServiceEndpoint}
implementations.
+ */
+public class EndpointFactory {
+
+ private static QName WSDL20_ELMT_QNAME = new QName(Namespaces.WSDL_20,
"service");
+ private static QName WSDL11_ELMT_QNAME = new QName(Namespaces.WSDL_11,
"service");
+ private static QName WSA_ELMT_QNAME = new QName(Namespaces.WS_ADDRESSING_NS,
"EndpointReference");
+ private static QName SOAP_ADDR_ELMT_QNAME = new QName(Namespaces.SOAP_NS,
"address");
+
+ private static MutableEndpoint[] ENDPOINTS = new MutableEndpoint[] {
+ new URLEndpoint(), new WSAEndpoint(), new WSDL11Endpoint(), new
WSDL20Endpoint() };
+
+ /**
+ * Creates a ServiceEndpoint using the provided Node. The actual endpoint
+ * type is detected using the endpoint node (text or element qname).
+ * @param endpointNode
+ * @return the new ServiceEndpoint
+ */
+ public static MutableEndpoint createEndpoint(Node endpointNode) {
+ for (MutableEndpoint endpoint : EndpointFactory.ENDPOINTS) {
+ if (endpoint.accept(endpointNode)) {
+ MutableEndpoint se;
+ try {
+ se = endpoint.getClass().newInstance();
+ } catch (InstantiationException e) {
+ throw new RuntimeException(e);
+ } catch (IllegalAccessException e) {
+ throw new RuntimeException(e);
+ }
+ se.set(endpointNode);
+ return se;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Convert an EPR element into another EPR using the provided target type.
The target
+ * type is actually the qualified name of the root element for the target
EPR (i.e
+ * wsa:MutableEndpoint, wsdl:service) or null to convert to a simple URL.
+ * @param sourceEndpoint
+ * @param targetElmtType QName to convert to
+ * @return the converted MutableEndpoint
+ */
+ public static MutableEndpoint convert(Node sourceEndpoint, QName
targetElmtType) {
+ MutableEndpoint targetEpr;
+ MutableEndpoint sourceEpr = EndpointFactory.createEndpoint(sourceEndpoint);
+ Map transfoMap = sourceEpr.toMap();
+ if (targetElmtType == null) {
+ targetEpr = new URLEndpoint();
+ } else if (targetElmtType.equals(EndpointFactory.WSDL20_ELMT_QNAME)) {
+ targetEpr = new WSDL20Endpoint();
+ } else if (targetElmtType.equals(EndpointFactory.WSDL11_ELMT_QNAME)) {
+ targetEpr = new WSDL11Endpoint();
+ } else if (targetElmtType.equals(EndpointFactory.WSA_ELMT_QNAME)) {
+ targetEpr = new WSAEndpoint();
+ } else if (targetElmtType.equals(EndpointFactory.SOAP_ADDR_ELMT_QNAME)) {
+ targetEpr = new URLEndpoint();
+ } else {
+ // When everything fails, shooting for the most simple EPR format
+ targetEpr = new URLEndpoint();
+ }
+
+ targetEpr.fromMap(transfoMap);
+ return targetEpr;
+ }
+}
Added:
incubator/ode/scratch/pxe-iapi/axis/src/main/java/com/fs/pxe/axis/epr/MutableEndpoint.java
URL:
http://svn.apache.org/viewvc/incubator/ode/scratch/pxe-iapi/axis/src/main/java/com/fs/pxe/axis/epr/MutableEndpoint.java?rev=419390&view=auto
==============================================================================
---
incubator/ode/scratch/pxe-iapi/axis/src/main/java/com/fs/pxe/axis/epr/MutableEndpoint.java
(added)
+++
incubator/ode/scratch/pxe-iapi/axis/src/main/java/com/fs/pxe/axis/epr/MutableEndpoint.java
Wed Jul 5 17:10:37 2006
@@ -0,0 +1,55 @@
+package com.fs.pxe.axis.epr;
+
+import com.fs.pxe.bpel.iapi.EndpointReference;
+import org.w3c.dom.Node;
+
+import java.util.Map;
+
+/**
+ * Adds methods on [EMAIL PROTECTED] EndpointReference} to set and manipulate
endpoint references.
+ */
+public interface MutableEndpoint extends EndpointReference {
+
+ static final String ADDRESS = "address";
+ static final String SESSION = "session";
+ static final String SERVICE_QNAME = "service";
+ static final String PORT_NAME = "port";
+ static final String BINDING_QNAME = "binding";
+
+ /**
+ * Expresses the fact that the endpoint can be either tranformed to a
+ * Map representation or initialized from a Map. Used for endpoint
+ * conversion, to transform one endpoint type into another (using Map
+ * as an intermediary format).
+ */
+ Map toMap();
+
+ /**
+ * Expresses the fact that the endpoint can be either tranformed to a
+ * Map representation or initialized from a Map. Used for endpoint
+ * conversion, to transform one endpoint type into another (using Map
+ * as an intermediary format).
+ */
+ void fromMap(Map eprMap);
+
+ /**
+ * Checks if the type of the provided node is the right one for this
+ * ServiceEndpoint implementation. The endpoint should be unwrapped
+ * (without service-ref) before calling this method.
+ * @param node
+ * @return true if the node content matches the service endpoint
implementation, false otherwise
+ */
+ boolean accept(Node node);
+
+ /**
+ * Set service endpoint value from an XML node.
+ * @param node
+ */
+ void set(Node node);
+
+ /**
+ * @return endpoint target URL
+ */
+ String getUrl();
+
+}
Added:
incubator/ode/scratch/pxe-iapi/axis/src/main/java/com/fs/pxe/axis/epr/URLEndpoint.java
URL:
http://svn.apache.org/viewvc/incubator/ode/scratch/pxe-iapi/axis/src/main/java/com/fs/pxe/axis/epr/URLEndpoint.java?rev=419390&view=auto
==============================================================================
---
incubator/ode/scratch/pxe-iapi/axis/src/main/java/com/fs/pxe/axis/epr/URLEndpoint.java
(added)
+++
incubator/ode/scratch/pxe-iapi/axis/src/main/java/com/fs/pxe/axis/epr/URLEndpoint.java
Wed Jul 5 17:10:37 2006
@@ -0,0 +1,66 @@
+package com.fs.pxe.axis.epr;
+
+import com.fs.utils.DOMUtils;
+import com.fs.utils.Namespaces;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.Text;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Implementation of the ServiceEndpoint interface backended by a simple URL.
+ */
+public class URLEndpoint implements MutableEndpoint {
+
+ private String _url;
+
+ public URLEndpoint() {
+ }
+
+ public String getUrl() {
+ return _url;
+ }
+
+ public void setUrl(String url) {
+ _url = url;
+ }
+
+ public boolean accept(Node node) {
+ if (node.getNodeType() == Node.TEXT_NODE) return true;
+ else if (node.getNodeType() == Node.ELEMENT_NODE) {
+ Element elmt = (Element)node;
+ if (elmt.getLocalName().equals("address") &&
elmt.getNamespaceURI().equals(Namespaces.SOAP_NS))
+ return true;
+ }
+ return false;
+ }
+
+ public void set(Node node) {
+ if (node.getNodeType() == Node.TEXT_NODE) _url =
((Text)node).getWholeText();
+ else if (node.getNodeType() == Node.ELEMENT_NODE) {
+ Element elmt = (Element)node;
+ _url = elmt.getAttribute("location");
+ }
+ }
+
+ public Document toXML() {
+ Document doc = DOMUtils.newDocument();
+ Element serviceRef =
doc.createElementNS(SERVICE_REF_QNAME.getNamespaceURI(),
SERVICE_REF_QNAME.getLocalPart());
+ Node urlNode = doc.createTextNode(_url);
+ serviceRef.appendChild(urlNode);
+ return doc;
+ }
+
+ public Map toMap() {
+ HashMap result = new HashMap();
+ result.put(ADDRESS, _url);
+ return result;
+ }
+
+ public void fromMap(Map eprMap) {
+ _url = (String) eprMap.get(ADDRESS);
+ }
+}
Added:
incubator/ode/scratch/pxe-iapi/axis/src/main/java/com/fs/pxe/axis/epr/WSAEndpoint.java
URL:
http://svn.apache.org/viewvc/incubator/ode/scratch/pxe-iapi/axis/src/main/java/com/fs/pxe/axis/epr/WSAEndpoint.java?rev=419390&view=auto
==============================================================================
---
incubator/ode/scratch/pxe-iapi/axis/src/main/java/com/fs/pxe/axis/epr/WSAEndpoint.java
(added)
+++
incubator/ode/scratch/pxe-iapi/axis/src/main/java/com/fs/pxe/axis/epr/WSAEndpoint.java
Wed Jul 5 17:10:37 2006
@@ -0,0 +1,108 @@
+package com.fs.pxe.axis.epr;
+
+import com.fs.utils.DOMUtils;
+import com.fs.utils.Namespaces;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * A service endpoint represented as a WS-Addressing EndpointReference.
+ */
+public class WSAEndpoint implements MutableEndpoint {
+
+ private Element _eprElmt;
+
+ public WSAEndpoint() {
+ }
+
+ public WSAEndpoint(String url, String sessionId) {
+ Document doc = DOMUtils.newDocument();
+ _eprElmt = doc.createElementNS(Namespaces.WS_ADDRESSING_NS,
"EndpointReference");
+ Element addrElmt = doc.createElementNS(Namespaces.WS_ADDRESSING_NS,
"Address");
+ addrElmt.setTextContent(url);
+ Element sessElmt = doc.createElementNS(Namespaces.INTALIO_SESSION_NS,
"identifier");
+ sessElmt.setTextContent(sessionId);
+ _eprElmt.appendChild(addrElmt);
+ _eprElmt.appendChild(sessElmt);
+ doc.appendChild(_eprElmt);
+ }
+
+ public String getSessionId() {
+ NodeList idNodes =
_eprElmt.getElementsByTagNameNS(Namespaces.INTALIO_SESSION_NS, "identifier");
+ if (idNodes.getLength() > 0) return idNodes.item(0).getTextContent();
+ else return null;
+ }
+
+ public void setSessionId(String sessionId) {
+ NodeList idList =
_eprElmt.getElementsByTagNameNS(Namespaces.INTALIO_SESSION_NS, "identifier");
+ if (idList.getLength() > 0) idList.item(0).setTextContent(sessionId);
+ else {
+ Element sessElmt =
_eprElmt.getOwnerDocument().createElementNS(Namespaces.INTALIO_SESSION_NS,
"identifier");
+ sessElmt.setTextContent(sessionId);
+ _eprElmt.appendChild(sessElmt);
+ }
+ }
+
+ public String getUrl() {
+ return _eprElmt.getElementsByTagNameNS(Namespaces.WS_ADDRESSING_NS,
"Address").item(0).getTextContent();
+ }
+
+ public void setUrl(String url) {
+ NodeList addrList =
_eprElmt.getElementsByTagNameNS(Namespaces.WS_ADDRESSING_NS, "Address");
+ if (addrList.getLength() > 0) addrList.item(0).setTextContent(url);
+ else {
+ Element addrElmt =
_eprElmt.getOwnerDocument().createElementNS(Namespaces.WS_ADDRESSING_NS,
"Address");
+ addrElmt.setTextContent(url);
+ _eprElmt.appendChild(addrElmt);
+ }
+ }
+
+ public boolean accept(Node node) {
+ if (node.getNodeType() == Node.ELEMENT_NODE) {
+ Element elmt = (Element)node;
+ if (elmt.getLocalName().equals("EndpointReference") &&
elmt.getNamespaceURI().equals(Namespaces.WS_ADDRESSING_NS))
+ return true;
+ }
+ return false;
+ }
+
+ public void set(Node node) {
+ if (node.getNamespaceURI().equals(SERVICE_REF_QNAME.getNamespaceURI()))
+ _eprElmt = DOMUtils.getFirstChildElement((Element)node);
+ else
+ _eprElmt = (Element) node;
+ }
+
+ public Document toXML() {
+ return _eprElmt.getOwnerDocument();
+ }
+
+ public Map toMap() {
+ HashMap<String,String> result = new HashMap<String,String>();
+ result.put(ADDRESS, getUrl());
+ String sid = getSessionId();
+ if (sid != null) result.put(SESSION, sid);
+ return result;
+ }
+
+ public void fromMap(Map eprMap) {
+ Document doc = DOMUtils.newDocument();
+ Element serviceRef =
doc.createElementNS(SERVICE_REF_QNAME.getNamespaceURI(),
SERVICE_REF_QNAME.getLocalPart());
+ _eprElmt = doc.createElementNS(Namespaces.WS_ADDRESSING_NS,
"EndpointReference");
+ serviceRef.appendChild(_eprElmt);
+ Element addrElmt = doc.createElementNS(Namespaces.WS_ADDRESSING_NS,
"Address");
+ addrElmt.setTextContent((String) eprMap.get(ADDRESS));
+ if (eprMap.get(SESSION) != null) {
+ Element sessElmt = doc.createElementNS(Namespaces.INTALIO_SESSION_NS,
"identifier");
+ sessElmt.setTextContent((String) eprMap.get(SESSION));
+ _eprElmt.appendChild(sessElmt);
+ }
+ _eprElmt.appendChild(addrElmt);
+ doc.appendChild(_eprElmt);
+ }
+}
Added:
incubator/ode/scratch/pxe-iapi/axis/src/main/java/com/fs/pxe/axis/epr/WSDL11Endpoint.java
URL:
http://svn.apache.org/viewvc/incubator/ode/scratch/pxe-iapi/axis/src/main/java/com/fs/pxe/axis/epr/WSDL11Endpoint.java?rev=419390&view=auto
==============================================================================
---
incubator/ode/scratch/pxe-iapi/axis/src/main/java/com/fs/pxe/axis/epr/WSDL11Endpoint.java
(added)
+++
incubator/ode/scratch/pxe-iapi/axis/src/main/java/com/fs/pxe/axis/epr/WSDL11Endpoint.java
Wed Jul 5 17:10:37 2006
@@ -0,0 +1,81 @@
+package com.fs.pxe.axis.epr;
+
+import com.fs.utils.DOMUtils;
+import com.fs.utils.Namespaces;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+
+import javax.xml.namespace.QName;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * A service endpoint represented as a wsdl11:service element.
+ */
+public class WSDL11Endpoint implements MutableEndpoint {
+
+ private Element _serviceElmt;
+
+ public WSDL11Endpoint() {
+ }
+
+ public String getUrl() {
+ return _serviceElmt.getElementsByTagNameNS(Namespaces.SOAP_NS,
"address").item(0).getTextContent();
+ }
+
+ public boolean accept(Node node) {
+ if (node.getNodeType() == Node.ELEMENT_NODE) {
+ Element elmt = (Element) node;
+ if (elmt.getLocalName().equals("service") &&
elmt.getNamespaceURI().equals(Namespaces.WSDL_11))
+ if (elmt.getElementsByTagNameNS(Namespaces.SOAP_NS,
"address").getLength() > 0)
+ return true;
+ }
+ return false;
+ }
+
+ public void set(Node node) {
+ if (node.getNamespaceURI().equals(SERVICE_REF_QNAME.getNamespaceURI()))
+ _serviceElmt = DOMUtils.getFirstChildElement((Element)node);
+ else
+ _serviceElmt = (Element) node;
+ }
+
+ public Document toXML() {
+ return _serviceElmt.getOwnerDocument();
+ }
+
+ public Map toMap() {
+ HashMap<String,Object> result = new HashMap<String,Object>(1);
+ result.put(ADDRESS, getUrl());
+ result.put(SERVICE_QNAME, new QName(_serviceElmt.getNamespaceURI(),
_serviceElmt.getAttribute("name")));
+ Element port = DOMUtils.getFirstChildElement(_serviceElmt);
+ result.put(PORT_NAME, port.getAttribute("name"));
+ // TODO binding
+ return result;
+ }
+
+ public void fromMap(Map eprMap) {
+ Document doc = DOMUtils.newDocument();
+ Element serviceRef =
doc.createElementNS(SERVICE_REF_QNAME.getNamespaceURI(),
SERVICE_REF_QNAME.getLocalPart());
+ _serviceElmt = doc.createElementNS(Namespaces.WSDL_11, "service");
+ serviceRef.appendChild(_serviceElmt);
+ if (eprMap.get(SERVICE_QNAME) != null) {
+ QName serviceQName = ((QName) eprMap.get(SERVICE_QNAME));
+ _serviceElmt.setAttribute("name", serviceQName.getLocalPart());
+ _serviceElmt.setAttribute("xmlns", serviceQName.getNamespaceURI());
+ }
+ Element port = doc.createElementNS(Namespaces.WSDL_11, "port");
+ if (eprMap.get(PORT_NAME) != null) {
+ port.setAttribute("name", (String) eprMap.get(PORT_NAME));
+ }
+ port.setAttribute("binding", "");
+ Element address = doc.createElementNS(Namespaces.SOAP_NS, "address");
+ if (eprMap.get(ADDRESS) != null) address.setAttribute("location", (String)
eprMap.get(ADDRESS));
+
+ _serviceElmt.appendChild(port);
+ _serviceElmt.appendChild(address);
+ doc.appendChild(_serviceElmt);
+ }
+
+}
Added:
incubator/ode/scratch/pxe-iapi/axis/src/main/java/com/fs/pxe/axis/epr/WSDL20Endpoint.java
URL:
http://svn.apache.org/viewvc/incubator/ode/scratch/pxe-iapi/axis/src/main/java/com/fs/pxe/axis/epr/WSDL20Endpoint.java?rev=419390&view=auto
==============================================================================
---
incubator/ode/scratch/pxe-iapi/axis/src/main/java/com/fs/pxe/axis/epr/WSDL20Endpoint.java
(added)
+++
incubator/ode/scratch/pxe-iapi/axis/src/main/java/com/fs/pxe/axis/epr/WSDL20Endpoint.java
Wed Jul 5 17:10:37 2006
@@ -0,0 +1,104 @@
+package com.fs.pxe.axis.epr;
+
+import com.fs.utils.DOMUtils;
+import com.fs.utils.Namespaces;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * A service endpoint represented as a wsdl20:service element.
+ */
+public class WSDL20Endpoint implements MutableEndpoint {
+
+ private Element _serviceElmt;
+
+ public WSDL20Endpoint() {
+ }
+
+ public String getSessionId() {
+ Element endpointElmt =
(Element)_serviceElmt.getElementsByTagNameNS(Namespaces.WSDL_20,
"endpoint").item(0);
+ NodeList idNodes =
endpointElmt.getElementsByTagNameNS(Namespaces.INTALIO_SESSION_NS,
"identifier");
+ if (idNodes.getLength() > 0) return idNodes.item(0).getTextContent();
+ else return null;
+ }
+
+ public void setSessionId(String sessionId) {
+ Element endpointElmt =
(Element)_serviceElmt.getElementsByTagNameNS(Namespaces.WSDL_20,
"endpoint").item(0);
+ NodeList idList =
endpointElmt.getElementsByTagNameNS(Namespaces.INTALIO_SESSION_NS,
"identifier");
+ if (idList.getLength() > 0) idList.item(0).setTextContent(sessionId);
+ else {
+ Element sessElmt =
_serviceElmt.getOwnerDocument().createElementNS(Namespaces.INTALIO_SESSION_NS,
"identifier");
+ sessElmt.setTextContent(sessionId);
+ endpointElmt.appendChild(sessElmt);
+ }
+ }
+
+ public String getUrl() {
+ return ((Element)_serviceElmt.getElementsByTagNameNS(Namespaces.WSDL_20,
"endpoint").item(0)).getAttribute("address");
+ }
+
+ public void setUrl(String url) {
+ Element endpointElmt =
(Element)_serviceElmt.getElementsByTagNameNS(Namespaces.WSDL_20,
"endpoint").item(0);
+ NodeList addrList =
endpointElmt.getElementsByTagNameNS(Namespaces.WSDL_20, "address");
+ if (addrList.getLength() > 0) addrList.item(0).setTextContent(url);
+ else {
+ Element addrElmt =
_serviceElmt.getOwnerDocument().createElementNS(Namespaces.WSDL_20, "address");
+ addrElmt.setTextContent(url);
+ endpointElmt.appendChild(addrElmt);
+ }
+ }
+
+ public boolean accept(Node node) {
+ if (node.getNodeType() == Node.ELEMENT_NODE) {
+ Element elmt = (Element) node;
+ if (elmt.getLocalName().equals("service") &&
elmt.getNamespaceURI().equals(Namespaces.WSDL_20))
+ if (_serviceElmt.getElementsByTagNameNS(Namespaces.WSDL_20,
"endpoint").getLength() > 0)
+ return true;
+ }
+ return false;
+ }
+
+ public void set(Node node) {
+ if (node.getNamespaceURI().equals(SERVICE_REF_QNAME.getNamespaceURI()))
+ _serviceElmt = DOMUtils.getFirstChildElement((Element)node);
+ else
+ _serviceElmt = (Element) node;
+ }
+
+ public Document toXML() {
+ return _serviceElmt.getOwnerDocument();
+ }
+
+ public Map toMap() {
+ HashMap<String,String> result = new HashMap<String,String>(1);
+ result.put(ADDRESS, getUrl());
+ String sid = getSessionId();
+ if (sid != null) result.put(ADDRESS, sid);
+ return result;
+ }
+
+ public void fromMap(Map eprMap) {
+ Document doc = DOMUtils.newDocument();
+ Element serviceRef =
doc.createElementNS(SERVICE_REF_QNAME.getNamespaceURI(),
SERVICE_REF_QNAME.getLocalPart());
+ _serviceElmt = doc.createElementNS(Namespaces.WSDL_20, "service");
+ _serviceElmt.setAttribute("name", "");
+ _serviceElmt.setAttribute("interface", "");
+ serviceRef.appendChild(_serviceElmt);
+ Element endpoint = doc.createElementNS(Namespaces.WSDL_20, "endpoint");
+ endpoint.setAttribute("name", "");
+ endpoint.setAttribute("binding", "");
+ if (eprMap.get(ADDRESS) != null) endpoint.setAttribute("address", (String)
eprMap.get(ADDRESS));
+ if (eprMap.get(SESSION) != null) {
+ Element session = doc.createElementNS(Namespaces.INTALIO_SESSION_NS,
"identifier");
+ session.setTextContent((String) eprMap.get(SESSION));
+ endpoint.appendChild(session);
+ }
+ _serviceElmt.appendChild(endpoint);
+ doc.appendChild(_serviceElmt);
+ }
+}
Added:
incubator/ode/scratch/pxe-iapi/axis/src/main/java/com/fs/pxe/axis/hooks/PXEAxisDispatcher.java
URL:
http://svn.apache.org/viewvc/incubator/ode/scratch/pxe-iapi/axis/src/main/java/com/fs/pxe/axis/hooks/PXEAxisDispatcher.java?rev=419390&view=auto
==============================================================================
---
incubator/ode/scratch/pxe-iapi/axis/src/main/java/com/fs/pxe/axis/hooks/PXEAxisDispatcher.java
(added)
+++
incubator/ode/scratch/pxe-iapi/axis/src/main/java/com/fs/pxe/axis/hooks/PXEAxisDispatcher.java
Wed Jul 5 17:10:37 2006
@@ -0,0 +1,129 @@
+package com.fs.pxe.axis.hooks;
+
+
+import org.apache.axiom.om.OMElement;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.addressing.EndpointReference;
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.description.AxisOperation;
+import org.apache.axis2.description.AxisService;
+import org.apache.axis2.description.HandlerDescription;
+import org.apache.axis2.engine.AbstractDispatcher;
+import org.apache.axis2.engine.AxisConfiguration;
+import org.apache.axis2.i18n.Messages;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import javax.xml.namespace.QName;
+
+
+/**
+ * Dispatches the service based on the information from the target endpoint
URL.
+ */
+public class PXEAxisDispatcher extends AbstractDispatcher {
+
+ /**
+ * Field NAME
+ */
+ public static final QName NAME = new QName("http://pxe.intalio.org/",
+ "PXEAxisDispatcher");
+ private static final Log log = LogFactory.getLog(PXEAxisDispatcher.class);
+ QName operationName = null;
+
+
+ public AxisOperation findOperation(AxisService service, MessageContext
messageContext)
+ throws AxisFault {
+ AxisOperation operation;
+
+ // Start with the wsaAction. We assume wsaAction is the more reliable
+ // way to identify the operation.
+ String action = messageContext.getWSAAction();
+ if (action != null) {
+ log.debug(Messages.getMessage("checkingoperation", action));
+ operation = service.getOperationByAction(action);
+ if (operation != null)
+ return operation;
+ }
+
+ // Failing that, look at the body of the SOAP message. We expect one
+ // element that has the same (local) name as the operation. This works
+ // well for RPC, not always for Doc/Lit.
+ OMElement bodyFirstChild =
messageContext.getEnvelope().getBody().getFirstElement();
+ if (bodyFirstChild != null) {
+ String localName = bodyFirstChild.getLocalName();
+ log.debug("Checking for Operation using SOAP message body's first
child's local name : "
+ + localName);
+ operation = service.getOperation(new QName(localName));
+ if (operation != null)
+ return operation;
+
+ // Of course, the element name most likely uses the suffix
+ // Request or Response, so look for those and strip them.
+ int index = localName.lastIndexOf("Request");
+ if (index + "Request".length() == localName.length()) {
+ return service.getOperation(new QName(localName.substring(0,
index)));
+ }
+ index = localName.lastIndexOf("Response");
+ if (index + "Response".length() == localName.length()) {
+ return service.getOperation(new QName(localName.substring(0,
index)));
+ }
+ }
+
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
org.apache.axis2.engine.AbstractDispatcher#findService(org.apache.axis2.context.MessageContext)
+ */
+ public AxisService findService(MessageContext messageContext) throws
AxisFault {
+ EndpointReference toEPR = messageContext.getTo();
+
+ if (toEPR != null) {
+ log.debug("Checking for Service using target endpoint address : "
+ toEPR.getAddress());
+
+ // The only thing we understand if a service name that
+ // follows /processes/ in the request URL.
+ String path = parseRequestURLForService(toEPR.getAddress());
+ if (path != null) {
+ AxisConfiguration registry =
+
messageContext.getConfigurationContext().getAxisConfiguration();
+ return registry.getService(path);
+ }
+ }
+
+ return null;
+ }
+
+
+ public void initDispatcher() {
+ init(new HandlerDescription(NAME));
+ }
+
+
+ /**
+ * Obtain the service name from the request URL. The request URL is
+ * expected to use the path "/processes/" under which all processes
+ * and their services are listed. Returns null if the path does not
+ * contain this part.
+ */
+ protected String parseRequestURLForService(String path) {
+ int index = path.indexOf("/processes/");
+ if (-1 != index) {
+ String service;
+
+ int serviceStart = index + "/processes/".length();
+ if (path.length() > serviceStart + 1) {
+ service = path.substring(serviceStart);
+ // Path may contain query string, not interesting for us.
+ int queryIndex = service.indexOf('?');
+ if (queryIndex > 0) {
+ service = service.substring(0, queryIndex);
+ }
+ return service;
+ }
+ }
+ return null;
+ }
+
+}
Modified:
incubator/ode/scratch/pxe-iapi/bpel-api/src/main/java/com/fs/pxe/bpel/iapi/EndpointReference.java
URL:
http://svn.apache.org/viewvc/incubator/ode/scratch/pxe-iapi/bpel-api/src/main/java/com/fs/pxe/bpel/iapi/EndpointReference.java?rev=419390&r1=419389&r2=419390&view=diff
==============================================================================
---
incubator/ode/scratch/pxe-iapi/bpel-api/src/main/java/com/fs/pxe/bpel/iapi/EndpointReference.java
(original)
+++
incubator/ode/scratch/pxe-iapi/bpel-api/src/main/java/com/fs/pxe/bpel/iapi/EndpointReference.java
Wed Jul 5 17:10:37 2006
@@ -22,7 +22,7 @@
* used by the BPEL engine to persist EPR references in the
* database.
* TODO: avoid using DOM
- * @param result destination for the generated XML
+ * @return destination for the generated XML
*/
Document toXML();
}
Modified:
incubator/ode/scratch/pxe-iapi/bpel-runtime/src/main/java/com/fs/pxe/bpel/engine/BpelServerImpl.java
URL:
http://svn.apache.org/viewvc/incubator/ode/scratch/pxe-iapi/bpel-runtime/src/main/java/com/fs/pxe/bpel/engine/BpelServerImpl.java?rev=419390&r1=419389&r2=419390&view=diff
==============================================================================
---
incubator/ode/scratch/pxe-iapi/bpel-runtime/src/main/java/com/fs/pxe/bpel/engine/BpelServerImpl.java
(original)
+++
incubator/ode/scratch/pxe-iapi/bpel-runtime/src/main/java/com/fs/pxe/bpel/engine/BpelServerImpl.java
Wed Jul 5 17:10:37 2006
@@ -608,8 +608,7 @@
throw new BpelEngineException("", dce);
}
- if (processDD.getActive())
- doActivateProcess(processId);
+ doActivateProcess(processId);
}
private com.fs.pxe.bpel.dd.TDeploymentDescriptor readDeploymentDescriptor(