Return-Path: Delivered-To: apmail-activemq-camel-commits-archive@locus.apache.org Received: (qmail 70011 invoked from network); 19 Feb 2008 06:33:18 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 19 Feb 2008 06:33:18 -0000 Received: (qmail 86996 invoked by uid 500); 19 Feb 2008 06:33:12 -0000 Delivered-To: apmail-activemq-camel-commits-archive@activemq.apache.org Received: (qmail 86976 invoked by uid 500); 19 Feb 2008 06:33:12 -0000 Mailing-List: contact camel-commits-help@activemq.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: camel-dev@activemq.apache.org Delivered-To: mailing list camel-commits@activemq.apache.org Received: (qmail 86967 invoked by uid 99); 19 Feb 2008 06:33:12 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 18 Feb 2008 22:33:12 -0800 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 19 Feb 2008 06:32:33 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id D424B1A9832; Mon, 18 Feb 2008 22:32:52 -0800 (PST) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: camel-commits@activemq.apache.org From: ningjiang@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20080219063252.D424B1A9832@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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 routingInterceptors = getRoutingInterceptors(); - chain.add(routingInterceptors); - if (LOG.isLoggable(Level.FINE)) { - LOG.fine("Injected " + routingInterceptors); - } - } - - // bus - List 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 getRoutingInterceptors(); - - /** - * @return "in" phrases from the phase manager specific to the routing context. - */ - protected abstract SortedSet 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 getResponseObject(Message inMessage, Map responseContext, - Class clazz) { + Class 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 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 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 getInPhases() { - return phaseManager.getInPhases(); - } - - protected SortedSet getOutPhases() { - return phaseManager.getOutPhases(); - } - @Override - protected List getRoutingInterceptors() { - List list = new ArrayList(); - 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 responseContext) { PayloadMessage payloadMsg = null; - + Message msg = exchange.getInMessage(); List 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 routingInterceptors = getRoutingInterceptors(); - chain.add(routingInterceptors); - if (LOG.isLoggable(Level.FINE)) { - LOG.fine("Injected " + routingInterceptors); - } - - // bus - List 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 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 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 getInPhases() { - return phaseManager.getInPhases(); - } - - @Override - protected List getRoutingInterceptors() { - List list = new ArrayList(); - list.add(new RawMessageInInterceptor()); - return list; + message.setContent(InputStream.class, content); } public Object getResponseObject(Exchange exchange, Map 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 routingInterceptors = getRoutingInterceptors(); - chain.add(routingInterceptors); - if (LOG.isLoggable(Level.FINE)) { - LOG.fine("Injected " + routingInterceptors); - } - } - - // bus - List 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()); - } + }