You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicemix.apache.org by js...@apache.org on 2007/11/27 11:25:24 UTC
svn commit: r598584 -
/servicemix/branches/servicemix-4.0/runtime/filemonitor/src/main/java/org/apache/servicemix/runtime/filemonitor/FileMonitor.java
Author: jstrachan
Date: Tue Nov 27 02:25:23 2007
New Revision: 598584
URL: http://svn.apache.org/viewvc?rev=598584&view=rev
Log:
added some link love to Peter Kriens who's FileInstall was an inspiration for the filemonitor idea
Modified:
servicemix/branches/servicemix-4.0/runtime/filemonitor/src/main/java/org/apache/servicemix/runtime/filemonitor/FileMonitor.java
Modified: servicemix/branches/servicemix-4.0/runtime/filemonitor/src/main/java/org/apache/servicemix/runtime/filemonitor/FileMonitor.java
URL: http://svn.apache.org/viewvc/servicemix/branches/servicemix-4.0/runtime/filemonitor/src/main/java/org/apache/servicemix/runtime/filemonitor/FileMonitor.java?rev=598584&r1=598583&r2=598584&view=diff
==============================================================================
--- servicemix/branches/servicemix-4.0/runtime/filemonitor/src/main/java/org/apache/servicemix/runtime/filemonitor/FileMonitor.java (original)
+++ servicemix/branches/servicemix-4.0/runtime/filemonitor/src/main/java/org/apache/servicemix/runtime/filemonitor/FileMonitor.java Tue Nov 27 02:25:23 2007
@@ -201,6 +201,15 @@
deleteConfiguration(file);
}
}
+ else if (name.equals("MANIFEST.MF")) {
+ File parentFile = file.getParentFile();
+ if (parentFile.getName().equals("META-INF")) {
+ File bundleDir = parentFile.getParentFile();
+ if (isValidBundleSourceDirectory(bundleDir)) {
+ undeployBundle(bundleDir);
+ }
+ }
+ }
}
catch (Exception e) {
warn("Failed to process: " + file + ". Reason: " + e);
@@ -238,7 +247,9 @@
protected void undeployBundle(File file) throws BundleException {
changedBundles = true;
+ log("Uneloying: " + file.getAbsolutePath());
Bundle bundle = getBundleForJarFile(file);
+
if (bundle == null) {
warn("Could not find Bundle for file: " + file.getAbsolutePath());
}
@@ -383,8 +394,8 @@
*/
protected File getExpandedBundleRootDirectory(File file) throws IOException {
File parent = file.getParentFile();
- String rootPath = deployDir.getCanonicalPath();
if (file.isDirectory()) {
+ String rootPath = deployDir.getCanonicalPath();
if (file.getCanonicalPath().equals(rootPath)) {
return null;
}
@@ -392,11 +403,24 @@
return file;
}
}
- String parentPath = parent.getCanonicalPath();
- if (parent != null && !parentPath.equals(rootPath) && parentPath.startsWith(rootPath)) {
+ if (isValidBundleSourceDirectory(parent)) {
return getExpandedBundleRootDirectory(parent);
}
return null;
+ }
+
+ /**
+ * Returns true if the given directory is a valid child directory within the {@link #deployDir}
+ */
+ protected boolean isValidBundleSourceDirectory(File dir) throws IOException {
+ if (dir != null) {
+ String parentPath = dir.getCanonicalPath();
+ String rootPath = deployDir.getCanonicalPath();
+ return !parentPath.equals(rootPath) && parentPath.startsWith(rootPath);
+ }
+ else {
+ return false;
+ }
}
/**