You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by gn...@apache.org on 2017/10/19 08:57:31 UTC
svn commit: r1812606 -
/felix/trunk/fileinstall/src/main/java/org/apache/felix/fileinstall/internal/DirectoryWatcher.java
Author: gnodet
Date: Thu Oct 19 08:57:31 2017
New Revision: 1812606
URL: http://svn.apache.org/viewvc?rev=1812606&view=rev
Log:
[FELIX-4661] FileInstall: Property "felix.fileinstall.filter" ignored when the service start
Modified:
felix/trunk/fileinstall/src/main/java/org/apache/felix/fileinstall/internal/DirectoryWatcher.java
Modified: felix/trunk/fileinstall/src/main/java/org/apache/felix/fileinstall/internal/DirectoryWatcher.java
URL: http://svn.apache.org/viewvc/felix/trunk/fileinstall/src/main/java/org/apache/felix/fileinstall/internal/DirectoryWatcher.java?rev=1812606&r1=1812605&r2=1812606&view=diff
==============================================================================
--- felix/trunk/fileinstall/src/main/java/org/apache/felix/fileinstall/internal/DirectoryWatcher.java (original)
+++ felix/trunk/fileinstall/src/main/java/org/apache/felix/fileinstall/internal/DirectoryWatcher.java Thu Oct 19 08:57:31 2017
@@ -42,6 +42,7 @@ import java.util.Set;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.jar.JarInputStream;
import java.util.jar.Manifest;
+import java.util.regex.Pattern;
import org.apache.felix.fileinstall.ArtifactInstaller;
import org.apache.felix.fileinstall.ArtifactListener;
@@ -810,6 +811,7 @@ public class DirectoryWatcher extends Th
Bundle[] bundles = this.context.getBundles();
String watchedDirPath = watchedDirectory.toURI().normalize().getPath();
Map<File, Long> checksums = new HashMap<File, Long>();
+ Pattern filePattern = filter == null || filter.isEmpty() ? null : Pattern.compile(filter);
for (Bundle bundle : bundles) {
// Convert to a URI because the location of a bundle
// is typically a URI. At least, that's the case for
@@ -855,13 +857,16 @@ public class DirectoryWatcher extends Th
}
final int index = path.lastIndexOf('/');
if (index != -1 && path.startsWith(watchedDirPath)) {
- Artifact artifact = new Artifact();
- artifact.setBundleId(bundle.getBundleId());
- artifact.setChecksum(Util.loadChecksum(bundle, context));
- artifact.setListener(null);
- artifact.setPath(new File(path));
- setArtifact(new File(path), artifact);
- checksums.put(new File(path), artifact.getChecksum());
+ final String fileName = path.substring(index + 1);
+ if (filePattern == null || filePattern.matcher(fileName).matches()) {
+ Artifact artifact = new Artifact();
+ artifact.setBundleId(bundle.getBundleId());
+ artifact.setChecksum(Util.loadChecksum(bundle, context));
+ artifact.setListener(null);
+ artifact.setPath(new File(path));
+ setArtifact(new File(path), artifact);
+ checksums.put(new File(path), artifact.getChecksum());
+ }
}
}
scanner.initialize(checksums);