APIdia Launch Partner
Top Description Inners Fields Constructors Methods
sun.nio.fs

pack-priv Class PollingWatchService

extends AbstractWatchService
Class Inheritance
Imports
java.nio.file.ClosedWatchServiceException, .DirectoryIteratorException, .DirectoryStream, .Files, .NotDirectoryException, .Path, .StandardWatchEventKinds, .WatchEvent, .WatchKey, java.nio.file.attribute.BasicFileAttributes, .FileTime, java.io.IOException, java.util.HashMap, .HashSet, .Iterator, .Map, .Set, java.util.concurrent.Executors, .ScheduledExecutorService, .ScheduledFuture, .ThreadFactory, .TimeUnit, jdk.internal.misc.InnocuousThread

Simple WatchService implementation that uses periodic tasks to poll registered directories for changes. This implementation is for use on operating systems that do not have native file change notification support.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
PollingWatchService.CacheEntry

Entry in directory cache to record file last-modified-time and tick-count

private class
PollingWatchService.PollingWatchKey

WatchKey implementation that encapsulates a map of the entries of the entries in the directory.

Field Summary

Modifier and TypeField and Description
private final Map<Object, PollingWatchService.PollingWatchKey>
private static final int
private final ScheduledExecutorService

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
pack-priv void
implClose()

Implements abstract sun.nio.fs.AbstractWatchService.implClose.

Closes this watch service.

pack-priv WatchKey
register(final Path path, WatchEvent.Kind<?>[] events, WatchEvent.Modifier... modifiers)

Implements abstract sun.nio.fs.AbstractWatchService.register.

Register the given file with this watch service

Inherited from sun.nio.fs.AbstractWatchService:
closecloseLockenqueueKeyisOpenpollpolltake

Field Detail

mapback to summary
private final Map<Object, PollingWatchService.PollingWatchKey> map
POLLING_INTERVALback to summary
private static final int POLLING_INTERVAL
scheduledExecutorback to summary
private final ScheduledExecutorService scheduledExecutor

Constructor Detail

PollingWatchServiceback to summary
pack-priv PollingWatchService()

Method Detail

implCloseback to summary
pack-priv void implClose() throws IOException

Implements abstract sun.nio.fs.AbstractWatchService.implClose.

Doc from sun.nio.fs.AbstractWatchService.implClose.

Closes this watch service. This method is invoked by the close method to perform the actual work of closing the watch service.

Annotations
@Override
registerback to summary
pack-priv WatchKey register(final Path path, WatchEvent.Kind<?>[] events, WatchEvent.Modifier... modifiers) throws IOException

Implements abstract sun.nio.fs.AbstractWatchService.register.

Register the given file with this watch service

Annotations
@Override
sun.nio.fs back to summary

private Class PollingWatchService.CacheEntry

extends Object
Class Inheritance

Entry in directory cache to record file last-modified-time and tick-count

Field Summary

Modifier and TypeField and Description
private FileTime
private int

Constructor Summary

AccessConstructor and Description
pack-priv
CacheEntry(FileTime lastModified, int lastTickCount)

Method Summary

Modifier and TypeMethod and Description
pack-priv FileTime
pack-priv int
pack-priv void
update(FileTime lastModified, int tickCount)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

lastModifiedback to summary
private FileTime lastModified
lastTickCountback to summary
private int lastTickCount

Constructor Detail

CacheEntryback to summary
pack-priv CacheEntry(FileTime lastModified, int lastTickCount)

Method Detail

lastModifiedback to summary
pack-priv FileTime lastModified()
lastTickCountback to summary
pack-priv int lastTickCount()
updateback to summary
pack-priv void update(FileTime lastModified, int tickCount)
sun.nio.fs back to summary

private Class PollingWatchService.PollingWatchKey

extends AbstractWatchKey
Class Inheritance

WatchKey implementation that encapsulates a map of the entries of the entries in the directory. Polling the key causes it to re-scan the directory and queue keys when entries are added, modified, or deleted.

Field Summary

Modifier and TypeField and Description
private Map<Path, PollingWatchService.CacheEntry>
private Set<? extends WatchEvent.Kind<?>>
private final Object
private ScheduledFuture<?>
private int
private volatile boolean
Inherited from sun.nio.fs.AbstractWatchKey:
MAX_EVENT_LIST_SIZEOVERFLOW_EVENT

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public void
cancel()

Implements java.nio.file.WatchKey.cancel.

Cancels the registration with the watch service.

pack-priv void
pack-priv void
enable(Set<? extends WatchEvent.Kind<?>> events)

pack-priv Object
pack-priv void
public boolean
isValid()

Implements java.nio.file.WatchKey.isValid.

Tells whether or not this watch key is valid.

pack-priv synchronized void
poll()

Polls the directory to detect for new files, modified files, or deleted files.

Inherited from sun.nio.fs.AbstractWatchKey:
pollEventsresetsignalsignalEventwatchablewatcher

Field Detail

entriesback to summary
private Map<Path, PollingWatchService.CacheEntry> entries
eventsback to summary
private Set<? extends WatchEvent.Kind<?>> events

Hides sun.nio.fs.AbstractWatchKey.events.

fileKeyback to summary
private final Object fileKey
pollerback to summary
private ScheduledFuture<?> poller
tickCountback to summary
private int tickCount
validback to summary
private volatile boolean valid

Constructor Detail

PollingWatchKeyback to summary
pack-priv PollingWatchKey(Path dir, PollingWatchService watcher, Object fileKey) throws IOException

Method Detail

cancelback to summary
public void cancel()

Implements java.nio.file.WatchKey.cancel.

Doc from java.nio.file.WatchKey.cancel.

Cancels the registration with the watch service. Upon return the watch key will be invalid. If the watch key is enqueued, waiting to be retrieved from the watch service, then it will remain in the queue until it is removed. Pending events, if any, remain pending and may be retrieved by invoking the pollEvents method after the key is cancelled.

If this watch key has already been cancelled then invoking this method has no effect. Once cancelled, a watch key remains forever invalid.

Annotations
@Override
disableback to summary
pack-priv void disable()
enableback to summary
pack-priv void enable(Set<? extends WatchEvent.Kind<?>> events)
fileKeyback to summary
pack-priv Object fileKey()
invalidateback to summary
pack-priv void invalidate()
isValidback to summary
public boolean isValid()

Implements java.nio.file.WatchKey.isValid.

Doc from java.nio.file.WatchKey.isValid.

Tells whether or not this watch key is valid.

A watch key is valid upon creation and remains until it is cancelled, or its watch service is closed.

Annotations
@Override
pollback to summary
pack-priv synchronized void poll()

Polls the directory to detect for new files, modified files, or deleted files.