Return-Path: Delivered-To: apmail-camel-users-archive@www.apache.org Received: (qmail 99336 invoked from network); 27 Jan 2010 21:23:58 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 27 Jan 2010 21:23:58 -0000 Received: (qmail 1508 invoked by uid 500); 27 Jan 2010 21:23:58 -0000 Delivered-To: apmail-camel-users-archive@camel.apache.org Received: (qmail 1451 invoked by uid 500); 27 Jan 2010 21:23:58 -0000 Mailing-List: contact users-help@camel.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@camel.apache.org Delivered-To: mailing list users@camel.apache.org Received: (qmail 1441 invoked by uid 99); 27 Jan 2010 21:23:58 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 27 Jan 2010 21:23:58 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of claus.ibsen@gmail.com designates 209.85.218.217 as permitted sender) Received: from [209.85.218.217] (HELO mail-bw0-f217.google.com) (209.85.218.217) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 27 Jan 2010 21:23:48 +0000 Received: by bwz9 with SMTP id 9so103014bwz.30 for ; Wed, 27 Jan 2010 13:23:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :from:date:message-id:subject:to:content-type :content-transfer-encoding; bh=FnVB34VPSTWoq4RuhKxCga8l9cgUdj/MnJPlWX924GI=; b=aZXohQtN8aIEgsEmOkdeadSlnxx34wiJ7HhqS+kxDXaLMR6RJqrIbHiov53hWwuCQT pi8U4UvhMK9hJ532K2yAy47fIb6eKeYjabLHrpKH0rIELBZ1CkwGZBJXqOcOU8NVF+F2 E3GueqSIbx0soObHcUZLamAMjCO0q+6XmdIJc= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type:content-transfer-encoding; b=HgdqjtyrDgkHtEbjIRrDroENVS1kcKNhnL4dnbFtCBJiqjPP2bkRthc2vQB0zzb2Di XovBw+1gTuYmfyD+i3pUnFY5kbzD9NWJFVS2mradG+0OA4wmqaS0mdTxv20PZiS5aeHN swDxJK1TNvKNkYCAzpOqmIpjlqGi+sVWyu+Ns= MIME-Version: 1.0 Received: by 10.204.143.78 with SMTP id t14mr4025014bku.10.1264627405115; Wed, 27 Jan 2010 13:23:25 -0800 (PST) In-Reply-To: References: From: Claus Ibsen Date: Wed, 27 Jan 2010 22:23:05 +0100 Message-ID: <5380c69c1001271323o5b51e47bsfb7577f6fbda1f1@mail.gmail.com> Subject: Re: FileProcessStrategy To: users@camel.apache.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Hi You can take a look at GenericFileExclusiveReadLockStrategy which is more suitable for this kind as its the strategy how to acquire a lock on the file, which in your case is when the .DONE file has been written. Since you are doing FTP stuff the should be FTPFile which is the raw type used by the real FTP framework underneath. The FTPFile type has a method to get the file name which you can use to compare it with .DONE On Wed, Jan 27, 2010 at 3:52 PM, Kevin Jackson wrote: > Hi, > > I have a problem creating a custom File processing strategy for when > to download a file from an FTP server > > Essentially we have to poll for a .DONE file to exist before taking > the data file. > > public class MyFTPProcessStrategy extends > GenericFileProcessStrategySupport { > > =A0 =A0@Override > =A0 =A0public boolean begin(GenericFileOperations > tGenericFileOperations, GenericFileEndpoint tGenericFileEndpoint, > Exchange exchange, GenericFile tGenericFile) throws Exception { > =A0 =A0 =A0 =A0super.begin(tGenericFileOperations, tGenericFileEndpoint, > exchange, tGenericFile); > =A0 =A0 =A0 =A0List> files =3D > (List>)tGenericFileOperations.listFiles(); > =A0 =A0 =A0 =A0for(GenericFile f : files) { > =A0 =A0 =A0 =A0 =A0 =A0if(f.getFileName().endsWith(".DONE")) { > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0return true; > =A0 =A0 =A0 =A0 =A0 =A0} > =A0 =A0 =A0 =A0} > =A0 =A0 =A0 =A0return false; > =A0 =A0} > } > > I get a class cast exception when looping through the files on the server= : > java.lang.ClassCastException: org.apache.commons.net.ftp.FTPFile > cannot be cast to org.apache.camel.component.file.GenericFile > > When I have checked nabble, this seems to be the correct solution > (check for the existence of a .ready file). > > This is with camel-2.1 > > Is this a known bug, a stupid implementation decision from me, or > something else? > > Thanks, > Kev > --=20 Claus Ibsen Apache Camel Committer Author of Camel in Action: http://www.manning.com/ibsen/ Open Source Integration: http://fusesource.com Blog: http://davsclaus.blogspot.com/ Twitter: http://twitter.com/davsclaus