Author: richard.opalka(a)jboss.com
Date: 2009-01-21 09:55:54 -0500 (Wed, 21 Jan 2009)
New Revision: 9082
Modified:
stack/cxf/trunk/.classpath
stack/cxf/trunk/modules/client/pom.xml
stack/cxf/trunk/modules/server/pom.xml
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/AbstractInvoker.java
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/CXFServletExt.java
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/ServletControllerExt.java
stack/cxf/trunk/pom.xml
stack/cxf/trunk/src/main/distro/ReleaseNotes.txt
stack/cxf/trunk/src/main/scripts/assembly-deploy-artifacts.xml
Log:
[JBWS-2417] upgrading from CXF 2.1 to CXF 2.1.3 + implementing architectural changes
Modified: stack/cxf/trunk/.classpath
===================================================================
--- stack/cxf/trunk/.classpath 2009-01-21 13:20:47 UTC (rev 9081)
+++ stack/cxf/trunk/.classpath 2009-01-21 14:55:54 UTC (rev 9082)
@@ -1,6 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src"
path="modules/server/src/main/java"/>
+ <classpathentry kind="src" path="cxf-api"/>
+ <classpathentry kind="src" path="cxf-transport-http"/>
+ <classpathentry kind="src" path="cxf-core"/>
<classpathentry kind="src"
path="modules/testsuite/cxf-tests/src/test/java"/>
<classpathentry kind="src"
path="modules/client/src/main/java"/>
<classpathentry kind="con"
path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
@@ -8,7 +11,8 @@
<classpathentry combineaccessrules="false" kind="src"
path="/jbossws-common"/>
<classpathentry combineaccessrules="false" kind="src"
path="/jbossws-framework"/>
<classpathentry combineaccessrules="false" kind="src"
path="/jbossws-spi"/>
- <classpathentry kind="con"
path="org.eclipse.jdt.USER_LIBRARY/jboss-5.0.0.CR2"/>
<classpathentry kind="con"
path="org.eclipse.jdt.USER_LIBRARY/junit"/>
+ <classpathentry kind="con"
path="org.eclipse.jdt.USER_LIBRARY/CXF"/>
+ <classpathentry kind="con"
path="org.eclipse.jdt.USER_LIBRARY/JBOSS500GA"/>
<classpathentry kind="output" path="target/eclipse-classes"/>
</classpath>
Modified: stack/cxf/trunk/modules/client/pom.xml
===================================================================
--- stack/cxf/trunk/modules/client/pom.xml 2009-01-21 13:20:47 UTC (rev 9081)
+++ stack/cxf/trunk/modules/client/pom.xml 2009-01-21 14:55:54 UTC (rev 9082)
@@ -80,7 +80,7 @@
<artifactId>stax-api</artifactId>
</dependency>
<dependency>
- <groupId>xml-security</groupId>
+ <groupId>org.apache.santuario</groupId>
<artifactId>xmlsec</artifactId>
</dependency>
Modified: stack/cxf/trunk/modules/server/pom.xml
===================================================================
--- stack/cxf/trunk/modules/server/pom.xml 2009-01-21 13:20:47 UTC (rev 9081)
+++ stack/cxf/trunk/modules/server/pom.xml 2009-01-21 14:55:54 UTC (rev 9082)
@@ -106,7 +106,7 @@
<artifactId>stax-api</artifactId>
</dependency>
<dependency>
- <groupId>xml-security</groupId>
+ <groupId>org.apache.santuario</groupId>
<artifactId>xmlsec</artifactId>
</dependency>
Modified:
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/AbstractInvoker.java
===================================================================
---
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/AbstractInvoker.java 2009-01-21
13:20:47 UTC (rev 9081)
+++
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/AbstractInvoker.java 2009-01-21
14:55:54 UTC (rev 9082)
@@ -23,20 +23,28 @@
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.Collection;
import java.util.HashMap;
+import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import javax.activation.DataHandler;
import javax.xml.ws.WebServiceContext;
import javax.xml.ws.handler.MessageContext;
import javax.xml.ws.handler.MessageContext.Scope;
+import org.apache.cxf.attachment.AttachmentImpl;
+import org.apache.cxf.binding.soap.SoapMessage;
import org.apache.cxf.frontend.MethodDispatcher;
+import org.apache.cxf.headers.Header;
import org.apache.cxf.helpers.CastUtils;
import org.apache.cxf.jaxws.context.WebServiceContextImpl;
import org.apache.cxf.jaxws.context.WrappedMessageContext;
-import org.apache.cxf.jaxws.support.ContextPropertiesMapping;
+import org.apache.cxf.message.Attachment;
import org.apache.cxf.message.Exchange;
+import org.apache.cxf.message.Message;
import org.apache.cxf.message.MessageContentsList;
import org.apache.cxf.service.Service;
import org.apache.cxf.service.invoker.Invoker;
@@ -58,27 +66,26 @@
public Object invoke(Exchange exchange, Object o)
{
// set up the webservice request context
- MessageContext msgCtx =
ContextPropertiesMapping.createWebServiceContext(exchange);
+ WrappedMessageContext ctx = new WrappedMessageContext(exchange.getInMessage(),
Scope.APPLICATION);
- Map<String, Scope> scopes = CastUtils.cast((Map<?,
?>)msgCtx.get(WrappedMessageContext.SCOPES));
- Map<String, Object> handlerScopedStuff = new HashMap<String,
Object>();
- if (scopes != null)
- {
- for (Map.Entry<String, Scope> scope : scopes.entrySet())
- {
- if (scope.getValue() == Scope.HANDLER)
- {
- handlerScopedStuff.put(scope.getKey(), msgCtx.get(scope.getKey()));
- }
- }
- for (String key : handlerScopedStuff.keySet())
- {
- msgCtx.remove(key);
- }
- }
+ Map<String, Object> handlerScopedStuff = removeHandlerProperties(ctx);
- WebServiceContextImpl.setMessageContext(msgCtx);
+ WebServiceContextImpl.setMessageContext(ctx);
+ Object retObj = _invokeInternal(exchange, o, ctx);
+
+ addHandlerProperties(ctx, handlerScopedStuff);
+
+ //update the webservice response context
+ updateWebServiceContext(exchange, ctx);
+ //clear the WebServiceContextImpl's ThreadLocal variable
+ WebServiceContextImpl.clear();
+
+ return new MessageContentsList(retObj);
+ }
+
+ private Object _invokeInternal(Exchange exchange, Object o, WrappedMessageContext
ctx)
+ {
BindingOperationInfo bop = exchange.get(BindingOperationInfo.class);
MethodDispatcher md =
(MethodDispatcher)exchange.get(Service.class).get(MethodDispatcher.class.getName());
Method m = md.getMethod(bop);
@@ -99,8 +106,8 @@
Invocation inv = invHandler.createInvocation();
InvocationContext invContext = inv.getInvocationContext();
- inv.getInvocationContext().addAttachment(WebServiceContext.class,
getWebServiceContext(msgCtx));
- invContext.addAttachment(MessageContext.class, msgCtx);
+ inv.getInvocationContext().addAttachment(WebServiceContext.class,
getWebServiceContext(ctx));
+ invContext.addAttachment(MessageContext.class, ctx);
inv.setJavaMethod(m);
inv.setArgs(params);
@@ -116,18 +123,7 @@
handleException(ex);
}
- for (Map.Entry<String, Object> key : handlerScopedStuff.entrySet())
- {
- msgCtx.put(key.getKey(), key.getValue());
- msgCtx.setScope(key.getKey(), Scope.HANDLER);
- }
-
- //update the webservice response context
- ContextPropertiesMapping.updateWebServiceContext(exchange, msgCtx);
- //clear the WebServiceContextImpl's ThreadLocal variable
- WebServiceContextImpl.clear();
-
- return new MessageContentsList(retObj);
+ return retObj;
}
protected abstract WebServiceContext getWebServiceContext(MessageContext msgCtx);
@@ -147,4 +143,99 @@
throw new RuntimeException(th);
}
+ protected Map<String, Object> removeHandlerProperties(WrappedMessageContext
ctx)
+ {
+ Map<String, Scope> scopes = CastUtils.cast((Map<?,
?>)ctx.get(WrappedMessageContext.SCOPES));
+ Map<String, Object> handlerScopedStuff = new HashMap<String,
Object>();
+ if (scopes != null)
+ {
+ for (Map.Entry<String, Scope> scope : scopes.entrySet())
+ {
+ if (scope.getValue() == Scope.HANDLER)
+ {
+ handlerScopedStuff.put(scope.getKey(), ctx.get(scope.getKey()));
+ }
+ }
+ for (String key : handlerScopedStuff.keySet())
+ {
+ ctx.remove(key);
+ }
+ }
+ return handlerScopedStuff;
+ }
+
+ protected void updateWebServiceContext(Exchange exchange, MessageContext ctx)
+ {
+ // Guard against wrong type associated with header list.
+ // Need to copy header only if the message is going out.
+ if (ctx.containsKey(Header.HEADER_LIST) && ctx.get(Header.HEADER_LIST)
instanceof List<?>)
+ {
+ List list = (List) ctx.get(Header.HEADER_LIST);
+ if (list != null && !list.isEmpty()) {
+ SoapMessage sm = (SoapMessage) createResponseMessage(exchange);
+ Iterator iter = list.iterator();
+ while (iter.hasNext())
+ {
+ sm.getHeaders().add((Header) iter.next());
+ }
+ }
+ }
+ if (exchange.getOutMessage() != null)
+ {
+ Message out = exchange.getOutMessage();
+ if (out.containsKey(Message.PROTOCOL_HEADERS))
+ {
+ Map<String, List<String>> heads = CastUtils
+ .cast((Map<?,
?>)exchange.getOutMessage().get(Message.PROTOCOL_HEADERS));
+ if (heads.containsKey("Content-Type")) {
+ List<String> ct = heads.get("Content-Type");
+ exchange.getOutMessage().put(Message.CONTENT_TYPE, ct.get(0));
+ heads.remove("Content-Type");
+ }
+ }
+ Map<String, DataHandler> dataHandlers
+ = CastUtils.cast((Map<?,
?>)out.get(MessageContext.OUTBOUND_MESSAGE_ATTACHMENTS));
+ if (dataHandlers != null && !dataHandlers.isEmpty())
+ {
+ Collection<Attachment> attachments = out.getAttachments();
+ if (attachments == null)
+ {
+ attachments = new ArrayList<Attachment>();
+ out.setAttachments(attachments);
+ }
+ for (Map.Entry<String, DataHandler> entry : dataHandlers.entrySet())
+ {
+ Attachment att = new AttachmentImpl(entry.getKey(), entry.getValue());
+ attachments.add(att);
+ }
+ }
+ out.remove(MessageContext.OUTBOUND_MESSAGE_ATTACHMENTS);
+ }
+ }
+
+ private Message createResponseMessage(Exchange exchange)
+ {
+ if (exchange == null) {
+ return null;
+ }
+ Message m = exchange.getOutMessage();
+ if (m == null && !exchange.isOneWay()) {
+ throw new UnsupportedOperationException();
+ /* TODO: below is the copy/paste from CXF 2.1.3 AbstractJAXWSMethodInvoker.java,
should we enable it?
+ Endpoint ep = exchange.get(Endpoint.class);
+ m = ep.getBinding().createMessage();
+ exchange.setOutMessage(m);
+ */
+ }
+ return m;
+ }
+
+ protected void addHandlerProperties(WrappedMessageContext ctx, Map<String,
Object> handlerScopedStuff)
+ {
+ for (Map.Entry<String, Object> key : handlerScopedStuff.entrySet())
+ {
+ ctx.put(key.getKey(), key.getValue(), Scope.HANDLER);
+ }
+ }
+
}
Modified:
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/CXFServletExt.java
===================================================================
---
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/CXFServletExt.java 2009-01-21
13:20:47 UTC (rev 9081)
+++
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/CXFServletExt.java 2009-01-21
14:55:54 UTC (rev 9082)
@@ -81,30 +81,13 @@
endpoint = initServiceEndpoint(contextPath);
context.setAttribute(ServletController.class.getName(), getController());
- this.startEndpoint();
}
- private void startEndpoint()
- {
- if (this.endpoint.getState() == EndpointState.CREATED)
- {
- this.endpoint.getLifecycleHandler().start(this.endpoint);
- }
- }
-
- private void stopEndpoint()
- {
- if (this.endpoint.getState() == EndpointState.STARTED)
- {
- this.endpoint.getLifecycleHandler().stop(this.endpoint);
- }
- }
-
@Override
public ServletController createServletController(ServletConfig servletConfig)
{
ServletTransportFactory stf =
(ServletTransportFactory)createServletTransportFactory();
- return new ServletControllerExt(stf, this);
+ return new ServletControllerExt(stf, servletConfig.getServletContext(), bus);
}
@Override
@@ -163,7 +146,6 @@
if (childCtx != null)
childCtx.destroy();
- this.stopEndpoint();
super.destroy();
}
Modified:
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/ServletControllerExt.java
===================================================================
---
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/ServletControllerExt.java 2009-01-21
13:20:47 UTC (rev 9081)
+++
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/ServletControllerExt.java 2009-01-21
14:55:54 UTC (rev 9082)
@@ -21,25 +21,23 @@
*/
package org.jboss.wsf.stack.cxf;
-import java.io.IOException;
import java.io.OutputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Collection;
+import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.cxf.Bus;
import org.apache.cxf.service.model.EndpointInfo;
-import org.apache.cxf.transport.servlet.CXFServlet;
import org.apache.cxf.transport.servlet.ServletController;
import org.apache.cxf.transport.servlet.ServletDestination;
import org.apache.cxf.transport.servlet.ServletTransportFactory;
import org.apache.cxf.transports.http.QueryHandler;
import org.apache.cxf.transports.http.QueryHandlerRegistry;
-import org.jboss.logging.Logger;
/**
* An extension to the CXF servlet controller
@@ -49,16 +47,16 @@
*/
public class ServletControllerExt extends ServletController
{
- private static Logger log = Logger.getLogger(ServletControllerExt.class);
-
private ServletTransportFactory cxfTransport;
- private CXFServlet cxfServlet;
+ private ServletContext servletCtx;
+ private Bus bus;
- public ServletControllerExt(ServletTransportFactory cxfTransport, CXFServlet
cxfServlet)
+ public ServletControllerExt(ServletTransportFactory cxfTransport, ServletContext
servletCtx, Bus bus)
{
- super(cxfTransport, cxfServlet);
+ super(cxfTransport, servletCtx, bus);
this.cxfTransport = cxfTransport;
- this.cxfServlet = cxfServlet;
+ this.servletCtx = servletCtx;
+ this.bus = bus;
}
/**
@@ -114,7 +112,6 @@
private boolean handleQuery(HttpServletRequest req, HttpServletResponse res,
ServletDestination dest)
throws ServletException
{
- Bus bus = cxfServlet.getBus();
boolean hasQuery = (null != req.getQueryString()) &&
(req.getQueryString().length() > 0);
boolean queryHandlerRegistryExists = bus.getExtension(QueryHandlerRegistry.class)
!= null;
Modified: stack/cxf/trunk/pom.xml
===================================================================
--- stack/cxf/trunk/pom.xml 2009-01-21 13:20:47 UTC (rev 9081)
+++ stack/cxf/trunk/pom.xml 2009-01-21 14:55:54 UTC (rev 9082)
@@ -56,7 +56,7 @@
<jbossws.jboss510.version>3.0.5.GA</jbossws.jboss510.version>
<jbossws.jboss600.version>3.0.6-SNAPSHOT</jbossws.jboss600.version>
<!-- END -->
- <cxf.version>2.1</cxf.version>
+ <cxf.version>2.1.3</cxf.version>
<cxf.stax.version>1.0.1</cxf.stax.version>
<fastinfoset.api.version>1.2.2</fastinfoset.api.version>
<jboss.common.version>1.2.1.GA</jboss.common.version>
@@ -70,7 +70,7 @@
<commons.logging.version>1.1.1</commons.logging.version>
<log4j.version>1.2.14</log4j.version>
<saaj.api.version>1.3</saaj.api.version>
- <xmlsec.version>1.3.0</xmlsec.version>
+ <xmlsec.version>1.4.0</xmlsec.version>
</properties>
<!-- DependencyManagement -->
@@ -283,7 +283,7 @@
<version>${cxf.stax.version}</version>
</dependency>
<dependency>
- <groupId>xml-security</groupId>
+ <groupId>org.apache.santuario</groupId>
<artifactId>xmlsec</artifactId>
<version>${xmlsec.version}</version>
</dependency>
Modified: stack/cxf/trunk/src/main/distro/ReleaseNotes.txt
===================================================================
--- stack/cxf/trunk/src/main/distro/ReleaseNotes.txt 2009-01-21 13:20:47 UTC (rev 9081)
+++ stack/cxf/trunk/src/main/distro/ReleaseNotes.txt 2009-01-21 14:55:54 UTC (rev 9082)
@@ -41,6 +41,9 @@
See: TODO: reference to associated JIRA issue
+
+This version of ${project.name} is based on CXF ${cxf.version}
+
Enjoy,
The JBossWS Team
Modified: stack/cxf/trunk/src/main/scripts/assembly-deploy-artifacts.xml
===================================================================
--- stack/cxf/trunk/src/main/scripts/assembly-deploy-artifacts.xml 2009-01-21 13:20:47 UTC
(rev 9081)
+++ stack/cxf/trunk/src/main/scripts/assembly-deploy-artifacts.xml 2009-01-21 14:55:54 UTC
(rev 9082)
@@ -29,7 +29,6 @@
<include>com.sun.xml.bind:jaxb-impl:jar</include>
<include>com.sun.xml.bind:jaxb-xjc:jar</include>
<include>javax.xml:jaxrpc-api:jar</include>
- <include>javax.xml.ws:jaxws-api:jar</include>
<include>org.jboss.ws:jbossws-common:jar</include>
<include>org.jboss.ws:jbossws-spi:jar</include>
<include>junit:junit:jar</include>
@@ -45,10 +44,17 @@
<include>org.apache.ws.commons.schema:XmlSchema:jar</include>
<include>com.sun.xml.fastinfoset:FastInfoset:jar</include>
<include>org.apache.ws.security:wss4j:jar</include>
- <include>xml-security:xmlsec:jar</include>
+ <include>org.apache.santuario:xmlsec:jar</include>
</includes>
</dependencySet>
<dependencySet>
+ <outputFileNameMapping>jaxws-api.jar</outputFileNameMapping>
+ <useStrictFiltering>true</useStrictFiltering>
+ <includes>
+
<include>org.apache.geronimo.specs:geronimo-jaxws_2.1_spec:jar</include>
+ </includes>
+ </dependencySet>
+ <dependencySet>
<outputFileNameMapping>wstx.jar</outputFileNameMapping>
<useStrictFiltering>true</useStrictFiltering>
<includes>