camel-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Hiram Chirino" <hi...@hiramchirino.com>
Subject Re: Patch to convert from String to Boolean
Date Mon, 08 Oct 2007 21:58:01 GMT
I think it was trying to break out of the recursion.. but perhaps it's
doing the check at the wrong point.

On 10/8/07, William Tam <email.wtam@gmail.com> wrote:
> In method org.apache.camel.impl.converter.DefaultTypeConverter.findTypeConverter(),
> any reasons why it skips if "!fromSuperClass.equals(Object.class)"?
> My test case seems to work I leave that out since it is then try to
> find the converter for Object->Boolean.
>
>        Class fromSuperClass = fromType.getSuperclass();
>             if (fromSuperClass != null &&
> !fromSuperClass.equals(Object.class)) {
>                 TypeConverter converter = getTypeConverter(toType,
> fromSuperClass);
>                 if (converter == null) {
>                     converter = findTypeConverter(toType,
> fromSuperClass, value);
>                 }
>                 if (converter != null) {
>                     return converter;
>                 }
>             }
>
> On 10/8/07, William Tam <email.wtam@gmail.com> wrote:
> > Good point.  I'll take a look at that.
> >
> > On 10/8/07, Guillaume Nodet <gnodet@gmail.com> wrote:
> > > Shouldn't the converter registry be able to do that ? If there is a
> > > conversion from x to y available, it should use it whenever the object to be
> > > converted inherits / implements x.
> > >
> > > On 10/8/07, William Tam <email.wtam@gmail.com> wrote:
> > > >
> > > > I wasn't able to convert a String to a Boolean using a route such as
> > > > from("direct:test").convertBodyTo(Boolean.class).  The problem is the
> > > > annotated converter method ObjectConverter.toBoolean(Object value) is
> > > > never reached.  The reason is that the converter is registered with
> > > > the key [class java.lang.Object=>class java.lang.Boolean] as taken
> > > > from the signature.  However, my route uses the key [class
> > > > java.lang.String=>class java.lang.Boolean] to look up a converter (so
> > > > none found)  since my in-message type is String (not Object).  I have
> > > > attached a patch which includes a unit test.
> > > >
> > > > Regards,
> > > > William
> > > >
> > > >
> > >
> > >
> > > --
> > > Cheers,
> > > Guillaume Nodet
> > > ------------------------
> > > Blog: http://gnodet.blogspot.com/
> > >
> >
>


-- 
Regards,
Hiram

Blog: http://hiramchirino.com

Mime
View raw message