camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ningji...@apache.org
Subject svn commit: r629003 - in /activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/invoker: AbstractInvokingContext.java PayloadInvokingContext.java RawMessageInvokingContext.java
Date Tue, 19 Feb 2008 06:32:51 GMT
Author: ningjiang
Date: Mon Feb 18 22:32:39 2008
New Revision: 629003

URL: http://svn.apache.org/viewvc?rev=629003&view=rev
Log:
CAMEL-339 clean up the get*Interceptor methods in the InvokingContexts

Modified:
    activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/invoker/AbstractInvokingContext.java
    activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/invoker/PayloadInvokingContext.java
    activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/invoker/RawMessageInvokingContext.java

Modified: activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/invoker/AbstractInvokingContext.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/invoker/AbstractInvokingContext.java?rev=629003&r1=629002&r2=629003&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/invoker/AbstractInvokingContext.java
(original)
+++ activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/invoker/AbstractInvokingContext.java
Mon Feb 18 22:32:39 2008
@@ -16,6 +16,8 @@
  */
 package org.apache.camel.component.cxf.invoker;
 
+import java.io.IOException;
+import java.io.InputStream;
 import java.util.List;
 import java.util.Map;
 import java.util.SortedSet;
@@ -25,7 +27,9 @@
 import org.apache.cxf.Bus;
 import org.apache.cxf.endpoint.Endpoint;
 import org.apache.cxf.endpoint.EndpointImpl;
+import org.apache.cxf.helpers.IOUtils;
 import org.apache.cxf.interceptor.Interceptor;
+import org.apache.cxf.io.CachedOutputStream;
 import org.apache.cxf.message.Exchange;
 import org.apache.cxf.message.Message;
 import org.apache.cxf.phase.Phase;
@@ -37,95 +41,11 @@
  *
  */
 public abstract class AbstractInvokingContext implements InvokingContext {
-    
-    private static final Logger LOG = Logger.getLogger(AbstractInvokingContext.class.getName());
-
-    /**
-     * This method is called when an request from a (routing) client is observed
-     * at the router's transport (inbound to the router from a client).  It will 
-     * return an "in" interceptor chain that will allow the appropriate routing 
-     * interceptor to receive and handle the message.
-     * @param exchange
-     * @return in interceptor chain
-     */
-    public PhaseInterceptorChain getRequestInInterceptorChain(Exchange exchange) {
-        return getInInterceptorChain(exchange, false);
-    }
-
-    protected PhaseInterceptorChain getInInterceptorChain(Exchange exchange, boolean isResponse)
{
-
-        Bus bus = exchange.get(Bus.class);
-        assert bus != null;
-
-        PhaseInterceptorChain chain = new PhaseInterceptorChain(getInPhases());
 
-        if (!isResponse) {
-            List<Interceptor> routingInterceptors = getRoutingInterceptors();
-            chain.add(routingInterceptors);    
-            if (LOG.isLoggable(Level.FINE)) {
-                LOG.fine("Injected " + routingInterceptors);
-            }
-        }
-
-        // bus
-        List<Interceptor> list = bus.getInInterceptors();
-        if (LOG.isLoggable(Level.FINE)) {
-            LOG.fine("Interceptors contributed by bus: " + list);
-        }  
-        
-        chain.add(list);
-
-        // endpoint
-        Endpoint ep = exchange.get(Endpoint.class);
-        if (ep != null) {
-            list = ep.getInInterceptors();
-            if (LOG.isLoggable(Level.FINE)) {
-                LOG.fine("Interceptors contributed by endpoint: " + list);
-            }
-            chain.add(list);
-
-            // binding
-            list = ep.getBinding().getInInterceptors();
-            if (LOG.isLoggable(Level.FINE)) {
-                LOG.fine("Interceptors contributed by binding: " + list);
-            }
-            chain.add(list);
-
-            // service
-            list = ep.getService().getInInterceptors();
-            if (LOG.isLoggable(Level.FINE)) {
-                LOG.fine("Interceptors contributed by service: " + list);
-            }
-            chain.add(list);
-        }
-
-        return chain;
-    }
-
-    /**
-     * @return routing interceptor(s) specific to the routing context.
-     */
-    protected abstract List<Interceptor> getRoutingInterceptors();
-
-    /**
-     * @return "in" phrases from the phase manager specific to the routing context.
-     */
-    protected abstract SortedSet<Phase> getInPhases(); 
-    
-    /**
-     * This method is called when a response from a CXF server is observed at the
-     * router's transport (inbound to the router from a server).  It will return an
-     * "in" interceptor chain that will allow the response to be returned to the 
-     * involved routing interceptor (with the appropriate interceptors in between).
-     * @param exchange
-     * @return in interceptor chain
-     */
-    public PhaseInterceptorChain getResponseInInterceptorChain(Exchange exchange) {
-        return getInInterceptorChain(exchange, true);
-    }
+    private static final Logger LOG = Logger.getLogger(AbstractInvokingContext.class.getName());
 
     protected <T> T getResponseObject(Message inMessage, Map<String, Object>
responseContext,
-            Class <T> clazz) {        
+            Class <T> clazz) {
         T retval = null;
         if (inMessage != null) {
             if (null != responseContext) {
@@ -137,13 +57,28 @@
         return retval;
     }
 
-    /**
-     * This method is called to set the fault observers on the endpoint that are specified
-     * to the phases meaningful to the routing context.
-     * @param endpointImpl
-     * @param bus
-     */
-    public void setEndpointFaultObservers(EndpointImpl endpointImpl, Bus bus) {
-        // default is no op
+    protected void loggerTheMessage(Message message, String messageTile) {
+        StringBuffer buffer = new StringBuffer( messageTile + "\n"
+                                               + "--------------------------------------");
+        InputStream is = message.getContent(InputStream.class);
+        if (is != null) {
+            CachedOutputStream bos = new CachedOutputStream();
+            try {
+                IOUtils.copy(is, bos);
+
+                is.close();
+                bos.close();
+
+                buffer.append("\nMessage:\n");
+                buffer.append(bos.getOut().toString());
+
+                message.setContent(InputStream.class, bos.getInputStream());
+            } catch (IOException e) {
+                e.printStackTrace();
+            }
+        }
+        buffer.append("\n--------------------------------------");
+        LOG.info(buffer.toString());
     }
+
 }

Modified: activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/invoker/PayloadInvokingContext.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/invoker/PayloadInvokingContext.java?rev=629003&r1=629002&r2=629003&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/invoker/PayloadInvokingContext.java
(original)
+++ activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/invoker/PayloadInvokingContext.java
Mon Feb 18 22:32:39 2008
@@ -46,99 +46,35 @@
 public class PayloadInvokingContext extends AbstractInvokingContext {
     private static final Logger LOG = Logger.getLogger(PayloadInvokingContext.class.getName());
 
-    private PhaseManager phaseManager;
-    private PhaseManager faultPhaseManager;
-    private MessageObserver inFaultObserver;
-    private MessageObserver outFaultObserver;
-    
-    public PayloadInvokingContext() {
-        phaseManager = new PayloadPhaseManagerImpl();
-        faultPhaseManager = new FaultPayloadPhaseManagerImpl();
-    }
 
-    public PhaseInterceptorChain getRequestOutInterceptorChain(Exchange exchange) {
-        return getOutIntercepterChain(exchange);
-    }
+    public PayloadInvokingContext() {
 
-    public PhaseInterceptorChain getResponseOutInterceptorChain(Exchange exchange) {
-        return getOutIntercepterChain(exchange);
-    }
-
-    private PhaseInterceptorChain getOutIntercepterChain(Exchange exchange) {
-        PhaseInterceptorChain chain = new PhaseInterceptorChain(
-                new PayloadPhaseManagerImpl().getOutPhases());
-        
-        Bus bus = exchange.get(Bus.class);
-        assert bus != null;
-        
-        // bus
-        List<Interceptor> list = bus.getOutInterceptors();
-        if (LOG.isLoggable(Level.FINE)) {
-            LOG.fine("Interceptors contributed by bus: " + list);
-        }
-        chain.add(list);
-        
-        // endpoint
-        Endpoint endpoint = exchange.get(Endpoint.class);
-        if (endpoint != null) {
-            list = endpoint.getOutInterceptors();
-            if (LOG.isLoggable(Level.FINE)) {
-                LOG.fine("Interceptors contributed by endpoint: " + list);
-            }
-            chain.add(list);
-            list = endpoint.getBinding().getOutInterceptors();
-            if (LOG.isLoggable(Level.FINE)) {
-                LOG.fine("Interceptors contributed by binding: " + list);
-            }
-            chain.add(list);
-        }
-        chain.add(new DOMOutInterceptor());
-        chain.add(new PayloadContentRedirectInterceptor());
-        
-        return chain;
     }
 
     public void setRequestOutMessageContent(Message message, Object content) {
 
         PayloadMessage request = (PayloadMessage) content;
-        
+
         Element header = request.getHeader();
         List<Element> payload = request.getPayload();
-        
+
         if (LOG.isLoggable(Level.FINEST)) {
             LOG.finest("header = " + header + ", paylaod = " + payload);
         }
-        
-        message.put(Element.class, header);
-        message.put(List.class, payload);    
-    }
-
-    @Override
-    protected SortedSet<Phase> getInPhases() {
-        return phaseManager.getInPhases();
-    }
-    
-    protected SortedSet<Phase> getOutPhases() {
-        return phaseManager.getOutPhases();
-    }
 
-    @Override
-    protected List<Interceptor> getRoutingInterceptors() {
-        List<Interceptor> list = new ArrayList<Interceptor>();
-        list.add(new DOMInInterceptor());
-        list.add(new PayloadInInterceptor());
-        return list;
+        message.put(Element.class, header);
+        message.put(List.class, payload);
     }
 
     @SuppressWarnings("unchecked")
     public Object getResponseObject(Exchange exchange, Map<String, Object> responseContext)
{
         PayloadMessage payloadMsg = null;
-        
+
         Message msg = exchange.getInMessage();
         List<Element> payload = getResponseObject(msg , responseContext, List.class);
         Element header = exchange.getInMessage().get(Element.class);
-        payloadMsg = new PayloadMessage(payload, header);            
-        
+        payloadMsg = new PayloadMessage(payload, header);
+
         if (LOG.isLoggable(Level.FINEST)) {
             LOG.finest(payloadMsg.toString());
         }
@@ -160,65 +96,7 @@
         }
         return retval;
     }
-    
-    protected PhaseInterceptorChain getInInterceptorChain(Exchange exchange, boolean isResponse)
{
-
-        Bus bus = exchange.get(Bus.class);
-        assert bus != null;
-
-        PhaseInterceptorChain chain = new PhaseInterceptorChain(getInPhases());
-
-        List<Interceptor> routingInterceptors = getRoutingInterceptors();
-        chain.add(routingInterceptors);    
-        if (LOG.isLoggable(Level.FINE)) {
-            LOG.fine("Injected " + routingInterceptors);
-        }
-
-        // bus
-        List<Interceptor> list = bus.getInInterceptors();
-        if (LOG.isLoggable(Level.FINE)) {
-            LOG.fine("Interceptors contributed by bus: " + list);
-        }
-        chain.add(list);
-
-        // endpoint
-        Endpoint ep = exchange.get(Endpoint.class);
-        if (ep != null) {
-            list = ep.getInInterceptors();
-            if (LOG.isLoggable(Level.FINE)) {
-                LOG.fine("Interceptors contributed by endpoint: " + list);
-            }
-            chain.add(list);
-
-            // binding
-            list = ep.getBinding().getInInterceptors();
-            if (LOG.isLoggable(Level.FINE)) {
-                LOG.fine("Interceptors contributed by binding: " + list);
-            }
-            chain.add(list);
-        }
 
-        return chain;
-    }
-    
-    /**
-     * This method is called to set the fault observers on the endpoint that are specified
-     * to the phases meaningful to the routing context.
-     * @param endpointImpl
-     */
-    @Override
-    public void setEndpointFaultObservers(EndpointImpl endpointImpl, Bus bus) {
-        if (inFaultObserver == null) {
-            inFaultObserver = new FaultChainInitiatorObserver(bus, faultPhaseManager.getInPhases(),
false);
-        }
-        endpointImpl.setInFaultObserver(inFaultObserver);
-        
-        if (outFaultObserver == null) {
-            outFaultObserver = new FaultChainInitiatorObserver(bus, faultPhaseManager.getOutPhases(),
true);
-        }
-        endpointImpl.setOutFaultObserver(outFaultObserver);
-    }
-    
     public void setResponseContent(Message outMessage, Object resultPayload) {
         if (resultPayload != null) {
             PayloadMessage payloadMessage = (PayloadMessage) resultPayload;
@@ -234,12 +112,12 @@
     public Object getRequestContent(Message inMessage) {
         List<Element> payload = inMessage.get(List.class);
         Element header = inMessage.get(Element.class);
-        
+
         if (LOG.isLoggable(Level.FINEST)) {
             LOG.finest("Header = " + header + ", Payload = " + payload);
         }
-        
+
         return new PayloadMessage(payload, header);
     }
-    
+
 }

Modified: activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/invoker/RawMessageInvokingContext.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/invoker/RawMessageInvokingContext.java?rev=629003&r1=629002&r2=629003&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/invoker/RawMessageInvokingContext.java
(original)
+++ activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/invoker/RawMessageInvokingContext.java
Mon Feb 18 22:32:39 2008
@@ -43,143 +43,29 @@
 
 public class RawMessageInvokingContext extends AbstractInvokingContext {
     private static final Logger LOG = Logger.getLogger(RawMessageInvokingContext.class.getName());
-    
-    private PhaseManager phaseManager; 
 
     public RawMessageInvokingContext() {
-        phaseManager = new RawMessagePhaseManagerImpl();
-    }
-    
-    public PhaseInterceptorChain getRequestOutInterceptorChain(Exchange exchange) {
-        return getOutInterceptorChain(exchange);
-    }
-
-    public PhaseInterceptorChain getResponseOutInterceptorChain(Exchange exchange) {
-        return getOutInterceptorChain(exchange);
-    }
 
-    private PhaseInterceptorChain getOutInterceptorChain(Exchange exchange) {
-        
-        PhaseInterceptorChain chain = new PhaseInterceptorChain(
-                new RawMessagePhaseManagerImpl().getOutPhases());
-        
-        Bus bus = exchange.get(Bus.class);
-        assert bus != null;
-        
-        // bus
-        List<Interceptor> list = bus.getOutInterceptors();
-        if (LOG.isLoggable(Level.FINE)) {
-            LOG.fine("Interceptors contributed by bus: " + list);
-        }
-        chain.add(list);
-        
-        // endpoint
-        Endpoint endpoint = exchange.get(Endpoint.class);
-        if (endpoint != null) {
-            list = endpoint.getOutInterceptors();
-            if (LOG.isLoggable(Level.FINE)) {
-                LOG.fine("Interceptors contributed by endpoint: " + list);
-            }
-            chain.add(list);
-        }
-        
-        if (LOG.isLoggable(Level.FINE)) {
-            LOG.fine("inject " + RawMessageContentRedirectInterceptor.class);
-        }
-        chain.add(new RawMessageContentRedirectInterceptor());
-        
-        return chain;
-  
     }
 
     public void setRequestOutMessageContent(Message message, Object content) {
-        message.setContent(InputStream.class, content);        
-    }
-
-    @Override
-    protected SortedSet<Phase> getInPhases() {
-        return phaseManager.getInPhases();
-    }
-
-    @Override
-    protected List<Interceptor> getRoutingInterceptors() {
-        List<Interceptor> list = new ArrayList<Interceptor>();
-        list.add(new RawMessageInInterceptor());
-        return list;
+        message.setContent(InputStream.class, content);
     }
 
     public Object getResponseObject(Exchange exchange, Map<String, Object> responseContext)
{
-        
+
         return getResponseObject(exchange.getInMessage(), responseContext, InputStream.class);
     }
-    
-    //@Override
-    protected PhaseInterceptorChain getInInterceptorChain(Exchange exchange, boolean isResponse)
{
-
-        Bus bus = exchange.get(Bus.class);
-        assert bus != null;
-
-        PhaseInterceptorChain chain = new PhaseInterceptorChain(getInPhases());
-
-        if (!isResponse) {
-            List<Interceptor> routingInterceptors = getRoutingInterceptors();
-            chain.add(routingInterceptors);    
-            if (LOG.isLoggable(Level.FINE)) {
-                LOG.fine("Injected " + routingInterceptors);
-            }
-        }
-
-        // bus
-        List<Interceptor> list = bus.getInInterceptors();
-        
-        LOG.fine("Interceptors contributed by bus: " + list);
-        chain.add(list);
-
-        // endpoint
-        Endpoint ep = exchange.get(Endpoint.class);
-        if (ep != null) {
-            list = ep.getInInterceptors();
-            if (LOG.isLoggable(Level.FINE)) {
-                LOG.fine("Interceptors contributed by endpoint: " + list);
-            }
-            chain.add(list);
-        }
 
-        return chain;
-    }
-    
     public void setResponseContent(Message outMessage, Object resultPayload) {
         LOG.info("Set content: " + resultPayload);
         outMessage.setContent(InputStream.class, resultPayload);
         //loggerTheMessage(outMessage, "Out Message");
     }
 
-    public Object getRequestContent(Message inMessage) {        
+    public Object getRequestContent(Message inMessage) {
         //loggerTheMessage(inMessage, "In Message");
         return inMessage.getContent(InputStream.class);
     }
-    
-    private void loggerTheMessage(Message message, String messageTile) {
-        StringBuffer buffer = new StringBuffer( messageTile + "\n" 
-                                               + "--------------------------------------");
-        InputStream is = message.getContent(InputStream.class);        
-        if (is != null) {
-            CachedOutputStream bos = new CachedOutputStream();
-            try {
-                IOUtils.copy(is, bos);
-
-                is.close();
-                bos.close();
-
-                buffer.append("\nMessage:\n");
-                buffer.append(bos.getOut().toString());
-                
-                message.setContent(InputStream.class, bos.getInputStream());
-            } catch (IOException e) {
-                e.printStackTrace();
-            }
-        }
-        buffer.append("\n--------------------------------------");
-        LOG.info(buffer.toString());
-    }
+
 }



Mime
View raw message