in filemonitor/src/main/java/org/apache/servicemix/kernel/filemonitor/FileMonitor.java [226:300]
protected synchronized void onFilesChanged(Collection<String> filenames) {
bundlesToStart.clear();
bundlesToUpdate.clear();
Set<File> bundleJarsCreated = new HashSet<File>();
for (String filename : filenames) {
File file = new File(filename);
try {
LOGGER.debug("File changed: " + filename);
// Handle config files
if (isValidConfigFile(file)) {
if (file.exists()) {
updateConfiguration(file);
} else {
deleteConfiguration(file);
}
continue;
}
// Handle exploded artifacts removal
if (!file.exists() && file.getName().equals("MANIFEST.MF")) {
File parentFile = file.getParentFile();
if (parentFile.getName().equals("META-INF")) {
File bundleDir = parentFile.getParentFile();
if (isValidBundleSourceDirectory(bundleDir)) {
undeployBundle(bundleDir);
continue;
}
}
}
// Handle exploded artifacts add
File jardir = getExpandedBundleRootDirectory(file);
if (jardir != null) {
if (bundleJarsCreated.contains(jardir)) {
continue;
}
bundleJarsCreated.add(jardir);
file = createBundleJar(jardir);
}
// Transformation step
if (file.exists()) {
File f = transformArtifact(file);
if (f == null) {
LOGGER.warn("Unsupported deployment: " + filename);
rescheduleTransformation(file);
continue;
}
file = f;
} else {
String transformedFile = artifactToBundle.get(filename);
if (transformedFile != null) {
file = new File(transformedFile);
if (file.exists()) {
file.delete();
}
}
}
// Handle final bundles
if (isValidArtifactFile(file)) {
if (file.exists()) {
deployBundle(file);
} else {
undeployBundle(file);
}
}
} catch (Exception e) {
LOGGER.warn("Failed to process: " + file + ". Reason: " + e, e);
}
}
refreshPackagesAndStartOrUpdateBundles();
}