3 Replies Latest reply on Apr 22, 2011 5:23 AM by davsclaus

    TypeConverter interface

    mfatafta2

      I am trying to understand how is the TypeConverter implementation will be used by Camel. How does Camel decide which convertTo method to call? How can I force Camel to call the convertTo that takes the Exchange as a parameter but not the other methods?

       

      Is there a better example that I can follow?

       

      private class MyOrderTypeConverter implements TypeConverter {

       

          @SuppressWarnings("unchecked")

          public  type, Exchange exchange, Object value) {

              return convertTo(type, value);

          }

      }

        • 1. Re: TypeConverter interface
          davsclaus

          Its much easier to use use a regular bean and add @Converter annotation to the class and the method(s) you want to be type converters.

           

          See more here

          http://camel.apache.org/type-converter.html

           

          If you have the Camel in Action book, then its also discussed in chapter 3.

          • 2. Re: TypeConverter interface
            mfatafta2

            Thanks for the comment.

             

            I am using the @Converter annotation and that seems to work fine.

             

            I am just trying to understand how the TypeConverter interface can be used.

             

            By the way, I already have you book way when it was first released.

             

            So, the question still unanswered.

             

            Thanks again.

            • 3. Re: TypeConverter interface
              davsclaus

              End users is encouraged to use the @Converter and beans.

               

              The TypeConverter interface is more for internal usages etc.

               

               

              Camel will pick the Exchange method if its available, if not it will pick the one without the Exchange.