camel-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Claus Ibsen" ...@silverbullet.dk>
Subject RE: svn commit: r691178 - in /activemq/camel/trunk/components/camel-mina/src: main/java/org/apache/camel/component/mina/ test/java/org/apache/camel/component/mina/
Date Wed, 03 Sep 2008 07:19:31 GMT
Hi Willem

You forgot one typo ;)
exclued => excluded


Med venlig hilsen
 
Claus Ibsen
......................................
Silverbullet
Skovsgårdsvænget 21
8362 Hørning
Tlf. +45 2962 7576
Web: www.silverbullet.dk
-----Original Message-----
From: Willem Jiang [mailto:willem.jiang@gmail.com] 
Sent: 3. september 2008 05:36
To: camel-dev@activemq.apache.org
Subject: Re: svn commit: r691178 - in /activemq/camel/trunk/components/camel-mina/src: main/java/org/apache/camel/component/mina/
test/java/org/apache/camel/component/mina/

Hi Claus

Thank you for point the issues out, I just commit a quick fix for it.
I just went through the William's header filter, it mainly works for 
filtering the header name.
For the mina component the headers only are sent with the exchange , 
most works can be done in the MinaPayloadHolder :)

Willem

Claus Ibsen wrote:
> Hi
>
> A few cosmetic issues:
> - System.out in a unit test
> - Spelling in the WARN log" exculed by the MinaPayloadHold"
>   Should be excluded and ...holder
>
> A side note: What about William Tam's new header stuff? Can't it be used to exclude the
headers not supported? Maybe it's to confusing to use ;)
>
>
> Med venlig hilsen
>  
> Claus Ibsen
> ......................................
> Silverbullet
> Skovsgårdsvænget 21
> 8362 Hørning
> Tlf. +45 2962 7576
> Web: www.silverbullet.dk
> -----Original Message-----
> From: ningjiang@apache.org [mailto:ningjiang@apache.org] 
> Sent: 2. september 2008 11:58
> To: camel-commits@activemq.apache.org
> Subject: svn commit: r691178 - in /activemq/camel/trunk/components/camel-mina/src: main/java/org/apache/camel/component/mina/
test/java/org/apache/camel/component/mina/
>
> Author: ningjiang
> Date: Tue Sep  2 02:58:23 2008
> New Revision: 691178
>
> URL: http://svn.apache.org/viewvc?rev=691178&view=rev
> Log:
> CAMEL-874 Add seralizable checking on the MinaPayloadHolder to make sure the MinaPayloadHolder
can be seralized by Mina
>
> Modified:
>     activemq/camel/trunk/components/camel-mina/src/main/java/org/apache/camel/component/mina/MinaConsumer.java
>     activemq/camel/trunk/components/camel-mina/src/main/java/org/apache/camel/component/mina/MinaPayloadHolder.java
>     activemq/camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaTransferExchangeOptionTest.java
>
> Modified: activemq/camel/trunk/components/camel-mina/src/main/java/org/apache/camel/component/mina/MinaConsumer.java
> URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-mina/src/main/java/org/apache/camel/component/mina/MinaConsumer.java?rev=691178&r1=691177&r2=691178&view=diff
> ==============================================================================
> --- activemq/camel/trunk/components/camel-mina/src/main/java/org/apache/camel/component/mina/MinaConsumer.java
(original)
> +++ activemq/camel/trunk/components/camel-mina/src/main/java/org/apache/camel/component/mina/MinaConsumer.java
Tue Sep  2 02:58:23 2008
> @@ -109,14 +109,15 @@
>                  } else {
>                      body = MinaPayloadHelper.getIn(endpoint, exchange);
>                  }
> -                boolean failed = exchange.isFailed();                
> -                if (!endpoint.isTransferExchange() && failed) {
> +                boolean failed = exchange.isFailed();
> +                if (failed && !endpoint.isTransferExchange()) {
>                      if (exchange.getException() != null) {
>                          body = exchange.getException();
>                      } else {
>                          body = exchange.getFault().getBody();
>                      }
>                  }
> +
>                  if (body == null) {
>                      // must close session if no data to write otherwise client will
never receive a response
>                      // and wait forever (if not timing out)
>
> Modified: activemq/camel/trunk/components/camel-mina/src/main/java/org/apache/camel/component/mina/MinaPayloadHolder.java
> URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-mina/src/main/java/org/apache/camel/component/mina/MinaPayloadHolder.java?rev=691178&r1=691177&r2=691178&view=diff
> ==============================================================================
> --- activemq/camel/trunk/components/camel-mina/src/main/java/org/apache/camel/component/mina/MinaPayloadHolder.java
(original)
> +++ activemq/camel/trunk/components/camel-mina/src/main/java/org/apache/camel/component/mina/MinaPayloadHolder.java
Tue Sep  2 02:58:23 2008
> @@ -19,8 +19,11 @@
>  import java.io.Serializable;
>  import java.util.LinkedHashMap;
>  import java.util.Map;
> +import java.util.Set;
>  
>  import org.apache.camel.Exchange;
> +import org.apache.commons.logging.Log;
> +import org.apache.commons.logging.LogFactory;
>  
>  /**
>   * Holder object for sending an exchange over the wire using the MINA ObjectSerializationCodecFactory
codec.
> @@ -43,6 +46,7 @@
>   */
>  public class MinaPayloadHolder implements Serializable {
>      private static final long serialVersionUID = 1L;
> +    private static final transient Log LOG = LogFactory.getLog(MinaPayloadHolder.class);
>  
>      private Object inBody;
>      private Object outBody;
> @@ -55,6 +59,7 @@
>  
>      /**
>       * Creates a payload object with the information from the given exchange.
> +     * Only marshal the Serializable object
>       *
>       * @param exchange     the exchange
>       * @return the holder object with information copied form the exchange
> @@ -62,17 +67,17 @@
>      public static MinaPayloadHolder marshal(Exchange exchange) {
>          MinaPayloadHolder payload = new MinaPayloadHolder();
>  
> -        payload.inBody = exchange.getIn().getBody();
> +        payload.inBody = checkSerializableObject(exchange.getIn().getBody());
>          if (exchange.getOut(false) != null) {
> -            payload.outBody = exchange.getOut().getBody();
> +            payload.outBody = checkSerializableObject(exchange.getOut().getBody());
>          }
> -        payload.inHeaders.putAll(exchange.getIn().getHeaders());
> -        payload.outHeaders.putAll(exchange.getOut().getHeaders());
> -        payload.properties.putAll(exchange.getProperties());
> +        payload.inHeaders.putAll(checkMapSerializableObjects(exchange.getIn().getHeaders()));
> +        payload.outHeaders.putAll(checkMapSerializableObjects(exchange.getOut().getHeaders()));
> +        payload.properties.putAll(checkMapSerializableObjects(exchange.getProperties()));
>          payload.exception = exchange.getException();
>          if (exchange.getFault(false) != null) {
>              payload.faultBody = exchange.getFault().getBody();
> -            payload.faultHeaders.putAll(exchange.getFault().getHeaders());
> +            payload.faultHeaders.putAll(checkMapSerializableObjects(exchange.getFault().getHeaders()));
>          }
>  
>          return payload;
> @@ -105,4 +110,33 @@
>                 + faultHeaders + ", properties=" + properties + ", exception=" + exception
+ '}';
>      }
>  
> +    private static Object checkSerializableObject(Object object) {
> +        if (object instanceof Serializable) {
> +            return object;
> +        } else {
> +            LOG.warn("Object " + object + " can't be serialized, it will be exculed
by the MinaPayloadHold");
> +            return null;
> +        }
> +    }
> +
> +    private static Map<String, Object> checkMapSerializableObjects(Map<String,
Object> map) {
> +        if (map == null) {
> +            return null;
> +        }
> +        Set<String> keys = map.keySet();
> +        Map<String, Object> result = new LinkedHashMap<String, Object>();
> +        for (String key : keys) {
> +            Object object = map.get(key);
> +            if (object instanceof Serializable) {
> +                result.put(key, object);
> +            } else {
> +                LOG.warn("Object " + object + " of key " + key
> +                         + " can't be serialized, it will be exculed by the MinaPayloadHold");
> +            }
> +        }
> +        return result;
> +
> +    }
> +
> +
>  }
>
> Modified: activemq/camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaTransferExchangeOptionTest.java
> URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaTransferExchangeOptionTest.java?rev=691178&r1=691177&r2=691178&view=diff
> ==============================================================================
> --- activemq/camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaTransferExchangeOptionTest.java
(original)
> +++ activemq/camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaTransferExchangeOptionTest.java
Tue Sep  2 02:58:23 2008
> @@ -16,6 +16,8 @@
>   */
>  package org.apache.camel.component.mina;
>  
> +import java.nio.charset.Charset;
> +
>  import junit.framework.Assert;
>  
>  import org.apache.camel.ContextTestSupport;
> @@ -71,7 +73,7 @@
>              assertEquals("cheddar", out.getHeader("cheese"));
>          } else {
>              Message fault = exchange.getFault();
> -            assertNotNull(fault);
> +            assertNotNull(fault.getBody());
>              assertTrue("Should get the InterrupteException exception", fault.getBody()
instanceof InterruptedException);
>              assertEquals("nihao", fault.getHeader("hello"));
>          }
> @@ -84,6 +86,7 @@
>          assertEquals("feta", in.getHeader("cheese"));
>          // however the shared properties have changed
>          assertEquals("fresh", exchange.getProperty("salami"));
> +        assertNull(exchange.getProperty("Charset"));
>      }
>  
>      protected RouteBuilder createRouteBuilder() {
> @@ -108,6 +111,7 @@
>                              e.getOut().setHeader("cheese", "cheddar");
>                          }
>                          e.setProperty("salami", "fresh");
> +                        e.setProperty("Charset", Charset.defaultCharset());
>                      }
>                  });
>              }
>
>
>
>   


Mime
View raw message