cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r439086 - in /incubator/cxf/trunk/rt/frontend/jaxws/src: main/java/org/apache/cxf/jaxws/ main/java/org/apache/cxf/jaxws/handler/ test/java/org/apache/cxf/jaxws/handler/
Date Thu, 31 Aug 2006 23:01:16 GMT
Author: dkulp
Date: Thu Aug 31 16:01:16 2006
New Revision: 439086

URL: http://svn.apache.org/viewvc?rev=439086&view=rev
Log:
Fix minor issues with jaxws barfing on oneways, handlers not being called, etc..


Modified:
    incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/EndpointInvocationHandler.java
    incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/AbstractJAXWSHandlerInterceptor.java
    incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/HandlerChainInvoker.java
    incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/LogicalHandlerInterceptor.java
    incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/StreamHandlerInterceptor.java
    incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/handler/AbstractProtocolHandlerInterceptorTest.java
    incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/handler/LogicalHandlerInterceptorTest.java
    incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/handler/StreamHandlerInterceptorTest.java

Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/EndpointInvocationHandler.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/EndpointInvocationHandler.java?rev=439086&r1=439085&r2=439086&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/EndpointInvocationHandler.java
(original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/EndpointInvocationHandler.java
Thu Aug 31 16:01:16 2006
@@ -29,6 +29,7 @@
 import javax.jws.WebMethod;
 import javax.xml.namespace.QName;
 import javax.xml.ws.Binding;
+import javax.xml.ws.BindingProvider;
 import javax.xml.ws.RequestWrapper;
 import javax.xml.ws.ResponseWrapper;
 import javax.xml.ws.WebServiceException;
@@ -68,6 +69,16 @@
     public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
 
         BindingOperationInfo oi = getOperationInfo(proxy, method);
+        if (oi == null) {
+            //check for method on BindingProvider
+            if (method.getDeclaringClass().equals(BindingProvider.class)
+                || method.getDeclaringClass().equals(BindingProviderImpl.class)) {
+                return method.invoke(this);
+            }
+            
+            Message msg = new Message("NO_OPERATION_INFO", LOG, method.getName());
+            throw new WebServiceException(msg.toString());
+        }
 
         // REVISIT - Holder objects, etc...
 
@@ -78,8 +89,8 @@
         Map<String, Object> context = new HashMap<String, Object>();
         context.put(org.apache.cxf.message.Message.METHOD, method);
         Object obj[] = client.invoke(oi, params, context);
-
-        return obj.length == 0 ? null : obj[0];
+        
+        return obj == null || obj.length == 0 ? null : obj[0];
     }
 
     BindingOperationInfo getOperationInfo(Object proxy, Method method) {
@@ -104,8 +115,7 @@
             QName oiQName = new QName(endpoint.getService().getName().getNamespaceURI(),
operationName);
             OperationInfo oi = ii.getOperation(oiQName);
             if (null == oi) {
-                Message msg = new Message("NO_OPERATION_INFO", LOG, operationName);
-                throw new WebServiceException(msg.toString());
+                return null;
             }
             // found the OI in the Interface, now find it in the binding
             BindingOperationInfo boi2 = endpoint.getEndpointInfo().getBinding().getOperation(oiQName);

Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/AbstractJAXWSHandlerInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/AbstractJAXWSHandlerInterceptor.java?rev=439086&r1=439085&r2=439086&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/AbstractJAXWSHandlerInterceptor.java
(original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/AbstractJAXWSHandlerInterceptor.java
Thu Aug 31 16:01:16 2006
@@ -25,9 +25,6 @@
 import org.apache.cxf.phase.AbstractPhaseInterceptor;
 
 public abstract class AbstractJAXWSHandlerInterceptor<T extends Message> extends AbstractPhaseInterceptor<T>
{
-
-    public static final String HANDLER_CHAIN_INVOKER = "org.apache.cxf.jaxws.handlers.invoker";
-    
     private Binding binding;
     
     protected AbstractJAXWSHandlerInterceptor(Binding b) {
@@ -35,6 +32,7 @@
     }
     
     boolean isOneway(T message) {
+        //@@TODO
         return true;
     }
     
@@ -43,15 +41,16 @@
     }
     
     boolean isRequestor(T message) {
-        return true;
+        Boolean b = (Boolean)message.get(Message.REQUESTOR_ROLE);
+        return b == null ? true : b.booleanValue();
     }
     
     protected HandlerChainInvoker getInvoker(T message) {
         HandlerChainInvoker invoker = 
-            (HandlerChainInvoker)message.getExchange().get(HANDLER_CHAIN_INVOKER);
+            message.getExchange().get(HandlerChainInvoker.class);
         if (null == invoker) {
             invoker = new HandlerChainInvoker(binding.getHandlerChain());
-            message.getExchange().put(HANDLER_CHAIN_INVOKER, invoker);
+            message.getExchange().put(HandlerChainInvoker.class, invoker);
         }
         return invoker;
     }

Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/HandlerChainInvoker.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/HandlerChainInvoker.java?rev=439086&r1=439085&r2=439086&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/HandlerChainInvoker.java
(original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/HandlerChainInvoker.java
Thu Aug 31 16:01:16 2006
@@ -92,7 +92,7 @@
         return protocolHandlers;
     }
 
-    public List<? extends Handler> getStreamHandlers() { 
+    public List<StreamHandler> getStreamHandlers() { 
         return streamHandlers;
     }
 

Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/LogicalHandlerInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/LogicalHandlerInterceptor.java?rev=439086&r1=439085&r2=439086&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/LogicalHandlerInterceptor.java
(original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/LogicalHandlerInterceptor.java
Thu Aug 31 16:01:16 2006
@@ -32,11 +32,14 @@
     }
     
     public void handleMessage(T message) {
-        LogicalMessageContextImpl lctx = new LogicalMessageContextImpl(message);
-        if (!getInvoker(message).invokeLogicalHandlers(isRequestor(message), lctx)) {
-            // need to abort - not sure how to do this:
-            // we have access to the interceptor chain via the message but 
-            // there is no support for terminating the chain yet
+        HandlerChainInvoker invoker = getInvoker(message);
+        if (!invoker.getLogicalHandlers().isEmpty()) {
+            LogicalMessageContextImpl lctx = new LogicalMessageContextImpl(message);
+            if (!invoker.invokeLogicalHandlers(isRequestor(message), lctx)) {
+                // need to abort - not sure how to do this:
+                // we have access to the interceptor chain via the message but 
+                // there is no support for terminating the chain yet
+            }
         }
     }
     

Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/StreamHandlerInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/StreamHandlerInterceptor.java?rev=439086&r1=439085&r2=439086&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/StreamHandlerInterceptor.java
(original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/StreamHandlerInterceptor.java
Thu Aug 31 16:01:16 2006
@@ -32,8 +32,11 @@
     }
 
     public void handleMessage(Message message) {
-        StreamMessageContextImpl sctx = new StreamMessageContextImpl(message);
-        getInvoker(message).invokeStreamHandlers(sctx);
+        HandlerChainInvoker invoker = getInvoker(message);
+        if (!invoker.getStreamHandlers().isEmpty()) {
+            StreamMessageContextImpl sctx = new StreamMessageContextImpl(message);
+            invoker.invokeStreamHandlers(sctx);
+        }
     } 
     
     public void handleFault(Message message) {

Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/handler/AbstractProtocolHandlerInterceptorTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/handler/AbstractProtocolHandlerInterceptorTest.java?rev=439086&r1=439085&r2=439086&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/handler/AbstractProtocolHandlerInterceptorTest.java
(original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/handler/AbstractProtocolHandlerInterceptorTest.java
Thu Aug 31 16:01:16 2006
@@ -58,7 +58,7 @@
 
     public void testInterceptSuccess() {
         expect(message.getExchange()).andReturn(exchange);
-        expect(exchange.get(AbstractProtocolHandlerInterceptor.HANDLER_CHAIN_INVOKER)).andReturn(invoker);
+        expect(exchange.get(HandlerChainInvoker.class)).andReturn(invoker);
         expect(invoker.invokeProtocolHandlers(eq(true), isA(MessageContext.class))).andReturn(true);
         control.replay();
         IIOPHandlerInterceptor pi = new IIOPHandlerInterceptor(binding);
@@ -68,7 +68,7 @@
     
     public void testInterceptFailure() {
         expect(message.getExchange()).andReturn(exchange);
-        expect(exchange.get(AbstractProtocolHandlerInterceptor.HANDLER_CHAIN_INVOKER)).andReturn(invoker);
+        expect(exchange.get(HandlerChainInvoker.class)).andReturn(invoker);
         expect(invoker.invokeProtocolHandlers(eq(true), isA(MessageContext.class))).andReturn(false);
         control.replay();
         IIOPHandlerInterceptor pi = new IIOPHandlerInterceptor(binding);

Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/handler/LogicalHandlerInterceptorTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/handler/LogicalHandlerInterceptorTest.java?rev=439086&r1=439085&r2=439086&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/handler/LogicalHandlerInterceptorTest.java
(original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/handler/LogicalHandlerInterceptorTest.java
Thu Aug 31 16:01:16 2006
@@ -19,8 +19,13 @@
 
 package org.apache.cxf.jaxws.handler;
 
+import java.util.ArrayList;
+import java.util.List;
+
 import javax.xml.ws.Binding;
+import javax.xml.ws.handler.LogicalHandler;
 import javax.xml.ws.handler.LogicalMessageContext;
+import javax.xml.ws.handler.MessageContext;
 
 import junit.framework.TestCase;
 
@@ -56,8 +61,20 @@
     }
     
     public void testInterceptSuccess() {
+        List<LogicalHandler> list = new ArrayList<LogicalHandler>();
+        list.add(new LogicalHandler() {
+            public void close(MessageContext arg0) {
+            }
+            public boolean handleFault(MessageContext arg0) {
+                return true;
+            }
+            public boolean handleMessage(MessageContext arg0) {
+                return true;
+            }
+        });
+        expect(invoker.getLogicalHandlers()).andReturn(list);
         expect(message.getExchange()).andReturn(exchange);
-        expect(exchange.get(AbstractProtocolHandlerInterceptor.HANDLER_CHAIN_INVOKER)).andReturn(invoker);
+        expect(exchange.get(HandlerChainInvoker.class)).andReturn(invoker);
         expect(invoker.invokeLogicalHandlers(eq(true),
             isA(LogicalMessageContext.class))).andReturn(true);
         control.replay();
@@ -67,8 +84,20 @@
     }
     
     public void testInterceptFailure() {
+        List<LogicalHandler> list = new ArrayList<LogicalHandler>();
+        list.add(new LogicalHandler() {
+            public void close(MessageContext arg0) {
+            }
+            public boolean handleFault(MessageContext arg0) {
+                return true;
+            }
+            public boolean handleMessage(MessageContext arg0) {
+                return true;
+            }
+        });
+        expect(invoker.getLogicalHandlers()).andReturn(list);
         expect(message.getExchange()).andReturn(exchange);
-        expect(exchange.get(AbstractProtocolHandlerInterceptor.HANDLER_CHAIN_INVOKER)).andReturn(invoker);
+        expect(exchange.get(HandlerChainInvoker.class)).andReturn(invoker);
         expect(invoker.invokeLogicalHandlers(eq(true), 
             isA(LogicalMessageContext.class))).andReturn(false);
         control.replay();
@@ -78,7 +107,7 @@
     
     public void testOnCompletion() {
         expect(message.getExchange()).andReturn(exchange);
-        expect(exchange.get(AbstractProtocolHandlerInterceptor.HANDLER_CHAIN_INVOKER)).andReturn(invoker);
+        expect(exchange.get(HandlerChainInvoker.class)).andReturn(invoker);
         invoker.mepComplete(message);
         expectLastCall();
         control.replay();

Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/handler/StreamHandlerInterceptorTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/handler/StreamHandlerInterceptorTest.java?rev=439086&r1=439085&r2=439086&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/handler/StreamHandlerInterceptorTest.java
(original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/handler/StreamHandlerInterceptorTest.java
Thu Aug 31 16:01:16 2006
@@ -19,10 +19,15 @@
 
 package org.apache.cxf.jaxws.handler;
 
+import java.util.ArrayList;
+import java.util.List;
+
 import javax.xml.ws.Binding;
+import javax.xml.ws.handler.MessageContext;
 
 import junit.framework.TestCase;
 
+import org.apache.cxf.jaxws.handlers.StreamHandler;
 import org.apache.cxf.jaxws.handlers.StreamMessageContext;
 import org.apache.cxf.message.Exchange;
 import org.apache.cxf.message.Message;
@@ -47,7 +52,18 @@
         invoker = control.createMock(HandlerChainInvoker.class);
         message = control.createMock(Message.class);
         exchange = control.createMock(Exchange.class);
-        
+        List<StreamHandler> list = new ArrayList<StreamHandler>();
+        list.add(new StreamHandler() {
+            public void close(MessageContext arg0) {
+            }
+            public boolean handleFault(StreamMessageContext arg0) {
+                return true;
+            }
+            public boolean handleMessage(StreamMessageContext arg0) {
+                return true;
+            }
+        });
+        expect(invoker.getStreamHandlers()).andReturn(list);        
     }
     
     public void tearDown() {
@@ -56,7 +72,7 @@
 
     public void testInterceptSuccess() {
         expect(message.getExchange()).andReturn(exchange);
-        expect(exchange.get(AbstractProtocolHandlerInterceptor.HANDLER_CHAIN_INVOKER)).andReturn(invoker);
+        expect(exchange.get(HandlerChainInvoker.class)).andReturn(invoker);
         expect(invoker.invokeStreamHandlers(isA(StreamMessageContext.class))).andReturn(true);
         control.replay();
         StreamHandlerInterceptor si = new StreamHandlerInterceptor(binding);
@@ -66,7 +82,7 @@
     
     public void testInterceptFailure() {
         expect(message.getExchange()).andReturn(exchange);
-        expect(exchange.get(AbstractProtocolHandlerInterceptor.HANDLER_CHAIN_INVOKER)).andReturn(invoker);
+        expect(exchange.get(HandlerChainInvoker.class)).andReturn(invoker);
         expect(invoker.invokeStreamHandlers(isA(StreamMessageContext.class))).andReturn(false);
         control.replay();
         StreamHandlerInterceptor si = new StreamHandlerInterceptor(binding);



Mime
View raw message