0

I am sure I have missed something really obvious but just haven’t worked it out.

We use bindy to extract a CSV file into a POJO . This has been working nice and well. We have been given some more CSV files to load. This is where I discovered the issue. Bindy doesn’t allow multiple classes to have the @CsvRecord annotation to live in the same package if you do a package scan. But that is ok since we use camel 2.13.3 and I can see that the constructor for BindyCsvDataFormat allows us to pass in a class.

The trouble I am having is, we use spring.xml to setup camel. I can’t seem to get the BindyCsvDataFormat to use the class constructor. It will only use the one that does a package scan.

<bean id="bindyDataformat" class="org.apache.camel.dataformat.bindy.csv.BindyCsvDataFormat">
    <constructor-arg value="com.something.package.Model.class" />
</bean>

The above didn’t work. I suspect it is with me passing a string as the constructor-arg so the string constructor is always called. Is there a way to get BindyCsvDataFormat to not do the package scan and to allow me to provide the class I want the csv data unmarshalled to in the spring.xml?

  • Does this help: http://stackoverflow.com/questions/11971651/pass-hardcoded-constructor-arg-classt-to-bean-via-spring-config – vikingsteve Feb 04 '15 at 14:46
  • Yes, it did help. It was in fact the answer I was looking for. Many Thanks. If you make an answer i will mark it as the correct one. – nate-sonicbottle Feb 04 '15 at 15:54

1 Answers1

0

What you are trying to do is not specific to bindy. It's a common problem where you need to inject the "value" of a Class via Spring DI.

Here's a link that describes how to do pass a class argument properly:

pass "HardCoded" Constructor Arg Class<T> to bean via Spring Config

Community
  • 1
  • 1
vikingsteve
  • 38,481
  • 23
  • 112
  • 156