2016-02-14 43 views
0

我想使用apache骆驼文件名过滤器。 我收到IllegalArgumentException类型的错误 - 请参阅下文。 你能指点一下吗?与骆驼文件名过滤器我得到一个错误

春天的xml:

<bean id="adoFilter" class="calypsox.bllInterfaces.cashMgn.cashMgnAdo.AdoFileFilter"/> 
       <camelContext xmlns="http://camel.apache.org/schema/spring" 
           id="cashMgn"> 
           <propertyPlaceholder id="cashMgnProperty" 
               location="${bll.resources.env}/cashMgn.properties" /> 
           <route id="cashMgnAdo"> 
               <from 
                   uri="file:{{cashMgnAdoFileDir}}?filter=#adoFilter;move=.org/${date:now:yyyyMMdd}/${file:name}&amp;readLock=changed&amp;readLockCheckInterval=2000&amp;readLockTimeout=10000&amp;moveFailed=.failed" /> 
               <convertBodyTo type="java.lang.String" /> 
               <to uri="bean:cashMgnHandler?method=handleCashMgnAdo" /> 
           </route> 

       </camelContext> 

java的过滤器类:

 public class AdoFileFilter<T> implements GenericFileFilter<T> { 
       public boolean accept(GenericFile<T> file) { 
           // we want all directories 
           // if (((File) file).isDirectory()) { 
           // return true; 
           // } 

           // we dont accept any files starting with skip in the name 
           return true;// !file.getFileName().startsWith("skip"); 
       } 
} 

例外:

Caused by: java.lang.IllegalArgumentException: 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 #adoFilter;move=.org/${date:now:yyyyMMdd}/${file:name} 

       at org.apache.camel.util.IntrospectionSupport.setProperty(IntrospectionSupport.java:341) 

       at org.apache.camel.util.IntrospectionSupport.setProperties(IntrospectionSupport.java:291) 

       at org.apache.camel.util.EndpointHelper.setProperties(EndpointHelper.java:225) 

       at org.apache.camel.impl.DefaultComponent.setProperties(DefaultComponent.java:200) 

       at org.apache.camel.component.file.GenericFileComponent.createEndpoint(GenericFileComponent.java:65) 

       at org.apache.camel.component.file.GenericFileComponent.createEndpoint(GenericFileComponent.java:36) 

       at org.apache.camel.impl.DefaultComponent.createEndpoint(DefaultComponent.java:75) 

       at org.apache.camel.impl.DefaultCamelContext.getEndpoint(DefaultCamelContext.java:432) 

       ... 28 more 

回答

2

你要查询参数与&amp;分开。您的filtermove之间的参数是分号代替。

+0

谢谢,就是这样! – user5157427