Hi

See this page
http://camel.apache.org/file2

The section about using GenericFileFilter

To register a custom file filter in the registry, then you can use the
SimpleRegistry with the CamelContext


Map simpleRegistry = new SimpleRegistry();
camel = new DefaultCamelContext(simpleRegistry);


Then you can just register your custom filter

simpleRegistry.put("myFilter", myFilerObject);




On Sun, Nov 6, 2011 at 11:12 AM, tkatva <tuomas.ka...@gmail.com> wrote:
> I have code where I dynamically try to add Endpoints and Endpoint Filters to
> CamelContext. But haven't been able to get FileFilter working on File- or
> FtpEndpoint's. For example I want to be able to filter only files with given
> parameters, for example I want to download files only with txt extension.
> Here's the code :
>
>  public void testCamel() {
>        camel = new DefaultCamelContext();
>        RouteDefinition routeDef = new RouteDefinition();
>
>
>
>        Endpoint from =
> camel.getEndpoint("file:C:\\FtpTestFolders\\FtpOut?delete=true");
>        //Endpoint from2 =
> camel.getEndpoint("quartz://myGroup/myTimerName?cron=0+0/5+*+*+*+?");
>        //routeDef.setHeader(Exchange.FILE_NAME, new
> SimpleExpression("${date:now:yyyyMMdd}.txt"));
>        routeDef.setHeader("testi", new ConstantExpression("TAMA ON
> TESTI"));
>        Endpoint to =
> camel.getEndpoint("file:C:\\FtpTestFolders\\FtpIn?fileName=filename1.txt");
>
>
>        routeDef.from(from).filter().simple("${file:ext} == 'txt'").to(to);
>
>
>
>
>        try {
>        camel.addRouteDefinition(routeDef);
>        camel.start();
>        } catch (Exception exp) {
>            System.out.println("EXCEPTION starting camel : " +
> exp.toString());
>        }
>        boolean wait = true;
>        while (wait) {
>
>        }
>    }
> }
>
> This works in a way that it routes those files that is defined in the filter
> but it removes all files from the source endpoint. I read about
> GenericFileFilter but how can I add it programmatically to camel context ? I
> would like to be able to define per route programmatically which filter
> parameter I would like to use.
>
> Thank you.
>
> Your help would be greatly appreciated.
>
> Best Regards Tuomas
>
> --
> View this message in context: 
> http://camel.465427.n5.nabble.com/Adding-File-name-filter-for-RouteEndpointDefinition-tp4968230p4968230.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>



-- 
Claus Ibsen
-----------------
FuseSource
Email: cib...@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/

Reply via email to