I have looked at the documentation but couldn’t find how to add custom type converters for mongoDB. How can one do it ?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
First of all I think that
fromAnyObjectToDBObjectdefault converter can resolve most of your cases. It uses Jackson library and all you need is to mark your custom classes with right annotations.Anyway, if you still need custom converter, following steps should be performed:
White your conversion logic and mark your class and converter methods with
org.apache.camel.Converterannotation:Create following resource file to be placed in your result jar:
META-INF/services/org/apache/camel/TypeConverter
And list your converter classes in this file:
com.acme.converters.CustomConverter
This file will help Camel to auto-discover your own converters.
You can also take a look at:
META-INF/services/org/apache/camel/TypeConverterin camel-mongodb-x.x.x.jar to see how default converter definedorg.apache.camel.impl.converter.AnnotationTypeConverterLoaderclass to check converters loading logic