You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@servicemix.apache.org by bradtwurst <na...@xoxy.net> on 2007/03/13 03:32:41 UTC

possible issue with file poller and recursive filters

Hello all,

I encountered something tonight that seems to be an issue.

I have a file poller configured as



> 	<file:poller service="km:poller" endpoint="poller" recursive="true"
> 		file="file:/BASEDIR" targetService="km:target"
> 		targetEndpoint="target" period="1000">
> 		<property name="filter">
> 			<bean class="org.apache.oro.io.GlobFilenameFilter">
> 				<constructor-arg value="data.log" />
> 			</bean>
> 		</property>
> 		<property name="marshaler">
> 			<bean
> 				class="org.apache.servicemix.components.util.BinaryFileMarshaler">
> 				<property name="fileName">
> 					<bean
> 						class="org.apache.servicemix.expression.PropertyExpression">
> 						<constructor-arg value="filename" />
> 					</bean>
> 				</property>
> 			</bean>
> 		</property>
> 	</file:poller>
> 

and I expect to have data.log files in various subdirectories.  

Running the service did not find any of the log files in the subdirectories.

As I stepped through the code, this appeared to be due to the
listFiles(filter) method call in the pollFileOrDirectory(File
fileOrDirectory, boolean processDir) not matching correctly on any files in
the subdirectories.

Can anyone confirm this?

Playing around with the file poller code, I was able to get recursive
filtering to work by replacing all the file polling recursive methods in the
class with the following (taking advantage of the apache commons-io package)



>     protected void pollFileOrDirectory(File fileOrDirectory) {
>         Collection files = FileUtils.listFiles(fileOrDirectory,
> FileFilterUtils
>                 .asFileFilter(getFilter()), TrueFileFilter.INSTANCE);
> 
>         for (Iterator iter = files.iterator(); iter.hasNext();) {
>             File file = (File) iter.next();
>             
>             pollFile(file); // process the file
>         }
>     }
> 
> 

Thanks,
James

-- 
View this message in context: http://www.nabble.com/possible-issue-with-file-poller-and-recursive-filters-tf3393561s12049.html#a9447423
Sent from the ServiceMix - Dev mailing list archive at Nabble.com.


Re: possible issue with file poller and recursive filters

Posted by Guillaume Nodet <gn...@gmail.com>.
Hum, i guess you're right.
What about raising a JIRA and attach your patch as a svn diff ?
But I guess in its current form, the patch does not honor the
recursive property on the endpoint ...

On 3/13/07, bradtwurst <na...@xoxy.net> wrote:
>
>
> Hello all,
>
> I encountered something tonight that seems to be an issue.
>
> I have a file poller configured as
>
>
>
> >       <file:poller service="km:poller" endpoint="poller"
> recursive="true"
> >               file="file:/BASEDIR" targetService="km:target"
> >               targetEndpoint="target" period="1000">
> >               <property name="filter">
> >                       <bean class="org.apache.oro.io.GlobFilenameFilter
> ">
> >                               <constructor-arg value="data.log" />
> >                       </bean>
> >               </property>
> >               <property name="marshaler">
> >                       <bean
> >                               class="
> org.apache.servicemix.components.util.BinaryFileMarshaler">
> >                               <property name="fileName">
> >                                       <bean
> >                                               class="
> org.apache.servicemix.expression.PropertyExpression">
> >                                               <constructor-arg
> value="filename" />
> >                                       </bean>
> >                               </property>
> >                       </bean>
> >               </property>
> >       </file:poller>
> >
>
> and I expect to have data.log files in various subdirectories.
>
> Running the service did not find any of the log files in the
> subdirectories.
>
> As I stepped through the code, this appeared to be due to the
> listFiles(filter) method call in the pollFileOrDirectory(File
> fileOrDirectory, boolean processDir) not matching correctly on any files
> in
> the subdirectories.
>
> Can anyone confirm this?
>
> Playing around with the file poller code, I was able to get recursive
> filtering to work by replacing all the file polling recursive methods in
> the
> class with the following (taking advantage of the apache commons-io
> package)
>
>
>
> >     protected void pollFileOrDirectory(File fileOrDirectory) {
> >         Collection files = FileUtils.listFiles(fileOrDirectory,
> > FileFilterUtils
> >                 .asFileFilter(getFilter()), TrueFileFilter.INSTANCE);
> >
> >         for (Iterator iter = files.iterator(); iter.hasNext();) {
> >             File file = (File) iter.next();
> >
> >             pollFile(file); // process the file
> >         }
> >     }
> >
> >
>
> Thanks,
> James
>
> --
> View this message in context:
> http://www.nabble.com/possible-issue-with-file-poller-and-recursive-filters-tf3393561s12049.html#a9447423
> Sent from the ServiceMix - Dev mailing list archive at Nabble.com.
>
>


-- 
Cheers,
Guillaume Nodet
------------------------
Architect, LogicBlaze (http://www.logicblaze.com/)
Blog: http://gnodet.blogspot.com/