2

I am defining a list in the following way in my blueprint-bean.xml

<cm:default-properties>
   <cm:property name="test-list">
            <list>
                <value type="java.lang.String"> "test 1" </value>
                <value type ="java.lang.String"> "test 2." </value>
                <value type ="java.lang.String"> "test 3." </value>
            </list>
</cm:property>
...

And i have not found a way to successfully retrieve it as a list in my routebuilder class.

Which looks like the following:

public class TestRoute extends RouteBuilder {

    @PropertyInject("testInt") int rate;
    @PropertyInject("test-list")   List<String> testlist;
...

I always get the exception:

No type converter available to convert from type: java.lang.String to the required type: java.util.List with value [ "test 1." ,  "test 2." ,  "test 3." ]

So the list seems to be converted to a String at some point and then cannot be converted back to a list at the point of injection.

Am i using the Annotation in a wrong way or is there another way to inject a list property into my JDSL route?

The annotation is working for all my other properties except for the List.

  • 1
    I haven't seen that you can inject a list like that. Try asking at the Camel gitterhub as well. From your error message it seems it is not retrieving a list but a simple string. – Souciance Eqdam Rashti Mar 30 '18 at 14:07
  • 1
    To me it looks like it's actually an Array. You could try changing to `@PropertyInject("test-list") String[] testlist;` then if you really need it to be a List it should be minimal effort to convert it. – Erik Karlstrand Apr 03 '18 at 06:17
  • I should have clarified that i found out in the meantime that the PropertyInject Annotation always returns a String and that is the intended behavior of the method. Im still curious if there is any way to straight up inject a list from blueprint or if i have to convert the String or String[] array i retrieve manually. – user9338894 Apr 03 '18 at 06:58

0 Answers0