Author: objectiser
Date: 2010-02-10 11:06:07 -0500 (Wed, 10 Feb 2010)
New Revision: 493
Added:
trunk/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/ws/BaseWebServiceEndpoint.java
trunk/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/ws/TemplateWebServiceEndpoint.java
Removed:
trunk/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/ws/AbstractWebServiceEndpoint.java
Modified:
trunk/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/ws/EndpointManager.java
trunk/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/ws/WebServiceProviderFactory.java
Log:
RIFTSAW-123 - fixed index out of bounds problem. CXF expects the jaxws provider
implementation to directly implement the Provider<?> interface - whereas this was
being defined in a superclass - which jbossws-native was fine with. Although this problem
has been fixed, 13 of the 20 integration tests still fail due to other reasons that still
need to be investigated - so if necessary other bugs will be raised for these.
Deleted:
trunk/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/ws/AbstractWebServiceEndpoint.java
===================================================================
---
trunk/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/ws/AbstractWebServiceEndpoint.java 2010-02-09
16:20:36 UTC (rev 492)
+++
trunk/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/ws/AbstractWebServiceEndpoint.java 2010-02-10
16:06:07 UTC (rev 493)
@@ -1,211 +0,0 @@
-/*
- * 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;
-
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.jboss.soa.bpel.runtime.engine.BPELEngine;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-import javax.wsdl.Definition;
-import javax.wsdl.Operation;
-import javax.wsdl.WSDLException;
-import javax.wsdl.factory.WSDLFactory;
-import javax.wsdl.xml.WSDLReader;
-import javax.xml.namespace.QName;
-import javax.xml.soap.*;
-import javax.xml.ws.Provider;
-
-/**
- * Base class for BPEL endpoints that are created through javassist.
- * Represents a JAX-WS {@link javax.xml.ws.Provider} implementation.
- *
- * @see org.jboss.soa.bpel.runtime.ws.WebServiceProviderFactory
- *
- * @author Heiko.Braun <heiko.braun(a)jboss.com>
- */
-public abstract class AbstractWebServiceEndpoint implements Provider<SOAPMessage>
-{
- protected final Log log = LogFactory.getLog(getClass());
-
- private SOAPMessageAdapter soapAdapter;
- private QName serviceQName;
- private Definition wsdlDefinition;
-
- private boolean isInitialized;
-
- private void init()
- {
- if(!isInitialized)
- {
- try
- {
- WSDLReader wsdlReader = WSDLFactory.newInstance().newWSDLReader();
- this.wsdlDefinition = wsdlReader.readWSDL(getWsdlLocation());
- this.serviceQName = QName.valueOf(getServiceName());
- this.soapAdapter = new SOAPMessageAdapter(wsdlDefinition, serviceQName,
getPortName());
- }
- catch (WSDLException e)
- {
- throw new RuntimeException("Failed to parse WSDL", e);
- }
- isInitialized = true;
- }
- }
-
- public SOAPMessage invoke(SOAPMessage soapMessage)
- {
- log.debug("Invoking endpoint "+getEndpointId());
- init();
-
- try
- {
- SOAPPart soapPart = soapMessage.getSOAPPart();
- SOAPEnvelope soapEnvelope = soapPart.getEnvelope();
- Element messageElement = getMessagePayload(soapEnvelope);
-
- if(log.isDebugEnabled())
- log.debug( "ODE inbound message: \n" +DOMWriter.printNode(soapEnvelope,
true) );
-
- // Create invocation context
- final String operationName = resolveOperationName(messageElement);
-
- WSInvocationAdapter invocationContext = new WSInvocationAdapter(
- operationName,
- serviceQName,
- getPortName(),
- soapAdapter
- );
- invocationContext.setSOAPMessage(soapMessage);
-
- // Invoke ODE
- getEngine().invoke(invocationContext);
-
- // Handle response
- SOAPMessage responseMessage = null;
-
- if (isResponseExpected(messageElement)) {
- responseMessage = invocationContext.getInvocationResult();
-
- if(log.isDebugEnabled())
- log.debug( "ODE outbound message: \n" +
- DOMWriter.printNode(responseMessage.getSOAPPart().getEnvelope(), true)
- );
- } else if (log.isDebugEnabled()) {
- log.debug( "ODE no outbound message");
- }
-
- return responseMessage;
- }
- catch (Exception e)
- {
- throw new RuntimeException("Failed to invoke BPEL process", e);
- }
- }
-
- public String resolveOperationName(Element payload)
- {
- if(soapAdapter.isRPC())
- {
- return payload.getLocalName();
- }
- else
- {
- QName elementName = new QName(payload.getNamespaceURI(), payload.getLocalName());
- Operation op = new WSDLParser(wsdlDefinition).getDocLitOperation(
- this.serviceQName, getPortName(), elementName
- );
-
- return op.getName();
- }
- }
-
- public boolean isResponseExpected(Element payload)
- {
- Operation op=null;
-
- if(soapAdapter.isRPC())
- {
- QName elementName = new QName(payload.getNamespaceURI(),
payload.getLocalName());
- op = new WSDLParser(wsdlDefinition).getRPCOperation(
- this.serviceQName, getPortName(), elementName
- );
- }
- else
- {
- QName elementName = new QName(payload.getNamespaceURI(), payload.getLocalName());
- op = new WSDLParser(wsdlDefinition).getDocLitOperation(
- this.serviceQName, getPortName(), elementName
- );
- }
-
- if (op == null) {
- throw new RuntimeException("Failed to locate operation definition for:
"+payload);
- }
-
- return op.getOutput() != null;
- }
-
- public static Element getMessagePayload(SOAPEnvelope soapEnvelope)
- throws SOAPException
- {
- SOAPBody body = soapEnvelope.getBody();
- Element messageElement = null; // first child of type Element
- NodeList children = body.getChildNodes();
- for(int i=0; i<children.getLength(); i++)
- {
- Node tmp = children.item(i);
- if(Node.ELEMENT_NODE == tmp.getNodeType())
- {
- messageElement = (Element)tmp;
- break;
- }
- }
- return messageElement;
- }
-
- public abstract String getEndpointId();
-
- public abstract String getServiceName();
-
- public abstract String getWsdlLocation();
-
- public abstract String getPortName();
-
- private BPELEngine getEngine()
- {
- try
- {
- InitialContext ctx = new InitialContext();
- return (BPELEngine)ctx.lookup("bpel/Engine");
- }
- catch (NamingException e)
- {
- throw new RuntimeException("Failed to initialize BPEL engine");
- }
- }
-}
Copied:
trunk/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/ws/BaseWebServiceEndpoint.java
(from rev 487,
trunk/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/ws/AbstractWebServiceEndpoint.java)
===================================================================
---
trunk/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/ws/BaseWebServiceEndpoint.java
(rev 0)
+++
trunk/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/ws/BaseWebServiceEndpoint.java 2010-02-10
16:06:07 UTC (rev 493)
@@ -0,0 +1,219 @@
+/*
+ * 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;
+
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.jboss.soa.bpel.runtime.engine.BPELEngine;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import javax.wsdl.Definition;
+import javax.wsdl.Operation;
+import javax.wsdl.WSDLException;
+import javax.wsdl.factory.WSDLFactory;
+import javax.wsdl.xml.WSDLReader;
+import javax.xml.namespace.QName;
+import javax.xml.soap.*;
+import javax.xml.ws.Provider;
+
+/**
+ * Base class for BPEL endpoints that are created through javassist.
+ * Represents a JAX-WS {@link javax.xml.ws.Provider} implementation.
+ *
+ * @see org.jboss.soa.bpel.runtime.ws.WebServiceProviderFactory
+ *
+ * @author Heiko.Braun <heiko.braun(a)jboss.com>
+ */
+public class BaseWebServiceEndpoint implements Provider<SOAPMessage>
+{
+ protected final Log log = LogFactory.getLog(getClass());
+
+ private SOAPMessageAdapter soapAdapter;
+ private QName serviceQName;
+ private Definition wsdlDefinition;
+
+ private boolean isInitialized;
+
+ private void init()
+ {
+ if(!isInitialized)
+ {
+ try
+ {
+ WSDLReader wsdlReader = WSDLFactory.newInstance().newWSDLReader();
+ this.wsdlDefinition = wsdlReader.readWSDL(getWsdlLocation());
+ this.serviceQName = QName.valueOf(getServiceName());
+ this.soapAdapter = new SOAPMessageAdapter(wsdlDefinition, serviceQName,
getPortName());
+ }
+ catch (WSDLException e)
+ {
+ throw new RuntimeException("Failed to parse WSDL", e);
+ }
+ isInitialized = true;
+ }
+ }
+
+ public SOAPMessage invoke(SOAPMessage soapMessage)
+ {
+ log.debug("Invoking endpoint "+getEndpointId());
+ init();
+
+ try
+ {
+ SOAPPart soapPart = soapMessage.getSOAPPart();
+ SOAPEnvelope soapEnvelope = soapPart.getEnvelope();
+ Element messageElement = getMessagePayload(soapEnvelope);
+
+ if(log.isDebugEnabled())
+ log.debug( "ODE inbound message: \n" +DOMWriter.printNode(soapEnvelope,
true) );
+
+ // Create invocation context
+ final String operationName = resolveOperationName(messageElement);
+
+ WSInvocationAdapter invocationContext = new WSInvocationAdapter(
+ operationName,
+ serviceQName,
+ getPortName(),
+ soapAdapter
+ );
+ invocationContext.setSOAPMessage(soapMessage);
+
+ // Invoke ODE
+ getEngine().invoke(invocationContext);
+
+ // Handle response
+ SOAPMessage responseMessage = null;
+
+ if (isResponseExpected(messageElement)) {
+ responseMessage = invocationContext.getInvocationResult();
+
+ if(log.isDebugEnabled())
+ log.debug( "ODE outbound message: \n" +
+ DOMWriter.printNode(responseMessage.getSOAPPart().getEnvelope(), true)
+ );
+ } else if (log.isDebugEnabled()) {
+ log.debug( "ODE no outbound message");
+ }
+
+ return responseMessage;
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException("Failed to invoke BPEL process", e);
+ }
+ }
+
+ public String resolveOperationName(Element payload)
+ {
+ if(soapAdapter.isRPC())
+ {
+ return payload.getLocalName();
+ }
+ else
+ {
+ QName elementName = new QName(payload.getNamespaceURI(), payload.getLocalName());
+ Operation op = new WSDLParser(wsdlDefinition).getDocLitOperation(
+ this.serviceQName, getPortName(), elementName
+ );
+
+ return op.getName();
+ }
+ }
+
+ public boolean isResponseExpected(Element payload)
+ {
+ Operation op=null;
+
+ if(soapAdapter.isRPC())
+ {
+ QName elementName = new QName(payload.getNamespaceURI(),
payload.getLocalName());
+ op = new WSDLParser(wsdlDefinition).getRPCOperation(
+ this.serviceQName, getPortName(), elementName
+ );
+ }
+ else
+ {
+ QName elementName = new QName(payload.getNamespaceURI(), payload.getLocalName());
+ op = new WSDLParser(wsdlDefinition).getDocLitOperation(
+ this.serviceQName, getPortName(), elementName
+ );
+ }
+
+ if (op == null) {
+ throw new RuntimeException("Failed to locate operation definition for:
"+payload);
+ }
+
+ return op.getOutput() != null;
+ }
+
+ public static Element getMessagePayload(SOAPEnvelope soapEnvelope)
+ throws SOAPException
+ {
+ SOAPBody body = soapEnvelope.getBody();
+ Element messageElement = null; // first child of type Element
+ NodeList children = body.getChildNodes();
+ for(int i=0; i<children.getLength(); i++)
+ {
+ Node tmp = children.item(i);
+ if(Node.ELEMENT_NODE == tmp.getNodeType())
+ {
+ messageElement = (Element)tmp;
+ break;
+ }
+ }
+ return messageElement;
+ }
+
+ public String getEndpointId() {
+ return(null);
+ }
+
+ public String getServiceName() {
+ return(null);
+ }
+
+ public String getWsdlLocation() {
+ return(null);
+ }
+
+ public String getPortName() {
+ return(null);
+ }
+
+ private BPELEngine getEngine()
+ {
+ try
+ {
+ InitialContext ctx = new InitialContext();
+ return (BPELEngine)ctx.lookup("bpel/Engine");
+ }
+ catch (NamingException e)
+ {
+ throw new RuntimeException("Failed to initialize BPEL engine");
+ }
+ }
+}
Modified:
trunk/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/ws/EndpointManager.java
===================================================================
---
trunk/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/ws/EndpointManager.java 2010-02-09
16:20:36 UTC (rev 492)
+++
trunk/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/ws/EndpointManager.java 2010-02-10
16:06:07 UTC (rev 493)
@@ -58,7 +58,7 @@
* This instance is stateful and retains references to both endpoints and clients.
* As such it should only exists once.
*
- * @see org.jboss.soa.bpel.runtime.ws.AbstractWebServiceEndpoint
+ * @see org.jboss.soa.bpel.runtime.ws.BaseWebServiceEndpoint
* @see org.jboss.soa.bpel.runtime.ws.WebServiceClient
* @see org.jboss.soa.bpel.runtime.engine.ode.JAXWSBindingContext
*
@@ -103,7 +103,7 @@
// generate provider impl
WebServiceProviderFactory providerFactory = new WebServiceProviderFactory();
- AbstractWebServiceEndpoint providerImpl =
+ BaseWebServiceEndpoint providerImpl =
providerFactory.createProvider(
metaData.getServiceName(),
metaData.getPortName(),
Added:
trunk/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/ws/TemplateWebServiceEndpoint.java
===================================================================
---
trunk/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/ws/TemplateWebServiceEndpoint.java
(rev 0)
+++
trunk/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/ws/TemplateWebServiceEndpoint.java 2010-02-10
16:06:07 UTC (rev 493)
@@ -0,0 +1,42 @@
+/*
+ * 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;
+
+
+import javax.xml.soap.*;
+import javax.xml.ws.Provider;
+
+/**
+ * CXF requires the JAX-WS implementation class to directly implement the
+ * Provider<SOAPMessage>, rather than be derived from a superclass that
+ * implements it. Therefore this 'template' web service endpoint class
+ * has been created, which will be loaded by javassist and renamed to
+ * be the specific endpoint implementation. This is necessary as
+ * javassist does not provide a way to set a interface that uses generics.
+ *
+ * @see org.jboss.soa.bpel.runtime.ws.WebServiceProviderFactory
+ *
+ */
+public class TemplateWebServiceEndpoint extends BaseWebServiceEndpoint implements
Provider<SOAPMessage>
+{
+ // See RIFTSAW-123 for description of issue related to CXF
+}
Modified:
trunk/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/ws/WebServiceProviderFactory.java
===================================================================
---
trunk/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/ws/WebServiceProviderFactory.java 2010-02-09
16:20:36 UTC (rev 492)
+++
trunk/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/ws/WebServiceProviderFactory.java 2010-02-10
16:06:07 UTC (rev 493)
@@ -35,7 +35,7 @@
* Creates JAX-WS Provider classes using javassist.
* These provider classes can then be deployed to JBossWS in memory.<p>
* The javassist generated class basically just carries the meta data,
- * while the actual implementation resides in {@link
org.jboss.soa.bpel.runtime.ws.AbstractWebServiceEndpoint}
+ * while the actual implementation resides in {@link
org.jboss.soa.bpel.runtime.ws.BaseWebServiceEndpoint}
*
* @author Heiko.Braun <heiko.braun(a)jboss.com>
*/
@@ -43,7 +43,7 @@
{
private final static String PKG_PREFIX =
WebServiceProviderFactory.class.getPackage().getName()+".";
- public AbstractWebServiceEndpoint createProvider(
+ public BaseWebServiceEndpoint createProvider(
QName service, String port,
String endpointId,
WSDLReference wsdlRef,
@@ -61,7 +61,15 @@
CtClass stringType = pool.get("java.lang.String");
String implClassName = PKG_PREFIX+"BPELWebServiceEndpoint_"+endpointId;
- CtClass impl = pool.makeClass(implClassName);
+ //CtClass impl = pool.makeClass(implClassName);
+
+ // Load an existing class representing the template for a Web Service provider
+ // This was necessary, as javassist does not provide a way to set an implemented
+ // interface that supports generics. Although the super class
(AbstractWebServiceEndpoint)
+ // implements this Provider<SOAPMessage> interface, CXF requires the actual web
service
+ // implementation class to directly define this interface. (RIFTSAW-123)
+ CtClass impl =
pool.get("org.jboss.soa.bpel.runtime.ws.TemplateWebServiceEndpoint");
+ impl.setName(implClassName);
// AbstractWebServiceEndpoint.endpointId property
CtField idField = new CtField(stringType, "endpointId", impl);
@@ -134,9 +142,6 @@
classFile.addAttribute(attr);
- // Provider interface and base implementation
-
impl.setSuperclass(pool.get("org.jboss.soa.bpel.runtime.ws.AbstractWebServiceEndpoint"));
-
createStringGetter(impl, stringType, "endpointId",
"getEndpointId");
createStringGetter(impl, stringType, "serviceName",
"getServiceName");
createStringGetter(impl, stringType, "wsdlLocation",
"getWsdlLocation");
@@ -151,7 +156,8 @@
// test it
Class clazz = loader.loadClass(implClassName);
- AbstractWebServiceEndpoint obj = (AbstractWebServiceEndpoint)clazz.newInstance();
+
+ BaseWebServiceEndpoint obj = (BaseWebServiceEndpoint)clazz.newInstance();
return obj;
}
@@ -172,6 +178,7 @@
body.append("}");
method.setBody(body.toString());
+
impl.addMethod(method);
}