[ 
https://issues.apache.org/jira/browse/CAMEL-4779?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13180854#comment-13180854
 ] 

Daniel Gredler commented on CAMEL-4779:
---------------------------------------

Here are the files that need to be moved:

components/camel-core-xml/src/main/java/org/apache/camel/core/xml/scan/AntPathMatcher.java
 -> camel-core/src/main/java/org/apache/camel/util/AntPathMatcher.java

(move only; this is the central underlying utility class)

components/camel-core-xml/src/main/java/org/apache/camel/core/xml/scan/PatternBasedPackageScanFilter.java
 -> 
components/camel-core-xml/src/main/java/org/apache/camel/core/xml/PatternBasedPackageScanFilter.java

(move only; I decided to move this one level up in the package structure just 
because the first move operation leaves us with a package with a single class, 
and it doesn't seem appropriate to leave it there alone)

components/camel-spring/src/main/java/org/apache/camel/spring/util/SpringAntPathMatcherFileFilter.java
 -> 
camel-core/src/main/java/org/apache/camel/component/file/AntPathMatcherFileFilter.java

(move and rename; also change imports to use our AntPathMatcher instead of 
Spring's AntPathMatcher and use standard Java String.replace() instead of 
Spring's StringUtils.replace()):

+import org.apache.camel.util.AntPathMatcher;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import org.springframework.util.AntPathMatcher;
-import org.springframework.util.StringUtils;

...

-        path = StringUtils.replace(path, File.separator, "/");
+        path = path.replace(File.separatorChar, '/');

                
> Make Ant path matching in file / FTP component easier to use
> ------------------------------------------------------------
>
>                 Key: CAMEL-4779
>                 URL: https://issues.apache.org/jira/browse/CAMEL-4779
>             Project: Camel
>          Issue Type: Improvement
>          Components: camel-core, camel-spring
>    Affects Versions: 2.8.3
>            Reporter: Daniel Gredler
>            Priority: Minor
>             Fix For: 2.10
>
>         Attachments: ant-path-filter.patch
>
>
> The existing codebase has an implicit optional dependency from camel-core to 
> camel-spring; camel-core contains the class AntPathMatcherGenericFileFilter, 
> which internally uses camel-spring's SpringAntPathMatcherFileFilter class via 
> runtime classpath checks and reflection. The reason that 
> SpringAntPathMatcherFileFilter is in camel-spring is that it uses Spring's 
> AntPathMatcher class internally. Interestingly, there is already an 
> AntPathMatcher class with an API very similar to Spring's class in the 
> camel-core-xml module.
> This patch moves camel-core-xml's AntPathMatcher into camel-core, removes the 
> classpath and reflection magic in camel-core's 
> AntPathMatcherGenericFileFilter class, and adds a new class to camel-core 
> named GenericFileFilterConverter, which automagically converts strings to ant 
> path file filters. The patch also adds some unit tests.
> The end result is that Camel users can now use ant path matching with the 
> file and FTP components without having to add a dependency on camel-spring, 
> and Camel users can specify the ant path expression to use directly in the 
> component querystring, rather than having to go through the work of 
> registering an additional file filter instance in the registry (although this 
> is only true when the user only needs to specify a single include path, which 
> is a very common use case). For example:
> from("file://target/blah?recursive=true&filter=**/*.txt")
>   .to(...);
> Instead of:
> from("file://target/blah?recursive=true&filter=#myTxtFilter")
>   .to(...);

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: 
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to