I am trying to set up the following route:
@Override
public void configure() throws Exception {
log.info("Creating ftp rout from " + config.ftpUrl().split("\\?")[0]);
from(config.ftpUrl()
+ "&stepwise=true"
+ "&delay=1000"
+ "&move=${file:name}.trans"
+ "&recursive=true"
+ "&binary=true"
+ "&filter=#" + Beans.doneFilter.name()
+ "&maxMessagesPerPoll=200"
+ "&eagerMaxMessagesPerPoll=false"
+ "&sorter=#" + Beans.sorter.name())
.log("Downloading file ${file:name}")
.to("file:" + config.ftpTargetPostpaid())
.to("file:" + config.ftpTargetPrepaid())
.to("file:" + config.ftpTargetFonic())
//.routePolicyRef(Beans.policy.name())
.autoStartup(false)
.routeId("ftp");
}
The error is:
Could not find a suitable setter for property: filter as there isn't a setter method with same type: java.lang.String nor type conversion possible: No type converter available to convert from type: java.lang.String to the required type: org.apache.camel.component.file.GenericFileFilter with value #doneFilter
I think the way i reference a bound bean is wrong? I bound all beans this way(stand alone app):
public class MainApp {
/**
* A main() so we can easily run these routing rules in our IDE
*/
public static void main(String... args) throws Exception {
Injector i = Guice.createInjector(new CepModule());
Main main = new Main();
bindBeans(main);
main.enableHangupSupport();
main.addRouteBuilder(i.getInstance(FetchFtp.class));
main.run();
}
private static void bindBeans(Main main) {
for (Beans bean : Beans.values()) {
main.bind(bean.name(), bean.clazz());
}
}
/**
* This is the java style bean registry. Use the enums name as reference to the bean.
*
*
*/
public static enum Beans{
sorter(SortingStrategy.class),
policy(PolicyForStartAndStopRoutes.class),
doneFilter(ExcludeDoneFilesFilter.class);
private final Class<?> clazz;
Beans(Class<?> clazz){
this.clazz = clazz;;
}
public Class<?> clazz(){
return clazz;
}
}
}
So how to use beans/classes in routes configured in java?