Return-Path: Delivered-To: apmail-activemq-camel-commits-archive@locus.apache.org Received: (qmail 3659 invoked from network); 2 Jan 2009 16:20:45 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 2 Jan 2009 16:20:45 -0000 Received: (qmail 18524 invoked by uid 500); 2 Jan 2009 16:20:45 -0000 Delivered-To: apmail-activemq-camel-commits-archive@activemq.apache.org Received: (qmail 18508 invoked by uid 500); 2 Jan 2009 16:20:45 -0000 Mailing-List: contact camel-commits-help@activemq.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: camel-dev@activemq.apache.org Delivered-To: mailing list camel-commits@activemq.apache.org Received: (qmail 18498 invoked by uid 99); 2 Jan 2009 16:20:45 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 02 Jan 2009 08:20:45 -0800 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 02 Jan 2009 16:20:43 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 7C2EB23889C0; Fri, 2 Jan 2009 08:20:22 -0800 (PST) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r730768 - in /activemq/camel/trunk: components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/AntPathMatcherRemoteFileFilter.java tests/camel-itest/pom.xml Date: Fri, 02 Jan 2009 16:20:22 -0000 To: camel-commits@activemq.apache.org From: davsclaus@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20090102162022.7C2EB23889C0@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: davsclaus Date: Fri Jan 2 08:20:22 2009 New Revision: 730768 URL: http://svn.apache.org/viewvc?rev=730768&view=rev Log: CAMEL-1198: added init() to avoid load and lookup methods more than once Modified: activemq/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/AntPathMatcherRemoteFileFilter.java activemq/camel/trunk/tests/camel-itest/pom.xml Modified: activemq/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/AntPathMatcherRemoteFileFilter.java URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/AntPathMatcherRemoteFileFilter.java?rev=730768&r1=730767&r2=730768&view=diff ============================================================================== --- activemq/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/AntPathMatcherRemoteFileFilter.java (original) +++ activemq/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/AntPathMatcherRemoteFileFilter.java Fri Jan 2 08:20:22 2009 @@ -16,6 +16,8 @@ */ package org.apache.camel.component.file.remote; +import java.lang.reflect.Method; + import org.apache.camel.util.ObjectHelper; import static org.apache.camel.util.CollectionHelper.collectionAsCommaDelimitedString; @@ -29,24 +31,28 @@ private String[] excludes; private String[] includes; - public boolean accept(RemoteFile file) { - // we must use reflection to invoke the AntPathMatcherFileFilter that reside in camel-spring.jar - // and we don't want camel-ftp to have runtime dependency on camel-spring.jar - Class clazz = ObjectHelper.loadClass(ANTPATHMATCHER_CLASSNAME); - ObjectHelper.notNull(clazz, ANTPATHMATCHER_CLASSNAME + " not found in classpath. camel-spring.jar is required in the classpath."); + private Object filter; + private Method includesMethod; + private Method excludesMethod; + private Method acceptsMethod; + public boolean accept(RemoteFile file) { try { - Object filter = ObjectHelper.newInstance(clazz); + synchronized (this) { + if (filter == null) { + init(); + } + } // invoke setIncludes(String), must using string type as invoking with string[] does not work - ObjectHelper.invokeMethod(filter.getClass().getMethod("setIncludes", String.class), filter, collectionAsCommaDelimitedString(includes)); + ObjectHelper.invokeMethod(includesMethod, filter, collectionAsCommaDelimitedString(includes)); // invoke setExcludes(String), must using string type as invoking with string[] does not work - ObjectHelper.invokeMethod(filter.getClass().getMethod("setExcludes", String.class), filter, collectionAsCommaDelimitedString(excludes)); + ObjectHelper.invokeMethod(excludesMethod, filter, collectionAsCommaDelimitedString(excludes)); // invoke acceptPathName(String) String path = file.getRelativeFileName(); - Boolean result = (Boolean) ObjectHelper.invokeMethod(filter.getClass().getMethod("acceptPathName", String.class), filter, path); + Boolean result = (Boolean) ObjectHelper.invokeMethod(acceptsMethod, filter, path); return result; } catch (NoSuchMethodException e) { @@ -54,6 +60,19 @@ } } + private void init() throws NoSuchMethodException { + // we must use reflection to invoke the AntPathMatcherFileFilter that reside in camel-spring.jar + // and we don't want camel-ftp to have runtime dependency on camel-spring.jar + Class clazz = ObjectHelper.loadClass(ANTPATHMATCHER_CLASSNAME); + ObjectHelper.notNull(clazz, ANTPATHMATCHER_CLASSNAME + " not found in classpath. camel-spring.jar is required in the classpath."); + + filter = ObjectHelper.newInstance(clazz); + + includesMethod = filter.getClass().getMethod("setIncludes", String.class); + excludesMethod = filter.getClass().getMethod("setExcludes", String.class); + acceptsMethod = filter.getClass().getMethod("acceptPathName", String.class); + } + public String[] getExcludes() { return excludes; } Modified: activemq/camel/trunk/tests/camel-itest/pom.xml URL: http://svn.apache.org/viewvc/activemq/camel/trunk/tests/camel-itest/pom.xml?rev=730768&r1=730767&r2=730768&view=diff ============================================================================== --- activemq/camel/trunk/tests/camel-itest/pom.xml (original) +++ activemq/camel/trunk/tests/camel-itest/pom.xml Fri Jan 2 08:20:22 2009 @@ -183,7 +183,19 @@ - + + + org.apache.maven.plugins + maven-clean-plugin + + + + ${basedir}/res + + + + +