Package org.hotswap.agent.watch.nio
Class AbstractNIO2Watcher
- java.lang.Object
-
- org.hotswap.agent.watch.nio.AbstractNIO2Watcher
-
- All Implemented Interfaces:
Watcher
- Direct Known Subclasses:
TreeWatcherNIO,WatcherNIO2
public abstract class AbstractNIO2Watcher extends Object implements Watcher
NIO2 watcher implementation for systems which support ExtendedWatchEventModifier.FILE_TREE Java 7 (NIO2) watch a directory (or tree) for changes to files. By http://docs.oracle.com/javase/tutorial/essential/io/examples/WatchDir.java- Author:
- Jiri Bubnik, alpapad@gmail.com
-
-
Field Summary
Fields Modifier and Type Field Description protected Map<WatchEventListener,ClassLoader>classLoaderListenersprotected EventDispatcherdispatcherprotected Map<WatchKey,Path>keysprotected static WatchEvent.Kind<?>[]KINDSprotected AgentLoggerLOGGERprotected WatchServicewatcher
-
Constructor Summary
Constructors Constructor Description AbstractNIO2Watcher()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidaddDirectory(Path path)Registers the given directoryvoidaddEventListener(ClassLoader classLoader, URI pathPrefix, WatchEventListener listener)Register listeners on an event.voidaddEventListener(ClassLoader classLoader, URL pathPrefix, WatchEventListener listener)Register listeners on an event.voidcloseClassLoader(ClassLoader classLoader)Remove all transformers registered with a classloaderprotected abstract voidregisterAll(Path dir)voidrun()Run the watcher agent thread.voidstop()Stop the watcher agent thread.
-
-
-
Field Detail
-
LOGGER
protected AgentLogger LOGGER
-
KINDS
protected static final WatchEvent.Kind<?>[] KINDS
-
watcher
protected WatchService watcher
-
classLoaderListeners
protected Map<WatchEventListener,ClassLoader> classLoaderListeners
-
dispatcher
protected final EventDispatcher dispatcher
-
-
Constructor Detail
-
AbstractNIO2Watcher
public AbstractNIO2Watcher() throws IOException- Throws:
IOException
-
-
Method Detail
-
addEventListener
public void addEventListener(ClassLoader classLoader, URI pathPrefix, WatchEventListener listener)
Description copied from interface:WatcherRegister listeners on an event.- Specified by:
addEventListenerin interfaceWatcher- Parameters:
classLoader- the classloader to which this path is associated. May be null, but then this listener will never be disassociated (even if application is undeployed)pathPrefix- where to listenlistener- the listener
-
addEventListener
public void addEventListener(ClassLoader classLoader, URL pathPrefix, WatchEventListener listener)
Description copied from interface:WatcherRegister listeners on an event.- Specified by:
addEventListenerin interfaceWatcher- Parameters:
classLoader- the classloader to which this path is associated. May be null, but then this listener will never be disassociated (even if application is undeployed)pathPrefix- where to listenlistener- the listener
-
closeClassLoader
public void closeClassLoader(ClassLoader classLoader)
Remove all transformers registered with a classloader- Specified by:
closeClassLoaderin interfaceWatcher- Parameters:
classLoader-
-
addDirectory
public void addDirectory(Path path) throws IOException
Registers the given directory- Throws:
IOException
-
registerAll
protected abstract void registerAll(Path dir) throws IOException
- Throws:
IOException
-
run
public void run()
Description copied from interface:WatcherRun the watcher agent thread.
-
-