[jboss-svn-commits] JBL Code SVN: r34787 - in labs/jbossesb/branches/JBESB_4_9_CP/product: lib/ext and 5 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Thu Aug 19 07:04:37 EDT 2010
Author: mageshbk at jboss.com
Date: 2010-08-19 07:04:37 -0400 (Thu, 19 Aug 2010)
New Revision: 34787
Added:
labs/jbossesb/branches/JBESB_4_9_CP/product/lib/ext/cxf-api-2.2.9.jar
labs/jbossesb/branches/JBESB_4_9_CP/product/lib/ext/cxf-common-utilities-2.2.9.jar
labs/jbossesb/branches/JBESB_4_9_CP/product/lib/ext/cxf-rt-core-2.2.9.jar
labs/jbossesb/branches/JBESB_4_9_CP/product/lib/ext/cxf-rt-transports-http-2.2.9.jar
labs/jbossesb/branches/JBESB_4_9_CP/product/lib/ext/jbossws-cxf-server.jar
labs/jbossesb/branches/JBESB_4_9_CP/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/adapter/SOAPProcessorFactory.java
labs/jbossesb/branches/JBESB_4_9_CP/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/adapter/cxf/
labs/jbossesb/branches/JBESB_4_9_CP/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/adapter/cxf/JBossWSCXFFactory.java
labs/jbossesb/branches/JBESB_4_9_CP/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/adapter/cxf/SOAPProcessorCXFServletContext.java
labs/jbossesb/branches/JBESB_4_9_CP/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/adapter/cxf/SOAPProcessorServletTransportFactory.java
labs/jbossesb/branches/JBESB_4_9_CP/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/adapter/wsnative/
labs/jbossesb/branches/JBESB_4_9_CP/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/adapter/wsnative/JBossWSNativeFactory.java
Removed:
labs/jbossesb/branches/JBESB_4_9_CP/product/lib/ext/cxf-api-2.2.6.jar
labs/jbossesb/branches/JBESB_4_9_CP/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/AbstractSOAPProcessor.java
labs/jbossesb/branches/JBESB_4_9_CP/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/CXFSOAPProcessor.java
labs/jbossesb/branches/JBESB_4_9_CP/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/NativeSOAPProcessor.java
Modified:
labs/jbossesb/branches/JBESB_4_9_CP/product/docs/Programmers_Guide/en-US/OOB-Actions/OOB_Actions_webservices_SOAP.xml
labs/jbossesb/branches/JBESB_4_9_CP/product/services/base-project-build.xml
labs/jbossesb/branches/JBESB_4_9_CP/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/SOAPProcessor.java
labs/jbossesb/branches/JBESB_4_9_CP/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/adapter/SOAPProcessorHttpServletRequest.java
labs/jbossesb/branches/JBESB_4_9_CP/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/adapter/SOAPProcessorHttpServletResponse.java
Log:
[JBESB-3405] - Update SOAPProcessor to invoke CXF endpoints using RequestHandler SPI
Modified: labs/jbossesb/branches/JBESB_4_9_CP/product/docs/Programmers_Guide/en-US/OOB-Actions/OOB_Actions_webservices_SOAP.xml
===================================================================
--- labs/jbossesb/branches/JBESB_4_9_CP/product/docs/Programmers_Guide/en-US/OOB-Actions/OOB_Actions_webservices_SOAP.xml 2010-08-19 09:30:37 UTC (rev 34786)
+++ labs/jbossesb/branches/JBESB_4_9_CP/product/docs/Programmers_Guide/en-US/OOB-Actions/OOB_Actions_webservices_SOAP.xml 2010-08-19 11:04:37 UTC (rev 34787)
@@ -96,9 +96,14 @@
process(Message) method. It can access the current Message instance via
the SOAPProcessor.getMessage() method and can change the Message instance
via the SOAPProcessor.setMessage(Message) method. This means that JBossWS-Native Webservice
- endpoints exposed via this action are "ESB Message Aware". However, JBossWS-CXF
- Webservice endpoints are not "ESB Message Aware".
+ endpoints exposed via this action are "ESB Message Aware".
</para>
+ <caution>
+ <para>
+ This feature has been deprecated and may no longer be available in future releases.
+ Users are not encouraged to rely on this feature.
+ </para>
+ </caution>
</section>
<section id="sect-webservicessoap-webservice-endpoint-deployment">
Deleted: labs/jbossesb/branches/JBESB_4_9_CP/product/lib/ext/cxf-api-2.2.6.jar
===================================================================
(Binary files differ)
Added: labs/jbossesb/branches/JBESB_4_9_CP/product/lib/ext/cxf-api-2.2.9.jar
===================================================================
(Binary files differ)
Property changes on: labs/jbossesb/branches/JBESB_4_9_CP/product/lib/ext/cxf-api-2.2.9.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: labs/jbossesb/branches/JBESB_4_9_CP/product/lib/ext/cxf-common-utilities-2.2.9.jar
===================================================================
(Binary files differ)
Property changes on: labs/jbossesb/branches/JBESB_4_9_CP/product/lib/ext/cxf-common-utilities-2.2.9.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: labs/jbossesb/branches/JBESB_4_9_CP/product/lib/ext/cxf-rt-core-2.2.9.jar
===================================================================
(Binary files differ)
Property changes on: labs/jbossesb/branches/JBESB_4_9_CP/product/lib/ext/cxf-rt-core-2.2.9.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: labs/jbossesb/branches/JBESB_4_9_CP/product/lib/ext/cxf-rt-transports-http-2.2.9.jar
===================================================================
(Binary files differ)
Property changes on: labs/jbossesb/branches/JBESB_4_9_CP/product/lib/ext/cxf-rt-transports-http-2.2.9.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: labs/jbossesb/branches/JBESB_4_9_CP/product/lib/ext/jbossws-cxf-server.jar
===================================================================
(Binary files differ)
Property changes on: labs/jbossesb/branches/JBESB_4_9_CP/product/lib/ext/jbossws-cxf-server.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: labs/jbossesb/branches/JBESB_4_9_CP/product/services/base-project-build.xml
===================================================================
--- labs/jbossesb/branches/JBESB_4_9_CP/product/services/base-project-build.xml 2010-08-19 09:30:37 UTC (rev 34786)
+++ labs/jbossesb/branches/JBESB_4_9_CP/product/services/base-project-build.xml 2010-08-19 11:04:37 UTC (rev 34787)
@@ -73,7 +73,11 @@
<target name="compile" depends="base-compile, service-compile"/>
<target name="base-compile" depends="prepare">
+ <condition property="jdk5.excludes" value="org\jboss\soa\esb\actions\soap\adapter\cxf\*">
+ <equals arg1="${ant.java.version}" arg2="1.5"/>
+ </condition>
<javac srcdir="src/main/java" destdir="build/classes" debug="on" >
+ <exclude name="${jdk5.excludes}"/>
<classpath refid="classpath" />
</javac>
</target>
Deleted: labs/jbossesb/branches/JBESB_4_9_CP/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/AbstractSOAPProcessor.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_9_CP/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/AbstractSOAPProcessor.java 2010-08-19 09:30:37 UTC (rev 34786)
+++ labs/jbossesb/branches/JBESB_4_9_CP/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/AbstractSOAPProcessor.java 2010-08-19 11:04:37 UTC (rev 34787)
@@ -1,84 +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.esb.actions.soap;
-
-import java.io.UnsupportedEncodingException;
-
-import org.jboss.soa.esb.ConfigurationException;
-import org.jboss.soa.esb.actions.ActionProcessingException;
-import org.jboss.soa.esb.actions.ActionUtils;
-import org.jboss.soa.esb.helpers.ConfigTree;
-import org.jboss.soa.esb.listeners.message.MessageDeliverException;
-import org.jboss.soa.esb.message.Message;
-import org.jboss.soa.esb.message.MessagePayloadProxy;
-import org.jboss.soa.esb.message.ResponseStatus;
-import org.jboss.soa.esb.message.body.content.BytesBody;
-
-/**
- * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
- * @author <a href="mageshbk at jboss.com">Magesh Kumar B</a>
- */
-public abstract class AbstractSOAPProcessor {
-
- protected String jbossws_endpoint;
- protected MessagePayloadProxy payloadProxy;
- protected boolean httpResponseStatusEnabled;
-
- /**
- * Public constructor.
- * @param config Configuration.
- * @throws ConfigurationException "jbossws-endpoint" not specified.
- */
- public AbstractSOAPProcessor(ConfigTree config) throws ConfigurationException {
- jbossws_endpoint = config.getRequiredAttribute(WebServiceUtils.JBOSSWS_ENDPOINT);
- payloadProxy = new MessagePayloadProxy(config,
- new String[] {BytesBody.BYTES_LOCATION, ActionUtils.POST_ACTION_DATA},
- new String[] {ActionUtils.POST_ACTION_DATA});
- httpResponseStatusEnabled = ResponseStatus.isHttpEnabled(config);
- }
-
- public abstract Message process(Message message) throws ActionProcessingException;
-
- protected byte[] getSOAPMessagePayload(Message message) throws ActionProcessingException {
- byte[] soapMessage;
- Object messagePayload;
-
- try {
- messagePayload = payloadProxy.getPayload(message);
- } catch (MessageDeliverException e) {
- throw new ActionProcessingException(e);
- }
-
- if(messagePayload instanceof byte[]) {
- soapMessage = (byte[])messagePayload;
- } else if(messagePayload instanceof String) {
- try {
- soapMessage = ((String)messagePayload).getBytes("UTF-8");
- } catch (UnsupportedEncodingException e) {
- throw new ActionProcessingException("Unable to decode SOAP message payload.", e);
- }
- } else {
- throw new ActionProcessingException("Unable to decode SOAP message payload. Must be either a byte[] or java.lang.String.");
- }
- return soapMessage;
- }
-}
Deleted: labs/jbossesb/branches/JBESB_4_9_CP/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/CXFSOAPProcessor.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_9_CP/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/CXFSOAPProcessor.java 2010-08-19 09:30:37 UTC (rev 34786)
+++ labs/jbossesb/branches/JBESB_4_9_CP/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/CXFSOAPProcessor.java 2010-08-19 11:04:37 UTC (rev 34787)
@@ -1,236 +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.esb.actions.soap;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.net.URL;
-import java.util.Iterator;
-
-import javax.wsdl.Definition;
-import javax.wsdl.Operation;
-import javax.wsdl.OperationType;
-import javax.wsdl.Port;
-import javax.xml.namespace.QName;
-import javax.xml.soap.MessageFactory;
-import javax.xml.soap.MimeHeaders;
-import javax.xml.soap.SOAPBody;
-import javax.xml.soap.SOAPElement;
-import javax.xml.soap.SOAPException;
-import javax.xml.soap.SOAPHeader;
-import javax.xml.soap.SOAPMessage;
-import javax.xml.ws.Dispatch;
-import javax.xml.ws.Service;
-import javax.xml.ws.soap.AddressingFeature;
-
-import org.jboss.internal.soa.esb.webservice.addressing.AddressingConstants;
-import org.jboss.soa.esb.ConfigurationException;
-import org.jboss.soa.esb.actions.ActionProcessingException;
-import org.jboss.soa.esb.helpers.ConfigTree;
-import org.jboss.soa.esb.message.Message;
-import org.jboss.soa.esb.message.Properties;
-import org.jboss.soa.esb.message.ResponseHeader;
-import org.jboss.wsf.spi.deployment.Endpoint;
-import org.xml.sax.InputSource;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-
-/**
- * JBossWS-CXF SOAP Processor.
- *
- * @author <a href="mageshbk at jboss.com">Magesh Kumar B</a>
- */
-public class CXFSOAPProcessor extends AbstractSOAPProcessor {
-
- Dispatch<SOAPMessage> dispatcher;
- Port port;
-
- public CXFSOAPProcessor(ConfigTree config) throws ConfigurationException {
- super(config);
- }
-
- /**
- * Process the SOAP message.
- * <p/>
- * Invokes the JBossWS-CXF endpoint over HTTP and writes the SOAP response back into the message payload.
- * @param message The ESB Aware (normalized) SOAP request message.
- * @return The SOAP response message.
- * @throws ActionProcessingException
- */
- public Message process(Message message) throws ActionProcessingException {
- byte[] byteMessage;
-
- if (dispatcher == null) {
- Endpoint endpoint = WebServiceUtils.getServiceEndpoint(jbossws_endpoint);
- if(endpoint == null) {
- throw new ActionProcessingException("Unknown Service Endpoint '" + jbossws_endpoint + "'.");
- }
- try
- {
- String wsdlLocation = WebServiceUtils.getWsdlLocation(endpoint);
- URL wsdlUrl = new URL(wsdlLocation);
- Definition definition = WebServiceUtils.readWSDL(wsdlUrl);
- javax.wsdl.Service wsdlService = (javax.wsdl.Service)definition.getServices().values().iterator().next();
- QName serviceName = wsdlService.getQName();
- port = (Port)wsdlService.getPorts().values().iterator().next();
- QName portName = new QName(definition.getTargetNamespace(), port.getName());
-
- Service service = Service.create(wsdlUrl, serviceName);
- // CXF dispatcher will create duplicate WS-Addressing headers if not set to false
- // As we are handling the SOAP MESSAGE from ESB clients directly we do not need to create it here
- dispatcher = service.createDispatch(portName, SOAPMessage.class, Service.Mode.MESSAGE, new AddressingFeature(false, false));
- }
- catch (Exception e)
- {
- throw new ActionProcessingException(e);
- }
- }
-
- byteMessage = getSOAPMessagePayload(message);
- try {
- MimeHeaders headers = new MimeHeaders();
- final Properties properties = message.getProperties() ;
- final String[] names = properties.getNames() ;
- for(final String name: names)
- {
- final Object value = properties.getProperty(name) ;
- if (value != null && value instanceof String)
- {
- if ("content-type".equals(name) && "application/octet-stream".equals(value))
- continue;
- else
- headers.addHeader(name, (String)value);
- }
- }
-
- SOAPMessage soapMessage = MessageFactory.newInstance().createMessage(headers, new ByteArrayInputStream(byteMessage));
- final Properties responseProperties = message.getProperties();
-
- if (isMessageOneWay(soapMessage)) {
- dispatcher.invokeOneWay(soapMessage);
- //return empty response
- responseProperties.setProperty("Content-Type", "text/xml");
- payloadProxy.setPayload(message, "");
- }
- else {
- SOAPMessage response = dispatcher.invoke(soapMessage);
-
- final byte[] responseData = getSoapMessageBytes(response);
- final String[] contentTypeHeader = response.getMimeHeaders().getHeader("Content-Type");
- String contentType = null;
- if (contentTypeHeader != null && contentTypeHeader.length > 0) {
- contentType = response.getMimeHeaders().getHeader("Content-Type")[0];
- }
-
- if(contentType != null) {
- responseProperties.setProperty("Content-Type", new ResponseHeader("Content-Type", contentType));
- } else {
- responseProperties.setProperty("Content-Type", new ResponseHeader("Content-Type", "text/xml"));
- }
-
- if ((contentType != null) && contentType.startsWith("multipart/")) {
- payloadProxy.setPayload(message, responseData) ;
- } else if (contentType != null) {
- String charset = null;
- if (contentType.indexOf("charset=") > 0) {
- charset = contentType.substring(contentType.indexOf("charset=") + 8);
- }
- if (charset == null) {
- payloadProxy.setPayload(message, new String(responseData));
- } else {
- payloadProxy.setPayload(message, new String(responseData, charset));
- }
- } else {
- payloadProxy.setPayload(message, new String(responseData));
- }
- }
- } catch (Exception ex) {
- throw new ActionProcessingException("Cannot process SOAP request", ex);
- }
-
- return message;
- }
-
- /**
- * Convert the SOAPMessage to bytes.
- *
- * @param soapMessage The SOAP message.
- * @return bytes.
- */
- protected static byte[] getSoapMessageBytes(SOAPMessage soapMessage) throws ActionProcessingException
- {
- try
- {
- ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
- soapMessage.writeTo(outputStream);
- byte[] byteArray = outputStream.toByteArray();
- return byteArray;
- }
- catch (Exception e)
- {
- throw new ActionProcessingException("Error in converting SOAPMessage into bytes");
- }
- }
-
- /**
- * Check if we are invoking a @Oneway annotated method.
- *
- * @param soapMessage The SOAP message.
- * @return True if there is no response to be expected.
- */
- private boolean isMessageOneWay(SOAPMessage soapMessage) throws SOAPException
- {
- boolean isOneWay = false;
- // Overloaded methods not supported
- // Encrypted messages will be treated as request-response as it cannot be decrypted
- Operation operation = port.getBinding().getPortType().getOperation(getOperationName(soapMessage), null, null);
- if (operation != null)
- isOneWay = operation.getStyle().equals(OperationType.ONE_WAY);
- return isOneWay;
- }
-
- /**
- * Retrives the operation name from the SOAP Envelope.
- *
- * @param soapMessage The SOAP message.
- * @return The operation name.
- */
- private static String getOperationName(SOAPMessage soapMessage) throws SOAPException
- {
- String operationName = null;
- SOAPBody body = soapMessage.getSOAPPart().getEnvelope().getBody();
- if (body != null)
- {
- Iterator<Node> nodes = body.getChildElements();
- Node node = null;
- while (nodes.hasNext())
- {
- node = nodes.next();
- if (node instanceof Element)
- {
- operationName = node.getLocalName();
- }
- }
- }
- return operationName;
- }
-}
\ No newline at end of file
Deleted: labs/jbossesb/branches/JBESB_4_9_CP/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/NativeSOAPProcessor.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_9_CP/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/NativeSOAPProcessor.java 2010-08-19 09:30:37 UTC (rev 34786)
+++ labs/jbossesb/branches/JBESB_4_9_CP/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/NativeSOAPProcessor.java 2010-08-19 11:04:37 UTC (rev 34787)
@@ -1,166 +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.esb.actions.soap;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.jboss.soa.esb.ConfigurationException;
-import org.jboss.soa.esb.actions.ActionProcessingException;
-import org.jboss.soa.esb.helpers.ConfigTree;
-import org.jboss.soa.esb.actions.soap.adapter.SOAPProcessorHttpServletRequest;
-import org.jboss.soa.esb.actions.soap.adapter.SOAPProcessorHttpServletResponse;
-import org.jboss.soa.esb.actions.soap.adapter.SOAPProcessorServletContext;
-import org.jboss.soa.esb.message.Message;
-import org.jboss.soa.esb.message.Properties;
-import org.jboss.soa.esb.message.ResponseHeader;
-import org.jboss.soa.esb.message.ResponseStatus;
-import org.jboss.wsf.spi.deployment.Endpoint;
-import org.jboss.wsf.spi.invocation.RequestHandler;
-
-/**
- * JBossWS-Native SOAP Processor.
- *
- * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
- * @author <a href="mageshbk at jboss.com">Magesh Kumar B</a>
- */
-public class NativeSOAPProcessor extends AbstractSOAPProcessor {
-
- public NativeSOAPProcessor(ConfigTree config) throws ConfigurationException {
- super(config);
- }
-
- /**
- * Process the SOAP message.
- * <p/>
- * Invokes the JBossWS-Native endpoint internally and writes the SOAP response back into the message payload.
- * @param message The ESB Aware (normalized) SOAP request message.
- * @return The SOAP response message.
- * @throws ActionProcessingException
- */
- public Message process(Message message) throws ActionProcessingException {
- Endpoint endpoint = WebServiceUtils.getServiceEndpoint(jbossws_endpoint);
- byte[] soapMessage;
-
- if(endpoint == null) {
- throw new ActionProcessingException("Unknown Service Endpoint '" + jbossws_endpoint + "'.");
- }
-
- soapMessage = getSOAPMessagePayload(message);
- try {
- SOAPProcessor.setMessage(message);
-
- RequestHandler requestHandler = endpoint.getRequestHandler();
-
- final Map<String, List<String>> headers = new HashMap<String, List<String>>() ;
- final Properties properties = message.getProperties() ;
- final String[] names = properties.getNames() ;
- for(final String name: names)
- {
- final Object value = properties.getProperty(name) ;
- if (value != null)
- {
- final String normalisedName = name.toLowerCase() ;
- final List<String> values = headers.get(normalisedName) ;
- if (values == null)
- {
- final List<String> newValues = new ArrayList<String>() ;
- newValues.add(value.toString()) ;
- headers.put(normalisedName, newValues) ;
- }
- else
- {
- values.add(value.toString()) ;
- }
- }
- }
-
- final String requestContentType = getHeaderValue(headers, "content-type") ;
- if ("application/octet-stream".equals(requestContentType))
- {
- headers.remove("content-type") ;
- }
- final String path = getHeaderValue(headers, "path") ;
- final SOAPProcessorHttpServletRequest servletRequest = new SOAPProcessorHttpServletRequest(path, soapMessage, headers) ;
- final SOAPProcessorHttpServletResponse servletResponse = new SOAPProcessorHttpServletResponse() ;
- final SOAPProcessorServletContext servletContext = new SOAPProcessorServletContext() ;
- requestHandler.handleHttpRequest(endpoint, servletRequest, servletResponse, servletContext) ;
-
- // This may have been changed, make sure we get the current version.
- message = SOAPProcessor.getMessage();
- final Properties responseProperties = message.getProperties() ;
- final String contentType = servletResponse.getContentType() ;
- final Map<String, List<String>> responseHeaders = servletResponse.getHeaders() ;
- // We deal with Content-Type below
- // HTTP Headers *should* be case-insensitive but not with JBR
- responseHeaders.remove("content-type") ;
-
- for(Map.Entry<String, List<String>> header: responseHeaders.entrySet())
- {
- // We can only deal with the first value in the list.
- // JBESB-2511
- new ResponseHeader(header.getKey(), header.getValue().get(0)).setPropertyNameThis(properties);
- }
- // JBESB-2761
- if (httpResponseStatusEnabled) {
- ResponseStatus.setHttpProperties(properties, servletResponse.getStatus(), servletResponse.getStatusMessage());
- }
-
- final byte[] responseData = servletResponse.getContent() ;
- if(contentType != null) {
- responseProperties.setProperty("Content-Type", new ResponseHeader("Content-Type", contentType));
- } else {
- responseProperties.setProperty("Content-Type", new ResponseHeader("Content-Type", "text/xml"));
- }
-
- if ((contentType != null) && contentType.startsWith("multipart/")) {
- payloadProxy.setPayload(message, responseData) ;
- } else {
- final String charset = servletResponse.getCharset() ;
- if (charset == null) {
- payloadProxy.setPayload(message, new String(responseData)) ;
- } else {
- payloadProxy.setPayload(message, new String(responseData, charset)) ;
- }
- }
- } catch (Exception ex) {
- throw new ActionProcessingException("Cannot process SOAP request", ex);
- } finally {
- SOAPProcessor.removeMessage();
- }
-
- return message;
- }
-
- private String getHeaderValue(final Map<String, List<String>> headers,
- final String header)
- {
- final List<String> values = headers.get(header) ;
- if (values != null)
- {
- return values.get(0) ;
- }
- return null ;
- }
-}
Modified: labs/jbossesb/branches/JBESB_4_9_CP/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/SOAPProcessor.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_9_CP/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/SOAPProcessor.java 2010-08-19 09:30:37 UTC (rev 34786)
+++ labs/jbossesb/branches/JBESB_4_9_CP/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/SOAPProcessor.java 2010-08-19 11:04:37 UTC (rev 34787)
@@ -19,13 +19,40 @@
*/
package org.jboss.soa.esb.actions.soap;
+import java.io.UnsupportedEncodingException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.servlet.ServletContext;
+
import org.jboss.internal.soa.esb.publish.Publish;
-import org.jboss.internal.soa.esb.util.JBossDeployerUtil;
import org.jboss.soa.esb.ConfigurationException;
import org.jboss.soa.esb.actions.AbstractActionPipelineProcessor;
import org.jboss.soa.esb.actions.ActionProcessingException;
+import org.jboss.soa.esb.actions.ActionUtils;
+import org.jboss.soa.esb.actions.soap.adapter.SOAPProcessorFactory;
+import org.jboss.soa.esb.actions.soap.adapter.SOAPProcessorHttpServletRequest;
+import org.jboss.soa.esb.actions.soap.adapter.SOAPProcessorHttpServletResponse;
import org.jboss.soa.esb.helpers.ConfigTree;
+import org.jboss.soa.esb.listeners.message.MessageDeliverException;
import org.jboss.soa.esb.message.Message;
+import org.jboss.soa.esb.message.MessagePayloadProxy;
+import org.jboss.soa.esb.message.Properties;
+import org.jboss.soa.esb.message.ResponseHeader;
+import org.jboss.soa.esb.message.ResponseStatus;
+import org.jboss.soa.esb.message.body.content.BytesBody;
+import org.jboss.wsf.spi.SPIProvider;
+import org.jboss.wsf.spi.SPIProviderResolver;
+import org.jboss.wsf.spi.deployment.Endpoint;
+import org.jboss.wsf.spi.invocation.EndpointAssociation;
+import org.jboss.wsf.spi.invocation.RequestHandler;
/**
* JBoss Webservices SOAP Processor.
@@ -88,7 +115,9 @@
public class SOAPProcessor extends AbstractActionPipelineProcessor {
private static ThreadLocal<Message> messageTL = new ThreadLocal<Message>();
- private AbstractSOAPProcessor processor;
+ private String jbossws_endpoint;
+ private MessagePayloadProxy payloadProxy;
+ private boolean httpResponseStatusEnabled;
/**
* Public constructor.
@@ -96,14 +125,11 @@
* @throws ConfigurationException "jbossws-endpoint" not specified.
*/
public SOAPProcessor(ConfigTree config) throws ConfigurationException {
- if (JBossDeployerUtil.getWSImpl().equals(JBossDeployerUtil.WSIMPL_NATIVE))
- {
- processor = new NativeSOAPProcessor(config);
- }
- else if (JBossDeployerUtil.getWSImpl().equals(JBossDeployerUtil.WSIMPL_CXF))
- {
- processor = new CXFSOAPProcessor(config);
- }
+ jbossws_endpoint = config.getRequiredAttribute(WebServiceUtils.JBOSSWS_ENDPOINT);
+ payloadProxy = new MessagePayloadProxy(config,
+ new String[] {BytesBody.BYTES_LOCATION, ActionUtils.POST_ACTION_DATA},
+ new String[] {ActionUtils.POST_ACTION_DATA});
+ httpResponseStatusEnabled = ResponseStatus.isHttpEnabled(config);
}
/**
@@ -115,9 +141,182 @@
* @throws ActionProcessingException
*/
public Message process(Message message) throws ActionProcessingException {
- return processor.process(message);
+ Endpoint endpoint = WebServiceUtils.getServiceEndpoint(jbossws_endpoint);
+ byte[] soapMessage;
+
+ if(endpoint == null) {
+ throw new ActionProcessingException("Unknown Service Endpoint '" + jbossws_endpoint + "'.");
+ }
+
+ soapMessage = getSOAPMessagePayload(message);
+ try {
+ messageTL.set(message);
+
+ RequestHandler requestHandler = endpoint.getRequestHandler();
+
+ final Map<String, List<String>> headers = new HashMap<String, List<String>>() ;
+ final Properties properties = message.getProperties() ;
+ final String[] names = properties.getNames() ;
+ for(final String name: names)
+ {
+ final Object value = properties.getProperty(name) ;
+ if (value != null)
+ {
+ String normalisedName = name.toLowerCase() ;
+
+ if ("content-type".equals(normalisedName))
+ {
+ if ("application/octet-stream".equals(value))
+ {
+ continue;
+ }
+ else
+ {
+ // CXF needs it to be case sensitive
+ normalisedName = "Content-Type";
+ }
+ }
+
+ final List<String> values = headers.get(normalisedName) ;
+ if (values == null)
+ {
+ final List<String> newValues = new ArrayList<String>() ;
+ newValues.add(value.toString()) ;
+ headers.put(normalisedName, newValues) ;
+ }
+ else
+ {
+ values.add(value.toString()) ;
+ }
+ }
+ }
+
+ //CXF throws NPE in handler if content-length not set
+ List<String> newValues = new ArrayList<String>();
+ newValues.add(String.valueOf(soapMessage.length));
+ headers.put("content-length", newValues);
+
+ final String endpointAddress = endpoint.getAddress() ;
+ String path = null ;
+ if (endpointAddress != null)
+ {
+ try
+ {
+ path = new URI(endpointAddress).getPath() ;
+ }
+ catch (final URISyntaxException urise) {} //ignore
+ }
+ if (path == null)
+ {
+ path = getHeaderValue(headers, "path") ;
+ }
+
+ final SOAPProcessorHttpServletRequest servletRequest = new SOAPProcessorHttpServletRequest(path, soapMessage, headers) ;
+ final SOAPProcessorHttpServletResponse servletResponse = new SOAPProcessorHttpServletResponse() ;
+ final ServletContext servletContext = SOAPProcessorFactory.getFactory().createServletContext(endpoint) ;
+
+ EndpointAssociation.setEndpoint(endpoint);
+ final ClassLoader old = Thread.currentThread().getContextClassLoader();
+ try
+ {
+ // Use the WS deloyment's initial classloader because there could be resources within it
+ final ClassLoader initCL = endpoint.getService().getDeployment().getInitialClassLoader();
+ Thread.currentThread().setContextClassLoader(initCL);
+
+ // Provide ENC for newer versions of JBossWS
+ final Context ctx = new javax.naming.InitialContext();
+ final Context enc = (Context)ctx.lookup("java:comp");
+ enc.createSubcontext("env");
+ requestHandler.handleHttpRequest(endpoint, servletRequest, servletResponse, servletContext) ;
+ enc.destroySubcontext("env");
+ }
+ finally
+ {
+ Thread.currentThread().setContextClassLoader(old);
+ EndpointAssociation.removeEndpoint();
+ }
+
+ // This may have been changed, make sure we get the current version.
+ message = messageTL.get();
+ final Properties responseProperties = message.getProperties() ;
+ final String contentType = servletResponse.getContentType() ;
+ final Map<String, List<String>> responseHeaders = servletResponse.getHeaders() ;
+ // We deal with Content-Type below
+ // HTTP Headers *should* be case-insensitive but not with JBR
+ responseHeaders.remove("content-type") ;
+
+ for(Map.Entry<String, List<String>> header: responseHeaders.entrySet())
+ {
+ // We can only deal with the first value in the list.
+ // JBESB-2511
+ new ResponseHeader(header.getKey(), header.getValue().get(0)).setPropertyNameThis(properties);
+ }
+ // JBESB-2761
+ if (httpResponseStatusEnabled) {
+ ResponseStatus.setHttpProperties(properties, servletResponse.getStatus(), servletResponse.getStatusMessage());
+ }
+
+ final byte[] responseData = servletResponse.getContent() ;
+ if(contentType != null) {
+ responseProperties.setProperty("Content-Type", new ResponseHeader("Content-Type", contentType));
+ } else {
+ responseProperties.setProperty("Content-Type", new ResponseHeader("Content-Type", "text/xml"));
+ }
+
+ if ((contentType != null) && contentType.startsWith("multipart/")) {
+ payloadProxy.setPayload(message, responseData) ;
+ } else {
+ final String charset = servletResponse.getCharset() ;
+ if (charset == null) {
+ payloadProxy.setPayload(message, new String(responseData)) ;
+ } else {
+ payloadProxy.setPayload(message, new String(responseData, charset)) ;
+ }
+ }
+ } catch (Exception ex) {
+ throw new ActionProcessingException("Cannot process SOAP request", ex);
+ } finally {
+ messageTL.remove();
+ }
+
+ return message;
}
+ private String getHeaderValue(final Map<String, List<String>> headers,
+ final String header)
+ {
+ final List<String> values = headers.get(header) ;
+ if (values != null)
+ {
+ return values.get(0) ;
+ }
+ return null ;
+ }
+
+ private byte[] getSOAPMessagePayload(Message message) throws ActionProcessingException {
+ byte[] soapMessage;
+ Object messagePayload;
+
+ try {
+ messagePayload = payloadProxy.getPayload(message);
+ } catch (MessageDeliverException e) {
+ throw new ActionProcessingException(e);
+ }
+
+ if(messagePayload instanceof byte[]) {
+ soapMessage = (byte[])messagePayload;
+ } else if(messagePayload instanceof String) {
+ try {
+ soapMessage = ((String)messagePayload).getBytes("UTF-8");
+ } catch (UnsupportedEncodingException e) {
+ throw new ActionProcessingException("Unable to decode SOAP message payload.", e);
+ }
+ } else {
+ throw new ActionProcessingException("Unable to decode SOAP message payload. Must be either a byte[] or java.lang.String.");
+ }
+ return soapMessage;
+ }
+
/**
* Set the {@link org.jboss.soa.esb.message.Message} instance for this invocation context.
* <p/>
Added: labs/jbossesb/branches/JBESB_4_9_CP/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/adapter/SOAPProcessorFactory.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_9_CP/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/adapter/SOAPProcessorFactory.java (rev 0)
+++ labs/jbossesb/branches/JBESB_4_9_CP/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/adapter/SOAPProcessorFactory.java 2010-08-19 11:04:37 UTC (rev 34787)
@@ -0,0 +1,90 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * 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,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+
+package org.jboss.soa.esb.actions.soap.adapter;
+
+import javax.servlet.ServletContext;
+
+import org.apache.log4j.Logger;
+import org.jboss.internal.soa.esb.util.JBossDeployerUtil;
+import org.jboss.soa.esb.actions.soap.adapter.wsnative.JBossWSNativeFactory;
+import org.jboss.soa.esb.util.ClassUtil;
+import org.jboss.wsf.spi.deployment.Endpoint;
+
+/**
+ * Factory for creating implementation specific proxies.
+ *
+ * @author <a href="mailto:kevin.conner at jboss.com">Kevin Conner</a>
+ * @author <a href="mailto:mageshbk at jboss.com">Magesh Kumar B</a>
+ */
+public abstract class SOAPProcessorFactory
+{
+ /**
+ * The logger for the soap processor factory implementations.
+ */
+ private static final Logger LOGGER = Logger.getLogger(SOAPProcessorFactory.class) ;
+
+ /**
+ * The implementation factory.
+ */
+ private static final SOAPProcessorFactory FACTORY ;
+
+ /**
+ * Get the factory singleton.
+ * @return The factory singleton.
+ */
+ public static SOAPProcessorFactory getFactory()
+ {
+ return FACTORY ;
+ }
+
+ /**
+ * Create an appropriate servlet context.
+ * @param endpoint The webservice endpoint.
+ * @return The servlet context.
+ */
+ public abstract ServletContext createServletContext(final Endpoint endpoint) ;
+
+ static
+ {
+ SOAPProcessorFactory factory = null ;
+
+ if (JBossDeployerUtil.getWSImpl().equals(JBossDeployerUtil.WSIMPL_CXF))
+ {
+ try
+ {
+ // Load using reflection as it will not be present on 1.5 compilations
+ final Class<?> factoryClass = ClassUtil.forName("org.jboss.soa.esb.actions.soap.adapter.cxf.JBossWSCXFFactory", SOAPProcessorFactory.class) ;
+ factory = SOAPProcessorFactory.class.cast(factoryClass.newInstance()) ;
+ }
+ catch (final Throwable th)
+ {
+ if (LOGGER.isDebugEnabled())
+ {
+ LOGGER.debug("Failed to load CXF factory", th) ;
+ }
+ }
+ }
+ if (factory == null)
+ {
+ factory = new JBossWSNativeFactory() ;
+ }
+ FACTORY = factory ;
+
+ }
+}
Modified: labs/jbossesb/branches/JBESB_4_9_CP/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/adapter/SOAPProcessorHttpServletRequest.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_9_CP/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/adapter/SOAPProcessorHttpServletRequest.java 2010-08-19 09:30:37 UTC (rev 34786)
+++ labs/jbossesb/branches/JBESB_4_9_CP/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/adapter/SOAPProcessorHttpServletRequest.java 2010-08-19 11:04:37 UTC (rev 34787)
@@ -156,9 +156,17 @@
throw new UnsupportedOperationException("Not yet supported") ;
}
- public Enumeration getHeaders(String arg0)
+ public Enumeration getHeaders(final String name)
{
- throw new UnsupportedOperationException("Not yet supported") ;
+ final List<String> values = headers.get(name) ;
+ if (values != null)
+ {
+ return Collections.enumeration(values) ;
+ }
+ else
+ {
+ return null ;
+ }
}
public int getIntHeader(String arg0)
@@ -218,7 +226,7 @@
public String getCharacterEncoding()
{
- throw new UnsupportedOperationException("Not yet supported") ;
+ return null ;
}
public int getContentLength()
@@ -319,7 +327,8 @@
public Object getAttribute(String arg0)
{
- throw new UnsupportedOperationException("Not yet supported") ;
+ return null ;
+// throw new UnsupportedOperationException("Not yet supported") ;
}
public String getLocalAddr()
Modified: labs/jbossesb/branches/JBESB_4_9_CP/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/adapter/SOAPProcessorHttpServletResponse.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_9_CP/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/adapter/SOAPProcessorHttpServletResponse.java 2010-08-19 09:30:37 UTC (rev 34786)
+++ labs/jbossesb/branches/JBESB_4_9_CP/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/adapter/SOAPProcessorHttpServletResponse.java 2010-08-19 11:04:37 UTC (rev 34787)
@@ -275,7 +275,6 @@
public void flushBuffer() throws IOException
{
- throw new UnsupportedOperationException("Not yet supported") ;
}
public int getBufferSize()
Added: labs/jbossesb/branches/JBESB_4_9_CP/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/adapter/cxf/JBossWSCXFFactory.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_9_CP/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/adapter/cxf/JBossWSCXFFactory.java (rev 0)
+++ labs/jbossesb/branches/JBESB_4_9_CP/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/adapter/cxf/JBossWSCXFFactory.java 2010-08-19 11:04:37 UTC (rev 34787)
@@ -0,0 +1,37 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * 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,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+
+package org.jboss.soa.esb.actions.soap.adapter.cxf;
+
+import javax.servlet.ServletContext;
+
+import org.jboss.soa.esb.actions.soap.adapter.SOAPProcessorFactory;
+import org.jboss.wsf.spi.deployment.Endpoint;
+
+/**
+ * Factory for creating JBossWS CXF specific proxies.
+ *
+ * @author <a href="mailto:kevin.conner at jboss.com">Kevin Conner</a>
+ */
+public class JBossWSCXFFactory extends SOAPProcessorFactory
+{
+ public ServletContext createServletContext(final Endpoint endpoint)
+ {
+ return new SOAPProcessorCXFServletContext(endpoint) ;
+ }
+}
Added: labs/jbossesb/branches/JBESB_4_9_CP/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/adapter/cxf/SOAPProcessorCXFServletContext.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_9_CP/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/adapter/cxf/SOAPProcessorCXFServletContext.java (rev 0)
+++ labs/jbossesb/branches/JBESB_4_9_CP/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/adapter/cxf/SOAPProcessorCXFServletContext.java 2010-08-19 11:04:37 UTC (rev 34787)
@@ -0,0 +1,213 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * 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,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+
+package org.jboss.soa.esb.actions.soap.adapter.cxf;
+
+import java.io.InputStream;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.Enumeration;
+import java.util.Set;
+
+import javax.servlet.RequestDispatcher;
+import javax.servlet.Servlet;
+import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
+
+import org.apache.cxf.Bus;
+import org.apache.cxf.transport.DestinationFactory;
+import org.apache.cxf.transport.DestinationFactoryManager;
+import org.apache.cxf.transport.servlet.ServletController;
+import org.apache.cxf.transport.servlet.ServletTransportFactory;
+import org.jboss.wsf.spi.deployment.Endpoint;
+import org.jboss.wsf.stack.cxf.ServletControllerExt;
+import org.jboss.wsf.stack.cxf.configuration.BusHolder;
+
+/**
+ * This is an adapter used when integrating with JBossWS CXF integration.
+ *
+ * @author <a href="mailto:kevin.conner at jboss.com">Kevin Conner</a>
+ */
+public class SOAPProcessorCXFServletContext implements ServletContext
+{
+ private static final String CONTROLLER_NAME = ServletController.class.getName() ;
+
+ private final ServletControllerExt servletControllerExt ;
+
+ public SOAPProcessorCXFServletContext(final Endpoint endpoint)
+ {
+ final BusHolder busHolder = endpoint.getAttachment(BusHolder.class) ;
+ final Bus bus = busHolder.getBus() ;
+
+ final ServletTransportFactory servletTransportFactory = new SOAPProcessorServletTransportFactory(bus, getTransport(bus)) ;
+ servletControllerExt = new ServletControllerExt(servletTransportFactory, null, this, bus) ;
+ }
+
+ private ServletTransportFactory getTransport(final Bus bus)
+ {
+ final DestinationFactoryManager dfm = bus.getExtension(DestinationFactoryManager.class) ;
+ try
+ {
+ final DestinationFactory df = dfm.getDestinationFactory("http://cxf.apache.org/transports/http/configuration") ;
+ if (df instanceof ServletTransportFactory)
+ {
+ return (ServletTransportFactory)df ;
+ }
+ }
+ catch (final Throwable th)
+ {
+ throw new IllegalStateException("Could not locate CXF transport", th) ;
+ }
+ throw new IllegalStateException("Could not locate CXF transport") ;
+ }
+
+ public Object getAttribute(final String name)
+ {
+ if (CONTROLLER_NAME.equals(name))
+ {
+ return servletControllerExt ;
+ }
+ else
+ {
+ throw new UnsupportedOperationException("Not yet supported") ;
+ }
+ }
+
+ public Enumeration getAttributeNames()
+ {
+ throw new UnsupportedOperationException("Not yet supported") ;
+ }
+
+ public ServletContext getContext(final String name)
+ {
+ throw new UnsupportedOperationException("Not yet supported") ;
+ }
+
+ public String getInitParameter(final String param)
+ {
+ throw new UnsupportedOperationException("Not yet supported") ;
+ }
+
+ public Enumeration getInitParameterNames()
+ {
+ throw new UnsupportedOperationException("Not yet supported") ;
+ }
+
+ public int getMajorVersion()
+ {
+ throw new UnsupportedOperationException("Not yet supported") ;
+ }
+
+ public int getMinorVersion()
+ {
+ throw new UnsupportedOperationException("Not yet supported") ;
+ }
+
+ public String getMimeType(final String file)
+ {
+ throw new UnsupportedOperationException("Not yet supported") ;
+ }
+
+ public RequestDispatcher getNamedDispatcher(final String name)
+ {
+ throw new UnsupportedOperationException("Not yet supported") ;
+ }
+
+ public String getRealPath(final String path)
+ {
+ throw new UnsupportedOperationException("Not yet supported") ;
+ }
+
+ public RequestDispatcher getRequestDispatcher(final String path)
+ {
+ throw new UnsupportedOperationException("Not yet supported") ;
+ }
+
+ public URL getResource(final String path)
+ throws MalformedURLException
+ {
+ throw new UnsupportedOperationException("Not yet supported") ;
+ }
+
+ public InputStream getResourceAsStream(final String path)
+ {
+ throw new UnsupportedOperationException("Not yet supported") ;
+ }
+
+ public Set getResourcePaths(final String path)
+ {
+ throw new UnsupportedOperationException("Not yet supported") ;
+ }
+
+ public String getServerInfo()
+ {
+ throw new UnsupportedOperationException("Not yet supported") ;
+ }
+
+ public Servlet getServlet(final String name)
+ throws ServletException
+ {
+ throw new UnsupportedOperationException("Not yet supported") ;
+ }
+
+ public String getServletContextName()
+ {
+ throw new UnsupportedOperationException("Not yet supported") ;
+ }
+
+ public Enumeration getServletNames()
+ {
+ throw new UnsupportedOperationException("Not yet supported") ;
+ }
+
+ public Enumeration getServlets()
+ {
+ throw new UnsupportedOperationException("Not yet supported") ;
+ }
+
+ public void log(final String msg)
+ {
+ throw new UnsupportedOperationException("Not yet supported") ;
+ }
+
+ public void log(final Exception ex, final String msg)
+ {
+ throw new UnsupportedOperationException("Not yet supported") ;
+ }
+
+ public void log(final String msg, final Throwable th)
+ {
+ throw new UnsupportedOperationException("Not yet supported") ;
+ }
+
+ public void removeAttribute(final String name)
+ {
+ throw new UnsupportedOperationException("Not yet supported") ;
+ }
+
+ public void setAttribute(final String name, final Object value)
+ {
+ throw new UnsupportedOperationException("Not yet supported") ;
+ }
+
+ public String getContextPath()
+ {
+// return "" ;
+ throw new UnsupportedOperationException("Not yet supported") ;
+ }
+}
Added: labs/jbossesb/branches/JBESB_4_9_CP/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/adapter/cxf/SOAPProcessorServletTransportFactory.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_9_CP/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/adapter/cxf/SOAPProcessorServletTransportFactory.java (rev 0)
+++ labs/jbossesb/branches/JBESB_4_9_CP/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/adapter/cxf/SOAPProcessorServletTransportFactory.java 2010-08-19 11:04:37 UTC (rev 34787)
@@ -0,0 +1,67 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * 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,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+
+package org.jboss.soa.esb.actions.soap.adapter.cxf;
+
+import java.util.Collection;
+import java.util.Set;
+
+import org.apache.cxf.Bus;
+import org.apache.cxf.transport.servlet.ServletDestination;
+import org.apache.cxf.transport.servlet.ServletTransportFactory;
+
+/**
+ * A specialisation of the servlet transport factory acting as a procy for the real transport.
+ *
+ * @author <a href="mailto:kevin.conner at jboss.com">Kevin Conner</a>
+ */
+public class SOAPProcessorServletTransportFactory extends ServletTransportFactory
+{
+
+ private final ServletTransportFactory proxy ;
+
+ public SOAPProcessorServletTransportFactory(final Bus bus, final ServletTransportFactory proxy)
+ {
+ super(bus) ;
+ this.proxy = proxy ;
+ }
+
+ @Override
+ public Collection<ServletDestination> getDestinations()
+ {
+ return proxy.getDestinations() ;
+ }
+
+ @Override
+ public Set<String> getDestinationsPaths()
+ {
+ return proxy.getDestinationsPaths() ;
+ }
+
+ @Override
+ public ServletDestination getDestinationForPath(final String path)
+ {
+ return proxy.getDestinationForPath(path) ;
+ }
+
+ @Override
+ public ServletDestination getDestinationForPath(final String path, final boolean tryDecoding)
+ {
+ return proxy.getDestinationForPath(path, tryDecoding);
+ }
+}
Added: labs/jbossesb/branches/JBESB_4_9_CP/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/adapter/wsnative/JBossWSNativeFactory.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_9_CP/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/adapter/wsnative/JBossWSNativeFactory.java (rev 0)
+++ labs/jbossesb/branches/JBESB_4_9_CP/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/adapter/wsnative/JBossWSNativeFactory.java 2010-08-19 11:04:37 UTC (rev 34787)
@@ -0,0 +1,38 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * 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,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+
+package org.jboss.soa.esb.actions.soap.adapter.wsnative;
+
+import javax.servlet.ServletContext;
+
+import org.jboss.soa.esb.actions.soap.adapter.SOAPProcessorFactory;
+import org.jboss.soa.esb.actions.soap.adapter.SOAPProcessorServletContext;
+import org.jboss.wsf.spi.deployment.Endpoint;
+
+/**
+ * Factory for creating JBossWS native specific proxies.
+ *
+ * @author <a href="mailto:kevin.conner at jboss.com">Kevin Conner</a>
+ */
+public class JBossWSNativeFactory extends SOAPProcessorFactory
+{
+ public ServletContext createServletContext(final Endpoint endpoint)
+ {
+ return new SOAPProcessorServletContext() ;
+ }
+}
More information about the jboss-svn-commits
mailing list