diff --git a/springloaded/src/main/java/org/springsource/loaded/TypeRegistry.java b/springloaded/src/main/java/org/springsource/loaded/TypeRegistry.java index 98d62135..5f2d7f0a 100644 --- a/springloaded/src/main/java/org/springsource/loaded/TypeRegistry.java +++ b/springloaded/src/main/java/org/springsource/loaded/TypeRegistry.java @@ -1537,6 +1537,15 @@ public static boolean instanceFieldInterceptionRequired(int ids, String name) { return false; } + /** + * Shuts down FileSystemWatcher thread and waits until it is finished. + * @throws InterruptedException + */ + public void shutdownFileSystemWatcherThread() throws InterruptedException { + if(fsWatcher != null) + fsWatcher.shutdownAndWait(); + } + /** * Called for a field operation - trying to determine whether a particular field needs special handling. * diff --git a/springloaded/src/main/java/org/springsource/loaded/agent/FileSystemWatcher.java b/springloaded/src/main/java/org/springsource/loaded/agent/FileSystemWatcher.java index 33438b50..1895e948 100644 --- a/springloaded/src/main/java/org/springsource/loaded/agent/FileSystemWatcher.java +++ b/springloaded/src/main/java/org/springsource/loaded/agent/FileSystemWatcher.java @@ -71,6 +71,17 @@ public void shutdown() { watchThread.timeToStop(); } } + + /** + * Shutdown the thread and wait until it is finished. + * @throws java.lang.InterruptedException + */ + public void shutdownAndWait() throws InterruptedException { + if (threadRunning) { + watchThread.timeToStop(); + thread.join(); + } + } /** * Add a new file to the list of those being monitored. If the file is something that can be watched, then this method will