camel-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Claus Ibsen <claus.ib...@gmail.com>
Subject Re: svn commit: r738999 - in /camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf: CxfEndpoint.java CxfExchange.java CxfMessage.java converter/CxfConverter.java
Date Fri, 30 Jan 2009 06:09:31 GMT
On Fri, Jan 30, 2009 at 7:04 AM, William Tam <email.wtam@gmail.com> wrote:
> Hi Claus,
>
> The code in CxfMessage#getBody was checking if a message body was a
> org.apache.cxf.message.MessageContentList.  If so, it extracted the
> first element and applied converter to the first element.  That piece
> of logic now resides in the CxfConverter.convertTo, which is a
> FallbackConverter.   Let me know if I am missing something,
>
> Thanks,
> William
Great I kinda forgot from the commit log that you deleted 2 files. The
content of these files is not logged :)
And I just wanted to raise a flag in case there was still something in
the CXF that should be looked at.




>
> On Fri, Jan 30, 2009 at 12:23 AM, Claus Ibsen <claus.ibsen@gmail.com> wrote:
>> Hi Willem
>>
>> There might be some left overs still there. I remember Jiang added
>> something to CxfMessage#getBody (or someplace like that) that would
>> kinda do something like that below.
>>
>> Maybe that code is still there?
>>
>> There is a ticket in JIRA somewhere about it, I can find it if you
>> need it. Ticket reported by me on camel-cxf and fixed by Jiang.
>>
>>
>>
>> On Thu, Jan 29, 2009 at 9:35 PM,  <wtam@apache.org> wrote:
>>> Author: wtam
>>> Date: Thu Jan 29 20:35:54 2009
>>> New Revision: 738999
>>>
>>> URL: http://svn.apache.org/viewvc?rev=738999&view=rev
>>> Log:
>>> use FallbackConverter in camel-cxf component, which means we can get rid of CxfMessage
and CxfExchange class.  Very cool.
>>>
>>> Removed:
>>>    camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfExchange.java
>>>    camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfMessage.java
>>> Modified:
>>>    camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfEndpoint.java
>>>    camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/converter/CxfConverter.java
>>>
>>> Modified: camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfEndpoint.java
>>> URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfEndpoint.java?rev=738999&r1=738998&r2=738999&view=diff
>>> ==============================================================================
>>> --- camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfEndpoint.java
(original)
>>> +++ camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfEndpoint.java
Thu Jan 29 20:35:54 2009
>>> @@ -25,8 +25,6 @@
>>>  import org.apache.camel.CamelContext;
>>>  import org.apache.camel.CamelException;
>>>  import org.apache.camel.Consumer;
>>> -import org.apache.camel.Exchange;
>>> -import org.apache.camel.ExchangePattern;
>>>  import org.apache.camel.HeaderFilterStrategyAware;
>>>  import org.apache.camel.Processor;
>>>  import org.apache.camel.Producer;
>>> @@ -97,11 +95,6 @@
>>>         return new CxfConsumer(this, processor);
>>>     }
>>>
>>> -    @Override
>>> -    public Exchange createExchange(ExchangePattern pattern) {
>>> -        return new CxfExchange(this, pattern);
>>> -    }
>>> -
>>>     public boolean isSingleton() {
>>>         return true;
>>>     }
>>>
>>> Modified: camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/converter/CxfConverter.java
>>> URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/converter/CxfConverter.java?rev=738999&r1=738998&r2=738999&view=diff
>>> ==============================================================================
>>> --- camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/converter/CxfConverter.java
(original)
>>> +++ camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/converter/CxfConverter.java
Thu Jan 29 20:35:54 2009
>>> @@ -22,9 +22,13 @@
>>>
>>>  import org.apache.camel.Converter;
>>>  import org.apache.camel.Endpoint;
>>> +import org.apache.camel.Exchange;
>>> +import org.apache.camel.FallbackConverter;
>>> +import org.apache.camel.TypeConverter;
>>>  import org.apache.camel.component.cxf.CxfSpringEndpoint;
>>>  import org.apache.camel.component.cxf.DataFormat;
>>>  import org.apache.camel.component.cxf.spring.CxfEndpointBeanDefinitionParser.CxfSpringEndpointBean;
>>> +import org.apache.camel.spi.TypeConverterRegistry;
>>>  import org.apache.camel.spring.SpringCamelContext;
>>>  import org.apache.commons.logging.Log;
>>>  import org.apache.commons.logging.LogFactory;
>>> @@ -89,4 +93,41 @@
>>>         return DataFormat.valueOf(name.toUpperCase());
>>>     }
>>>
>>> +    /**
>>> +     * Use a fallback type converter so we can convert the embedded list element
>>> +     * if the value is MessageContentsList.  The algorithm of this converter
>>> +     * finds the first non-null list element from the list and applies convertion
>>> +     * to the list element.
>>> +     *
>>> +     * @param type the desired type to be converted to
>>> +     * @param exchange optional exchange which can be null
>>> +     * @param value the object to be converted
>>> +     * @param registry type converter registry
>>> +     * @return the converted value of the desired type or null if no suitable
converter found
>>> +     */
>>> +    @FallbackConverter
>>> +    public static <T> T convertTo(Class<T> type, Exchange exchange,
Object value,
>>> +            TypeConverterRegistry registry) {
>>> +
>>> +        if (MessageContentsList.class.isAssignableFrom(value.getClass())) {
>>> +            MessageContentsList list = (MessageContentsList)value;
>>> +
>>> +            for (int i = 0; i < list.size(); i++) {
>>> +                Object embedded = list.get(i);
>>> +
>>> +                if (embedded != null) {
>>> +                    if (type.isInstance(embedded)) {
>>> +                        return (T)embedded;
>>> +                    } else {
>>> +                        TypeConverter tc = registry.lookup(type, embedded.getClass());
>>> +                        if (tc != null) {
>>> +                            return tc.convertTo(type, exchange, embedded);
>>> +                        }
>>> +                    }
>>> +                }
>>> +            }
>>> +        }
>>> +
>>> +        return null;
>>> +    }
>>>  }
>>>
>>>
>>>
>>
>>
>>
>> --
>> Claus Ibsen
>> Apache Camel Committer
>>
>> Open Source Integration: http://fusesource.com
>> Blog: http://davsclaus.blogspot.com/
>>
>



-- 
Claus Ibsen
Apache Camel Committer

Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/

Mime
View raw message