Author: mriou
Date: Thu Jul 20 12:26:54 2006
New Revision: 424028
URL: http://svn.apache.org/viewvc?rev=424028&view=rev
Log:
URL where a process service is deployed is now configurable using the WSDL
service soap:address.
Modified:
incubator/ode/scratch/pxe-iapi/axis2/src/main/java/com/fs/pxe/axis2/DeploymentUnit.java
incubator/ode/scratch/pxe-iapi/axis2/src/main/java/com/fs/pxe/axis2/MessageExchangeContextImpl.java
incubator/ode/scratch/pxe-iapi/axis2/src/main/java/com/fs/pxe/axis2/PXEServer.java
incubator/ode/scratch/pxe-iapi/axis2/src/main/java/com/fs/pxe/axis2/PXEService.java
incubator/ode/scratch/pxe-iapi/axis2/src/main/java/com/fs/pxe/axis2/hooks/PXEAxisDispatcher.java
incubator/ode/scratch/pxe-iapi/axis2/src/main/java/com/fs/pxe/axis2/hooks/PXEAxisService.java
incubator/ode/scratch/pxe-iapi/bpel-api/src/main/java/com/fs/pxe/bpel/epr/WSAEndpoint.java
Modified:
incubator/ode/scratch/pxe-iapi/axis2/src/main/java/com/fs/pxe/axis2/DeploymentUnit.java
URL:
http://svn.apache.org/viewvc/incubator/ode/scratch/pxe-iapi/axis2/src/main/java/com/fs/pxe/axis2/DeploymentUnit.java?rev=424028&r1=424027&r2=424028&view=diff
==============================================================================
---
incubator/ode/scratch/pxe-iapi/axis2/src/main/java/com/fs/pxe/axis2/DeploymentUnit.java
(original)
+++
incubator/ode/scratch/pxe-iapi/axis2/src/main/java/com/fs/pxe/axis2/DeploymentUnit.java
Thu Jul 20 12:26:54 2006
@@ -10,6 +10,8 @@
import com.fs.pxe.bpel.o.OProcess;
import com.fs.pxe.bpel.o.Serializer;
import org.apache.axis2.AxisFault;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import javax.wsdl.WSDLException;
import javax.wsdl.xml.WSDLReader;
@@ -17,7 +19,6 @@
import java.io.File;
import java.io.FileFilter;
import java.io.FileInputStream;
-import java.io.IOException;
import java.io.InputStream;
import java.util.HashMap;
@@ -27,6 +28,8 @@
*/
public class DeploymentUnit {
+ private static Log __log = LogFactory.getLog(DeploymentUnit.class);
+
private long _lastModified;
private String _name;
private File _duDirectory;
@@ -103,9 +106,9 @@
_pxeServer.createExternalService(def, invoke.getService().getName(),
invoke.getService().getPort());
}
} catch (AxisFault axisFault) {
- throw new DeploymentException("Service deployment in Axis2 failed!",
axisFault);
+ __log.error("Service deployment in Axis2 failed!", axisFault);
} catch (Throwable e) {
-
+ __log.error("Service deployment failed!", e);
}
}
_lastModified = new File(_duDirectory, "deploy.xml").lastModified();
Modified:
incubator/ode/scratch/pxe-iapi/axis2/src/main/java/com/fs/pxe/axis2/MessageExchangeContextImpl.java
URL:
http://svn.apache.org/viewvc/incubator/ode/scratch/pxe-iapi/axis2/src/main/java/com/fs/pxe/axis2/MessageExchangeContextImpl.java?rev=424028&r1=424027&r2=424028&view=diff
==============================================================================
---
incubator/ode/scratch/pxe-iapi/axis2/src/main/java/com/fs/pxe/axis2/MessageExchangeContextImpl.java
(original)
+++
incubator/ode/scratch/pxe-iapi/axis2/src/main/java/com/fs/pxe/axis2/MessageExchangeContextImpl.java
Thu Jul 20 12:26:54 2006
@@ -25,11 +25,9 @@
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 {
@@ -43,16 +41,22 @@
epr.toXML().getDocumentElement());
// It's now safe to cast
QName serviceName = ((WSAEndpoint)epr).getServiceName();
+ String portName = ((WSAEndpoint)epr).getPortName();
if (__log.isDebugEnabled())
__log.debug("The service to invoke is the external service " +
serviceName);
- ExternalService service = _server.getExternalService(serviceName);
+ ExternalService service = _server.getExternalService(serviceName,
portName);
service.invoke(partnerRoleMessageExchange);
}
public void onAsyncReply(MyRoleMessageExchange myRoleMessageExchange) throws
BpelEngineException {
if (__log.isDebugEnabled())
__log.debug("Processing an async reply from service " +
myRoleMessageExchange.getServiceName());
- PXEService service =
_server.getService(myRoleMessageExchange.getServiceName());
+
+ // TODO Add a port in MessageExchange (for now there's only service) to be
able to find the
+ // TODO right service. For now we'll just lookup by service+portType but
if we have severalt ports
+ // TODO for the same portType that will not work.
+ PXEService service =
_server.getService(myRoleMessageExchange.getServiceName(),
+ myRoleMessageExchange.getPortType().getQName());
service.notifyResponse(myRoleMessageExchange);
}
}
Modified:
incubator/ode/scratch/pxe-iapi/axis2/src/main/java/com/fs/pxe/axis2/PXEServer.java
URL:
http://svn.apache.org/viewvc/incubator/ode/scratch/pxe-iapi/axis2/src/main/java/com/fs/pxe/axis2/PXEServer.java?rev=424028&r1=424027&r2=424028&view=diff
==============================================================================
---
incubator/ode/scratch/pxe-iapi/axis2/src/main/java/com/fs/pxe/axis2/PXEServer.java
(original)
+++
incubator/ode/scratch/pxe-iapi/axis2/src/main/java/com/fs/pxe/axis2/PXEServer.java
Thu Jul 20 12:26:54 2006
@@ -18,6 +18,7 @@
import org.apache.axis2.engine.AxisConfiguration;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.apache.commons.collections.map.MultiKeyMap;
import org.hibernate.cfg.Environment;
import org.hibernate.dialect.Dialect;
import org.hibernate.dialect.DialectFactory;
@@ -43,6 +44,7 @@
import java.util.HashMap;
import java.util.Hashtable;
import java.util.Properties;
+import java.util.Iterator;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
@@ -67,8 +69,11 @@
private QuartzSchedulerImpl _scheduler;
private DeploymentPoller _poller;
- private HashMap<QName,PXEService> _services = new
HashMap<QName,PXEService>();
- private HashMap<QName,ExternalService> _externalServices = new
HashMap<QName,ExternalService>();
+ private MultiKeyMap _services = new MultiKeyMap();
+ private MultiKeyMap _externalServices = new MultiKeyMap();
+
+// private HashMap<QName,PXEService> _services = new
HashMap<QName,PXEService>();
+// private HashMap<QName,ExternalService> _externalServices = new
HashMap<QName,ExternalService>();
public void init(ServletConfig config, AxisConfiguration axisConf) throws
ServletException {
_axisConfig = axisConf;
@@ -159,9 +164,9 @@
try {
AxisService axisService = PXEAxisService.createService(_axisConfig,
def, serviceName, portName);
- PXEService pxeService = new PXEService(axisService, def, serviceName,
+ PXEService pxeService = new PXEService(axisService, def, serviceName,
portName,
_server, _jotm.getTransactionManager());
- _services.put(serviceName, pxeService);
+ _services.put(serviceName, portName, pxeService);
// Setting our new service on the receiver, the same receiver handles all
// operations so the first one should fit them all
@@ -182,7 +187,7 @@
if (_externalServices.get(serviceName) != null) return;
ExternalService extService = new ExternalService(def, serviceName,
portName, _executorService, _axisConfig);
- _externalServices.put(serviceName, extService);
+ _externalServices.put(serviceName, portName, extService);
__log.debug("Created external service " + serviceName);
}
@@ -196,12 +201,22 @@
_services.remove(serviceName);
}
- public PXEService getService(QName serviceName) {
- return _services.get(serviceName);
+ public PXEService getService(QName serviceName, String portName) {
+ return (PXEService) _services.get(serviceName, portName);
+ }
+
+ public PXEService getService(QName serviceName, QName portTypeName) {
+ // TODO Normally this lookup should't exist as there could be more one
than port
+ // TODO for a portType. See MessageExchnageContextImpl.
+ for (Iterator iterator = _services.values().iterator();
iterator.hasNext();) {
+ PXEService service = (PXEService) iterator.next();
+ if (service.respondsTo(serviceName, portTypeName)) return service;
+ }
+ return null;
}
- public ExternalService getExternalService(QName serviceName) {
- return _externalServices.get(serviceName);
+ public ExternalService getExternalService(QName serviceName, String
portName) {
+ return (ExternalService) _externalServices.get(serviceName, portName);
}
public AxisInvoker createInvoker() {
Modified:
incubator/ode/scratch/pxe-iapi/axis2/src/main/java/com/fs/pxe/axis2/PXEService.java
URL:
http://svn.apache.org/viewvc/incubator/ode/scratch/pxe-iapi/axis2/src/main/java/com/fs/pxe/axis2/PXEService.java?rev=424028&r1=424027&r2=424028&view=diff
==============================================================================
---
incubator/ode/scratch/pxe-iapi/axis2/src/main/java/com/fs/pxe/axis2/PXEService.java
(original)
+++
incubator/ode/scratch/pxe-iapi/axis2/src/main/java/com/fs/pxe/axis2/PXEService.java
Thu Jul 20 12:26:54 2006
@@ -10,14 +10,12 @@
import com.fs.utils.GUID;
import org.apache.axiom.soap.SOAPEnvelope;
import org.apache.axiom.soap.SOAPFactory;
-import org.apache.axiom.soap.SOAPHeader;
import org.apache.axis2.AxisFault;
import org.apache.axis2.context.MessageContext;
import org.apache.axis2.description.AxisService;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.w3c.dom.Element;
-import org.w3c.dom.NodeList;
import javax.transaction.TransactionManager;
import javax.wsdl.Definition;
@@ -40,15 +38,17 @@
private TransactionManager _txManager;
private Definition _wsdlDef;
private QName _serviceName;
+ private String _portName;
private Map<String,ResponseCallback> _waitingCallbacks;
- public PXEService(AxisService axisService, Definition4BPEL def, QName
serviceName,
+ public PXEService(AxisService axisService, Definition4BPEL def, QName
serviceName, String portName,
BpelServerImpl server, TransactionManager txManager) {
_axisService = axisService;
_server = server;
_txManager = txManager;
_wsdlDef = def;
_serviceName = serviceName;
+ _portName = portName;
_waitingCallbacks = Collections.synchronizedMap(new HashMap<String,
ResponseCallback>());
}
@@ -62,10 +62,9 @@
// Creating mesage exchange
String messageId = new GUID().toString();
- pxeMex = _server.getEngine().createMessageExchange(""+messageId,
- new QName(msgContext.getAxisService().getTargetNamespace(),
- msgContext.getAxisService().getName()), null,
+ pxeMex = _server.getEngine().createMessageExchange(""+messageId,
_serviceName, null,
msgContext.getAxisOperation().getName().getLocalPart());
+ __log.debug("PXE routed to operation " + pxeMex.getOperation() + " from
service " + _serviceName);
if (pxeMex.getOperation() != null) {
// Preparing message to send to PXE
@@ -87,6 +86,8 @@
}
// Invoking PXE
pxeMex.invoke(pxeRequest);
+ } else {
+ success = false;
}
} catch(Exception e) {
e.printStackTrace();
@@ -162,6 +163,13 @@
callback.onResponse(mex);
_waitingCallbacks.remove(mex.getClientId());
}
+ }
+
+ public boolean respondsTo(QName serviceName, QName portTypeName) {
+ boolean result = _serviceName.equals(serviceName);
+ result = result && _wsdlDef.getService(_serviceName).getPort(_portName)
+ .getBinding().getPortType().getQName().equals(portTypeName);
+ return result;
}
private void onResponse(MyRoleMessageExchange mex, MessageContext
msgContext) throws AxisFault {
Modified:
incubator/ode/scratch/pxe-iapi/axis2/src/main/java/com/fs/pxe/axis2/hooks/PXEAxisDispatcher.java
URL:
http://svn.apache.org/viewvc/incubator/ode/scratch/pxe-iapi/axis2/src/main/java/com/fs/pxe/axis2/hooks/PXEAxisDispatcher.java?rev=424028&r1=424027&r2=424028&view=diff
==============================================================================
---
incubator/ode/scratch/pxe-iapi/axis2/src/main/java/com/fs/pxe/axis2/hooks/PXEAxisDispatcher.java
(original)
+++
incubator/ode/scratch/pxe-iapi/axis2/src/main/java/com/fs/pxe/axis2/hooks/PXEAxisDispatcher.java
Thu Jul 20 12:26:54 2006
@@ -62,11 +62,11 @@
// 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()) {
+ if (index >=0 && index + "Request".length() == localName.length())
{
return service.getOperation(new QName(localName.substring(0,
index)));
}
index = localName.lastIndexOf("Response");
- if (index + "Response".length() == localName.length()) {
+ if (index >=0 && index + "Response".length() ==
localName.length()) {
return service.getOperation(new QName(localName.substring(0,
index)));
}
}
@@ -103,7 +103,6 @@
public void initDispatcher() {
init(new HandlerDescription(NAME));
}
-
/**
* Obtain the service name from the request URL. The request URL is
Modified:
incubator/ode/scratch/pxe-iapi/axis2/src/main/java/com/fs/pxe/axis2/hooks/PXEAxisService.java
URL:
http://svn.apache.org/viewvc/incubator/ode/scratch/pxe-iapi/axis2/src/main/java/com/fs/pxe/axis2/hooks/PXEAxisService.java?rev=424028&r1=424027&r2=424028&view=diff
==============================================================================
---
incubator/ode/scratch/pxe-iapi/axis2/src/main/java/com/fs/pxe/axis2/hooks/PXEAxisService.java
(original)
+++
incubator/ode/scratch/pxe-iapi/axis2/src/main/java/com/fs/pxe/axis2/hooks/PXEAxisService.java
Thu Jul 20 12:26:54 2006
@@ -7,6 +7,9 @@
import org.apache.axis2.engine.AxisConfiguration;
import javax.wsdl.Definition;
+import javax.wsdl.Port;
+import javax.wsdl.extensions.ExtensibilityElement;
+import javax.wsdl.extensions.soap.SOAPAddress;
import javax.xml.namespace.QName;
import java.util.Iterator;
@@ -19,11 +22,13 @@
public static AxisService createService(AxisConfiguration axisConfig,
Definition wsdlDefinition,
QName wsdlServiceName, String
portName) throws AxisFault {
+ String serviceName = extractServiceName(wsdlDefinition, wsdlServiceName,
portName);
+
WSDL2AxisServiceBuilder serviceBuilder =
new WSDL2AxisServiceBuilder(wsdlDefinition, wsdlServiceName,
portName);
serviceBuilder.setServerSide(true);
AxisService axisService = serviceBuilder.populateService();
- axisService.setName(wsdlServiceName.getLocalPart());
+ axisService.setName(serviceName);
axisService.setWsdlfound(true);
axisService.setClassLoader(axisConfig.getServiceClassLoader());
@@ -37,4 +42,49 @@
}
return axisService;
}
+
+ private static String extractServiceName(Definition wsdlDefinition, QName
wsdlServiceName, String portName) throws AxisFault {
+ String url = null;
+ Port port = wsdlDefinition.getService(wsdlServiceName).getPort(portName);
+ for (Object oext : port.getExtensibilityElements()) {
+ if (oext instanceof SOAPAddress)
+ url = ((SOAPAddress)oext).getLocationURI();
+ }
+ if (url == null) {
+ throw new AxisFault("Could not extract any soap:address from service
WSDL definition " + wsdlServiceName +
+ " (necessary to establish the process target address)!");
+ }
+ String serviceName = parseURLForService(url);
+ if (serviceName == null) {
+ throw new AxisFault("The soap:address used for service WSDL definition "
+ wsdlServiceName +
+ " and port " + portName + " should be of the form
http://hostname:port/pxe/processes/myProcessEndpointName");
+ }
+ return serviceName;
+ }
+
+ /**
+ * 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 static String parseURLForService(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/epr/WSAEndpoint.java
URL:
http://svn.apache.org/viewvc/incubator/ode/scratch/pxe-iapi/bpel-api/src/main/java/com/fs/pxe/bpel/epr/WSAEndpoint.java?rev=424028&r1=424027&r2=424028&view=diff
==============================================================================
---
incubator/ode/scratch/pxe-iapi/bpel-api/src/main/java/com/fs/pxe/bpel/epr/WSAEndpoint.java
(original)
+++
incubator/ode/scratch/pxe-iapi/bpel-api/src/main/java/com/fs/pxe/bpel/epr/WSAEndpoint.java
Thu Jul 20 12:26:54 2006
@@ -74,6 +74,16 @@
return null;
}
+ public String getPortName() {
+ NodeList metadataList =
_eprElmt.getElementsByTagNameNS(Namespaces.WS_ADDRESSING_NS, "Metadata");
+ if (metadataList.getLength() > 0) {
+ Element metadata = (Element) metadataList.item(0);
+ Element service = DOMUtils.getFirstChildElement(metadata);
+ return service.getAttribute("EndpointName");
+ }
+ return null;
+ }
+
public boolean accept(Node node) {
if (node.getNodeType() == Node.ELEMENT_NODE) {
Element elmt = (Element)node;