cool.

On 10/9/07, James Strachan <[EMAIL PROTECTED]> wrote:
> IIRC the reason I skipped Object was to avoid finding Object based
> converters before interface based converters. i.e. Object should be
> used last after all other base classes or interfaces are attempted.
>
> I've just patched the type converter to look for Object based
> converters after the base classes and any interfaces - along with
> adding a test case for testing String -> Boolean and all appears well
> now
>
>
> On 08/10/2007, William Tam <[EMAIL PROTECTED]> wrote:
> > I see.  I think we can do something like this instead.
> >
> >            Class fromSuperClass = fromType.getSuperclass();
> >             if (fromSuperClass != null) {
> >                 TypeConverter converter = getTypeConverter(toType,
> > fromSuperClass);
> >                 if (converter == null && 
> > !fromSuperClass.equals(Object.class)) {
> >                     converter = findTypeConverter(toType,
> > fromSuperClass, value);
> >                 }
> >                 if (converter != null) {
> >                     return converter;
> >                 }
> >             }
> >
> > BTW, you can use my test case in the patch to verify it.  (just ignore
> > the ObjectConverter change).
> >
> >
> > On 10/8/07, Hiram Chirino <[EMAIL PROTECTED]> wrote:
> > > 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 PROTECTED]> 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 PROTECTED]> wrote:
> > > > > Good point.  I'll take a look at that.
> > > > >
> > > > > On 10/8/07, Guillaume Nodet <[EMAIL PROTECTED]> 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 PROTECTED]> 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
> > >
> >
>
>
> --
> James
> -------
> http://macstrac.blogspot.com/
>
> Open Source SOA
> http://open.iona.com
>

Reply via email to