2 Replies Latest reply on Aug 13, 2012 1:23 AM by davsclaus

    Type converter feature request

    jamie3_james.archibald

      Currently the following works:

       

      public class TracePointTypeConverterTest extends CamelTestSupport {

       

           @Test

           public void lookup() {

                assertNotNull(context.getTypeConverterRegistry().lookup(SomeObject.class, AnotherObject.class));

           }

      }

       

      @Converter

      public class MyTypeConverter {

       

         @Converter

         public SomeObject convert(AnotherObject obj, Exchange exg) {

             String foo = exg.getIn().getHeader("foo", String.class);

             // do something

         }

      }

       

       

      This however does not work and the unit test fails:

       

      @Converter

      public class MyTypeConverter {

       

         @Converter

         public SomeObject convert(AnotherObject obj, @Header("foo") String foo, ...) {

             // do something

         }

      }

        • 1. Re: Type converter feature request
          njiang

          It is strange that you are using @Header and define the converter method with more than two parameter.

           

          Camel Converter only supports to take the Exchange as an additional parameter, not like the bean method can take the @Header annotation.

           

          Willem

          • 2. Re: Type converter feature request
            davsclaus

            Yes the type converter method signature, only supports 1 or 2 parameters.

             

            1 parameter = the from type

            2 parameters = the from type, Exchange as the 2nd parameter

             

            You cannot use the bean parameter bindings.

            And we do not intend to support this in the future.