Top Description Inners Fields Constructors Methods
org.xnio

pack-priv Class PollingFileSystemWatcher

extends Object
implements FileSystemWatcher, Runnable
Class Inheritance
All Implemented Interfaces
java.lang.Runnable, org.xnio.FileSystemWatcher, java.io.Closeable, java.lang.AutoCloseable
Imports
java.io.File, .IOException, java.util.ArrayDeque, .ArrayList, .Collections, .Deque, .HashMap, .List, .Map, java.util.concurrent.atomic.AtomicInteger, org.xnio._private.Messages

Polling based file system watcher service, for use on JDK6
Author
Stuart Douglas

Nested and Inner Type Summary

Modifier and TypeClass and Description
private class

Field Summary

Modifier and TypeField and Description
private final Map<File, PollingFileSystemWatcher.PollHolder>
private final int
private volatile boolean
public static final String
private static final AtomicInteger
private final Thread

Constructor Summary

AccessConstructor and Description
pack-priv
PollingFileSystemWatcher(final String name, int pollInterval, final boolean daemon)

Method Summary

Modifier and TypeMethod and Description
public void
close()

Implements java.io.Closeable.close.

Closes this stream and releases any system resources associated with it.

private List<FileChangeEvent>
doDiff(Map<File, Long> newFileState, Map<File, Long> currentFileState)

private void
pack-priv static Map<File, Long>
doScan(File file)

pack-priv static void
public void
run()

Implements java.lang.Runnable.run.

Runs this operation.

public synchronized void
unwatchPath(File
the path
file
,
final FileChangeCallback
the callback
callback
)

Implements org.xnio.FileSystemWatcher.unwatchPath.

Stop watching a path.

public synchronized void
watchPath(File
The path to watch
file
,
FileChangeCallback
The callback
callback
)

Implements org.xnio.FileSystemWatcher.watchPath.

Watch the given path recursively, and invoke the callback when a change is made.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

filesback to summary
private final Map<File, PollingFileSystemWatcher.PollHolder> files
pollIntervalback to summary
private final int pollInterval
stoppedback to summary
private volatile boolean stopped
THREAD_NAMEback to summary
public static final String THREAD_NAME
threadIdCounterback to summary
private static final AtomicInteger threadIdCounter
watchThreadback to summary
private final Thread watchThread

Constructor Detail

PollingFileSystemWatcherback to summary
pack-priv PollingFileSystemWatcher(final String name, int pollInterval, final boolean daemon)

Method Detail

closeback to summary
public void close() throws IOException

Implements java.io.Closeable.close.

Doc from java.io.Closeable.close.

Closes this stream and releases any system resources associated with it. If the stream is already closed then invoking this method has no effect.

As noted in AutoCloseable#close(), cases where the close may fail require careful attention. It is strongly advised to relinquish the underlying resources and to internally mark the Closeable as closed, prior to throwing the IOException.

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs
doDiffback to summary
private List<FileChangeEvent> doDiff(Map<File, Long> newFileState, Map<File, Long> currentFileState)
doNotifyback to summary
private void doNotify()
doScanback to summary
pack-priv static Map<File, Long> doScan(File file)
invokeCallbackback to summary
pack-priv static void invokeCallback(FileChangeCallback callback, List<FileChangeEvent> results)
runback to summary
public void run()

Implements java.lang.Runnable.run.

Doc from java.lang.Runnable.run.

Runs this operation.

Annotations
@Override
unwatchPathback to summary
public synchronized void unwatchPath(File file, final FileChangeCallback callback)

Implements org.xnio.FileSystemWatcher.unwatchPath.

Doc from org.xnio.FileSystemWatcher.unwatchPath.

Stop watching a path.

Parameters
file:File

the path

callback:FileChangeCallback

the callback

Annotations
@Override
watchPathback to summary
public synchronized void watchPath(File file, FileChangeCallback callback)

Implements org.xnio.FileSystemWatcher.watchPath.

Doc from org.xnio.FileSystemWatcher.watchPath.

Watch the given path recursively, and invoke the callback when a change is made.

Parameters
file:File

The path to watch

callback:FileChangeCallback

The callback

Annotations
@Override
org.xnio back to summary

private Class PollingFileSystemWatcher.PollHolder

extends Object
Class Inheritance

Field Summary

Modifier and TypeField and Description
pack-priv final List<FileChangeCallback>
pack-priv Map<File, Long>

Constructor Summary

AccessConstructor and Description
private
PollHolder(Map<File, Long> currentFileState)

Method Summary

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

callbacksback to summary
pack-priv final List<FileChangeCallback> callbacks
currentFileStateback to summary
pack-priv Map<File, Long> currentFileState

Constructor Detail

PollHolderback to summary
private PollHolder(Map<File, Long> currentFileState)