cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ajaypai...@apache.org
Subject svn commit: r523406 - in /incubator/cxf/trunk/rt: core/src/main/java/org/apache/cxf/interceptor/ core/src/main/java/org/apache/cxf/service/factory/ core/src/test/java/org/apache/cxf/interceptor/ frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support...
Date Wed, 28 Mar 2007 16:46:33 GMT
Author: ajaypaibir
Date: Wed Mar 28 09:46:31 2007
New Revision: 523406

URL: http://svn.apache.org/viewvc?view=rev&rev=523406
Log:
[CXF-500] Defer creation of OutMessage and OutFaultMessage from OutgoingChainSetupInterceptor
to ServiceInvokerInterceptor i.e after the inbound message is dispatched to implementor. Setting
up of outbound interceptor chain is deferred to POST_INVOKE phase rather than PRE_LOGICAL
inbound.Removed OutgoingChainSetupInterceptor from the inbound chain.

Modified:
    incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/AbstractFaultChainIntiatorObserver.java
    incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/MessageSenderInterceptor.java
    incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/OutgoingChainInterceptor.java
    incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/ServiceInvokerInterceptor.java
    incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/service/factory/AbstractServiceFactoryBean.java
    incubator/cxf/trunk/rt/core/src/test/java/org/apache/cxf/interceptor/OutgoingChainInterceptorTest.java
    incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/ContextPropertiesMapping.java
    incubator/cxf/trunk/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/ContextUtils.java
    incubator/cxf/trunk/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/MAPAggregator.java

Modified: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/AbstractFaultChainIntiatorObserver.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/AbstractFaultChainIntiatorObserver.java?view=diff&rev=523406&r1=523405&r2=523406
==============================================================================
--- incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/AbstractFaultChainIntiatorObserver.java
(original)
+++ incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/AbstractFaultChainIntiatorObserver.java
Wed Mar 28 09:46:31 2007
@@ -24,8 +24,8 @@
 import java.util.logging.Logger;
 
 import org.apache.cxf.Bus;
-import org.apache.cxf.binding.Binding;
 import org.apache.cxf.common.logging.LogUtils;
+import org.apache.cxf.endpoint.Endpoint;
 import org.apache.cxf.message.Exchange;
 import org.apache.cxf.message.Message;
 import org.apache.cxf.message.MessageImpl;
@@ -45,11 +45,12 @@
 
     public void onMessage(Message m) {
         Message faultMessage = getFaultMessage(m);
+        Exchange ex = m.getExchange();
         if (faultMessage == null) {
-            faultMessage = new MessageImpl();
+            Endpoint ep = ex.get(Endpoint.class);
+            faultMessage = ep.getBinding().createMessage();
         }
         
-        faultMessage = m.getExchange().get(Binding.class).createMessage(faultMessage);
         setFaultMessage(m, faultMessage);
         MessageImpl.copyContent(m, faultMessage);
 
@@ -60,7 +61,7 @@
         faultMessage.setInterceptorChain(chain);
         try {
             chain.doIntercept(faultMessage);
-        } catch (Exception ex) {
+        } catch (Exception exc) {
             LogUtils.log(LOG, Level.INFO, "Error occured during error handling, give up!",
ex);
         }
     }

Modified: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/MessageSenderInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/MessageSenderInterceptor.java?view=diff&rev=523406&r1=523405&r2=523406
==============================================================================
--- incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/MessageSenderInterceptor.java
(original)
+++ incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/MessageSenderInterceptor.java
Wed Mar 28 09:46:31 2007
@@ -47,7 +47,8 @@
             ? message.getConduit()
             : exchange.getConduit() != null
               ? exchange.getConduit()
-              : exchange.getOutMessage() != null
+              : (exchange.getOutMessage() != null
+                  || exchange.getOutFaultMessage() != null)
                 ? OutgoingChainInterceptor.getBackChannelConduit(exchange)
                 : null;
 
@@ -69,4 +70,4 @@
             throw new Fault(new org.apache.cxf.common.i18n.Message("COULD_NOT_SEND", BUNDLE),
ex);
         }
     }
-}
+}
\ No newline at end of file

Modified: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/OutgoingChainInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/OutgoingChainInterceptor.java?view=diff&rev=523406&r1=523405&r2=523406
==============================================================================
--- incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/OutgoingChainInterceptor.java
(original)
+++ incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/OutgoingChainInterceptor.java
Wed Mar 28 09:46:31 2007
@@ -20,11 +20,18 @@
 package org.apache.cxf.interceptor;
 
 import java.io.IOException;
+import java.util.List;
+import java.util.logging.Level;
+import java.util.logging.Logger;
 
+import org.apache.cxf.Bus;
+import org.apache.cxf.endpoint.Endpoint;
 import org.apache.cxf.message.Exchange;
 import org.apache.cxf.message.Message;
 import org.apache.cxf.phase.AbstractPhaseInterceptor;
 import org.apache.cxf.phase.Phase;
+import org.apache.cxf.phase.PhaseInterceptorChain;
+import org.apache.cxf.phase.PhaseManager;
 import org.apache.cxf.service.model.BindingMessageInfo;
 import org.apache.cxf.service.model.BindingOperationInfo;
 import org.apache.cxf.service.model.MessageInfo;
@@ -32,7 +39,7 @@
 import org.apache.cxf.ws.addressing.EndpointReferenceType;
 
 public class OutgoingChainInterceptor extends AbstractPhaseInterceptor<Message> {
-
+    private static final Logger LOG = Logger.getLogger(OutgoingChainInterceptor.class.getName());
     public OutgoingChainInterceptor() {
         super();
         setPhase(Phase.POST_INVOKE);
@@ -51,14 +58,19 @@
                 out.put(MessageInfo.class, bin.getOperationInfo().getOutput());
                 out.put(BindingMessageInfo.class, bin.getOutput());
             }
-            out.getInterceptorChain().doIntercept(out);
+            
+            InterceptorChain outChain = out.getInterceptorChain();
+            if (outChain == null) {
+                outChain = getOutInterceptorChain(ex);
+                out.setInterceptorChain(outChain);
+            }
+            outChain.doIntercept(out);
         }
     }
     
     protected static Conduit getBackChannelConduit(Exchange ex) {
         Conduit conduit = null;
-        if (ex.getOutMessage().getConduit() == null
-            && ex.getConduit() == null
+        if (ex.getConduit() == null
             && ex.getDestination() != null) {
             try {
                 EndpointReferenceType target =
@@ -72,4 +84,37 @@
         }
         return conduit;
     }
+    
+    public static InterceptorChain getOutInterceptorChain(Exchange ex) {
+        Bus bus = ex.get(Bus.class);
+        PhaseManager pm = bus.getExtension(PhaseManager.class);
+        PhaseInterceptorChain chain = new PhaseInterceptorChain(pm.getOutPhases());
+        
+        Endpoint ep = ex.get(Endpoint.class);
+        List<Interceptor> il = ep.getOutInterceptors();
+        if (LOG.isLoggable(Level.FINE)) {
+            LOG.fine("Interceptors contributed by endpoint: " + il);
+        }
+        chain.add(il);
+        il = ep.getService().getOutInterceptors();
+        if (LOG.isLoggable(Level.FINE)) {
+            LOG.fine("Interceptors contributed by service: " + il);
+        }
+        chain.add(il);
+        il = bus.getOutInterceptors();
+        if (LOG.isLoggable(Level.FINE)) {
+            LOG.fine("Interceptors contributed by bus: " + il);
+        }
+        chain.add(il);        
+        if (ep.getBinding() != null) {
+            il = ep.getBinding().getOutInterceptors();
+            if (LOG.isLoggable(Level.FINE)) {
+                LOG.fine("Interceptors contributed by binding: " + il);
+            }
+            chain.add(il);
+        }
+        chain.setFaultObserver(ep.getOutFaultObserver());
+        return chain;
+    }
 }
+

Modified: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/ServiceInvokerInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/ServiceInvokerInterceptor.java?view=diff&rev=523406&r1=523405&r2=523406
==============================================================================
--- incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/ServiceInvokerInterceptor.java
(original)
+++ incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/ServiceInvokerInterceptor.java
Wed Mar 28 09:46:31 2007
@@ -55,15 +55,24 @@
             public void run() {
 
                 Object result = invoker.invoke(message.getExchange(), getInvokee(message));
-
-                if (result != null) {
-                    if (result instanceof List) {
-                        exchange.getOutMessage().setContent(List.class, result);
-                    } else if (result.getClass().isArray()) {
-                        result = Arrays.asList((Object[])result);
-                        exchange.getOutMessage().setContent(List.class, result);
-                    } else {
-                        exchange.getOutMessage().setContent(Object.class, result);
+                if (!exchange.isOneWay()) {
+                    Endpoint ep = exchange.get(Endpoint.class);
+                    
+                    Message outMessage = message.getExchange().getOutMessage();
+                    if (outMessage == null) {
+                        outMessage = ep.getBinding().createMessage();
+                        exchange.setOutMessage(outMessage);
+                    }
+                    copyJaxwsProperties(message, outMessage);
+                    if (result != null) {
+                        if (result instanceof List) {
+                            outMessage.setContent(List.class, result);
+                        } else if (result.getClass().isArray()) {
+                            result = Arrays.asList((Object[])result);
+                            outMessage.setContent(List.class, result);
+                        } else {
+                            outMessage.setContent(Object.class, result);
+                        }                    
                     }                    
                 }
             }
@@ -96,4 +105,12 @@
     private Executor getExecutor(final Endpoint endpoint) {
         return endpoint.getService().getExecutor();
     }
+    
+    private void copyJaxwsProperties(Message inMsg, Message outMsg) {       
+        outMsg.put(Message.WSDL_OPERATION, inMsg.get(Message.WSDL_OPERATION));
+        outMsg.put(Message.WSDL_SERVICE, inMsg.get(Message.WSDL_SERVICE));
+        outMsg.put(Message.WSDL_INTERFACE, inMsg.get(Message.WSDL_INTERFACE));
+        outMsg.put(Message.WSDL_PORT, inMsg.get(Message.WSDL_PORT));
+        outMsg.put(Message.WSDL_DESCRIPTION, inMsg.get(Message.WSDL_DESCRIPTION));
+    }    
 }

Modified: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/service/factory/AbstractServiceFactoryBean.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/service/factory/AbstractServiceFactoryBean.java?view=diff&rev=523406&r1=523405&r2=523406
==============================================================================
--- incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/service/factory/AbstractServiceFactoryBean.java
(original)
+++ incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/service/factory/AbstractServiceFactoryBean.java
Wed Mar 28 09:46:31 2007
@@ -22,7 +22,6 @@
 import org.apache.cxf.Bus;
 import org.apache.cxf.databinding.DataBinding;
 import org.apache.cxf.interceptor.OutgoingChainInterceptor;
-import org.apache.cxf.interceptor.OutgoingChainSetupInterceptor;
 import org.apache.cxf.interceptor.ServiceInvokerInterceptor;
 import org.apache.cxf.service.Service;
 
@@ -35,9 +34,7 @@
 
     protected void initializeDefaultInterceptors() {
         service.getInInterceptors().add(new ServiceInvokerInterceptor());
-        service.getInInterceptors().add(new OutgoingChainSetupInterceptor());
         service.getInInterceptors().add(new OutgoingChainInterceptor());
-        service.getOutFaultInterceptors().add(new OutgoingChainSetupInterceptor());
     }
     
     protected void initializeDataBindings() {

Modified: incubator/cxf/trunk/rt/core/src/test/java/org/apache/cxf/interceptor/OutgoingChainInterceptorTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/test/java/org/apache/cxf/interceptor/OutgoingChainInterceptorTest.java?view=diff&rev=523406&r1=523405&r2=523406
==============================================================================
--- incubator/cxf/trunk/rt/core/src/test/java/org/apache/cxf/interceptor/OutgoingChainInterceptorTest.java
(original)
+++ incubator/cxf/trunk/rt/core/src/test/java/org/apache/cxf/interceptor/OutgoingChainInterceptorTest.java
Wed Mar 28 09:46:31 2007
@@ -32,6 +32,7 @@
 import org.apache.cxf.message.MessageImpl;
 import org.apache.cxf.phase.Phase;
 import org.apache.cxf.phase.PhaseManager;
+import org.apache.cxf.phase.PhaseManagerImpl;
 import org.apache.cxf.service.Service;
 import org.apache.cxf.service.model.BindingMessageInfo;
 import org.apache.cxf.service.model.BindingOperationInfo;
@@ -64,9 +65,8 @@
         empty = new ArrayList<Interceptor>();
 
         bus = control.createMock(Bus.class);
-        PhaseManager pm = control.createMock(PhaseManager.class);
-        EasyMock.expect(bus.getExtension(PhaseManager.class)).andReturn(pm);
-        EasyMock.expect(pm.getOutPhases()).andReturn(phases);
+        PhaseManager pm = new PhaseManagerImpl();
+        EasyMock.expect(bus.getExtension(PhaseManager.class)).andReturn(pm).anyTimes();
 
         service = control.createMock(Service.class);
         endpoint = control.createMock(Endpoint.class);
@@ -75,9 +75,10 @@
         MessageImpl m = new MessageImpl();
         EasyMock.expect(binding.createMessage()).andStubReturn(m);
         
-        EasyMock.expect(endpoint.getService()).andReturn(service);
+        EasyMock.expect(endpoint.getService()).andReturn(service).anyTimes();
         EasyMock.expect(endpoint.getOutInterceptors()).andReturn(empty);
         EasyMock.expect(service.getOutInterceptors()).andReturn(empty);
+        EasyMock.expect(bus.getOutInterceptors()).andReturn(empty);
 
         bopInfo = control.createMock(BindingOperationInfo.class);
         opInfo = control.createMock(OperationInfo.class);

Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/ContextPropertiesMapping.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/ContextPropertiesMapping.java?view=diff&rev=523406&r1=523405&r2=523406
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/ContextPropertiesMapping.java
(original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/ContextPropertiesMapping.java
Wed Mar 28 09:46:31 2007
@@ -31,6 +31,7 @@
 import javax.xml.ws.handler.MessageContext;
 
 import org.apache.cxf.configuration.security.AuthorizationPolicy;
+import org.apache.cxf.endpoint.Endpoint;
 import org.apache.cxf.jaxws.context.WrappedMessageContext;
 import org.apache.cxf.message.Attachment;
 import org.apache.cxf.message.Exchange;
@@ -135,26 +136,29 @@
     public static MessageContext createWebServiceContext(Exchange exchange) {
         MessageContext ctx = new WrappedMessageContext(exchange.getInMessage());
         mapCxf2Jaxws(ctx);        
+        addMessageAttachments(ctx, 
+                              exchange.getInMessage(), 
+                              MessageContext.INBOUND_MESSAGE_ATTACHMENTS);
+
         Object requestHeaders = 
             exchange.getInMessage().get(Message.PROTOCOL_HEADERS);
         if (null != requestHeaders) {
             ctx.put(MessageContext.HTTP_REQUEST_HEADERS, requestHeaders);
-        }       
-
-        addMessageAttachments(ctx, 
-                              exchange.getInMessage(), 
-                              MessageContext.INBOUND_MESSAGE_ATTACHMENTS);
         
-        Message outMessage = exchange.getOutMessage();
-        if (null != outMessage) {
+            Message outMessage = exchange.getOutMessage();
+            if (outMessage == null) {
+                Endpoint ep = exchange.get(Endpoint.class);
+                outMessage = ep.getBinding().createMessage();
+                exchange.setOutMessage(outMessage);
+            }
             Object responseHeaders =
                 outMessage.get(Message.PROTOCOL_HEADERS);
             if (responseHeaders == null) {
                 responseHeaders = new HashMap<String, List<String>>();
-                outMessage.put(Message.PROTOCOL_HEADERS, responseHeaders);         
+                outMessage.put(Message.PROTOCOL_HEADERS, responseHeaders);
             }
             ctx.put(MessageContext.HTTP_RESPONSE_HEADERS, responseHeaders);
-        }   
+        }
         return ctx;
     }
     

Modified: incubator/cxf/trunk/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/ContextUtils.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/ContextUtils.java?view=diff&rev=523406&r1=523405&r2=523406
==============================================================================
--- incubator/cxf/trunk/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/ContextUtils.java
(original)
+++ incubator/cxf/trunk/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/ContextUtils.java
Wed Mar 28 09:46:31 2007
@@ -41,7 +41,7 @@
 import org.apache.cxf.endpoint.Endpoint;
 import org.apache.cxf.interceptor.Fault;
 import org.apache.cxf.interceptor.InterceptorChain;
-import org.apache.cxf.interceptor.OutgoingChainSetupInterceptor;
+import org.apache.cxf.interceptor.OutgoingChainInterceptor;
 import org.apache.cxf.message.Exchange;
 import org.apache.cxf.message.Message;
 import org.apache.cxf.service.model.BindingOperationInfo;
@@ -346,7 +346,7 @@
                     InterceptorChain chain =
                         fullResponse != null
                         ? fullResponse.getInterceptorChain()
-                        : OutgoingChainSetupInterceptor.getOutInterceptorChain(exchange);
+                        : OutgoingChainInterceptor.getOutInterceptorChain(exchange);
                     partialResponse.setInterceptorChain(chain);
                     exchange.setConduit(backChannel);
                     
@@ -363,6 +363,9 @@
                     exchange.setConduit(null);
                     if (fullResponse != null) {
                         exchange.setOutMessage(fullResponse);
+                    } else {
+                        fullResponse = endpoint.getBinding().createMessage();
+                        exchange.setOutMessage(fullResponse);
                     }
                     
                     if (retrieveAsyncPostResponseDispatch(inMessage)) {
@@ -396,7 +399,13 @@
      */
     public static void propogateReceivedMAPs(AddressingProperties inMAPs,
                                               Exchange exchange) {
+        if (exchange.getOutMessage() == null) {
+            exchange.setOutMessage(createMessage(exchange));
+        }
         propogateReceivedMAPs(inMAPs, exchange.getOutMessage());
+        if (exchange.getOutFaultMessage() == null) {
+            exchange.setOutFaultMessage(createMessage(exchange));
+        }
         propogateReceivedMAPs(inMAPs, exchange.getOutFaultMessage());
     }
 
@@ -717,15 +726,20 @@
         }
         return method;
     }
+    
+    /**
+     * Create a Binding specific Message.
+     * 
+     * @param message the current message
+     * @return the Method from the BindingOperationInfo
+     */
+    private static Message createMessage(Exchange exchange) {
+        Endpoint ep = exchange.get(Endpoint.class);
+        Message msg = null;
+        if (ep != null) {
+            msg = ep.getBinding().createMessage();
+        }
+        return msg;
+    }
+    
 }
-
-
-
-
-
-
-
-
-
-
-

Modified: incubator/cxf/trunk/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/MAPAggregator.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/MAPAggregator.java?view=diff&rev=523406&r1=523405&r2=523406
==============================================================================
--- incubator/cxf/trunk/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/MAPAggregator.java
(original)
+++ incubator/cxf/trunk/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/MAPAggregator.java
Wed Mar 28 09:46:31 2007
@@ -35,7 +35,6 @@
 
 import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.endpoint.Endpoint;
-import org.apache.cxf.interceptor.OutgoingChainSetupInterceptor;
 import org.apache.cxf.message.Exchange;
 import org.apache.cxf.message.Message;
 import org.apache.cxf.phase.AbstractPhaseInterceptor;
@@ -83,8 +82,6 @@
     public MAPAggregator() {
         super();
         setPhase(Phase.PRE_LOGICAL);
-        // this is necessary so that MAPs can be propagated 
-        addAfter(OutgoingChainSetupInterceptor.class.getName());
     }
 
     /**



Mime
View raw message