1

I have a HashMap to String Type Converter in my jar, say A.jar but a similar converter exists in another jar, B.jar (exposed by a third party in the same server) but I always want my type converter(present in A.jar) to get invoked in my camel route, when I call

String body=message.getBody(String.class);

Any idea on how this can be done?

user3201181
  • 62
  • 1
  • 9
  • by default you can't decide your jar orders, maybe take a look at : http://stackoverflow.com/questions/5817802/loading-two-classes-in-different-jars – yunandtidus Feb 17 '15 at 14:59

2 Answers2

0

Well if you have both jars loaded by the classloader in the same camel context, there is a high chance of something going wrong here.

You could work around it.

Firstly, you could just use a bean reference to the specific type converter (instead of getBody(String.class)).

Or secondly, you could hack into the TypeConverterRegistry at runtime and see if you can remove the one you don't need, see: context.getTypeConverterRegistry().

vikingsteve
  • 38,481
  • 23
  • 112
  • 156
0

You can create a Wrapper Class that is only having a String element. Lets call this WrapperString. Define the toString() method of this wrapper class to only return the String element.

Modify your converter from Hashmap to String to Hashmap to WrapperString.

In the conversion logic, you simply write your own logic for converting the hashmap to String, then create an instance of the WrapperString class and assign that converted value to this object.

DolphinJava
  • 2,682
  • 1
  • 23
  • 37