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

pack-priv abstract Class AbstractWatchService

extends Object
implements WatchService
Class Inheritance
All Implemented Interfaces
java.nio.file.WatchService, java.io.Closeable, java.lang.AutoCloseable
Known Direct Subclasses
sun.nio.fs.PollingWatchService, sun.nio.fs.LinuxWatchService
Imports
java.nio.file.*, java.util.concurrent.*, java.io.IOException

Base implementation class for watch services.

Field Summary

Modifier and TypeField and Description
private final WatchKey
private volatile boolean
private final Object
private final LinkedBlockingDeque<WatchKey>

Constructor Summary

AccessConstructor and Description
protected

Method Summary

Modifier and TypeMethod and Description
private void
checkKey(WatchKey key)

Checks the key isn't the special CLOSE_KEY used to unblock threads when the watch service is closed.

private void
checkOpen()

Throws ClosedWatchServiceException if watch service is closed

public final void
close()

Implements java.nio.file.WatchService.close.

Closes this watch service.

pack-priv final Object
closeLock()

Retrieves the object upon which the close method synchronizes.

pack-priv final void
pack-priv abstract void
implClose()

Closes this watch service.

pack-priv final boolean
isOpen()

Tells whether or not this watch service is open.

public final WatchKey
poll()

Implements java.nio.file.WatchService.poll.

Retrieves and removes the next watch key, or null if none are present.

public final WatchKey
poll(long timeout, TimeUnit unit)

Implements java.nio.file.WatchService.poll.

Retrieves and removes the next watch key, waiting if necessary up to the specified wait time if none are yet present.

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

Register the given object with this watch service

public final WatchKey
take()

Implements java.nio.file.WatchService.take.

Retrieves and removes next watch key, waiting if none are yet present.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

CLOSE_KEYback to summary
private final WatchKey CLOSE_KEY
closedback to summary
private volatile boolean closed
closeLockback to summary
private final Object closeLock
pendingKeysback to summary
private final LinkedBlockingDeque<WatchKey> pendingKeys

Constructor Detail

AbstractWatchServiceback to summary
protected AbstractWatchService()

Method Detail

checkKeyback to summary
private void checkKey(WatchKey key)

Checks the key isn't the special CLOSE_KEY used to unblock threads when the watch service is closed.

checkOpenback to summary
private void checkOpen()

Throws ClosedWatchServiceException if watch service is closed

closeback to summary
public final void close() throws IOException

Implements java.nio.file.WatchService.close.

Doc from java.nio.file.WatchService.close.

Closes this watch service.

If a thread is currently blocked in the take or poll methods waiting for a key to be queued then it immediately receives a ClosedWatchServiceException. Any valid keys associated with this watch service are invalidated.

After a watch service is closed, any further attempt to invoke operations upon it will throw ClosedWatchServiceException. If this watch service is already closed then invoking this method has no effect.

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs
closeLockback to summary
pack-priv final Object closeLock()

Retrieves the object upon which the close method synchronizes.

enqueueKeyback to summary
pack-priv final void enqueueKey(WatchKey key)
implCloseback to summary
pack-priv abstract void implClose() throws IOException

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

isOpenback to summary
pack-priv final boolean isOpen()

Tells whether or not this watch service is open.

pollback to summary
public final WatchKey poll()

Implements java.nio.file.WatchService.poll.

Doc from java.nio.file.WatchService.poll.

Retrieves and removes the next watch key, or null if none are present.

Annotations
@Override
pollback to summary
public final WatchKey poll(long timeout, TimeUnit unit) throws InterruptedException

Implements java.nio.file.WatchService.poll.

Doc from java.nio.file.WatchService.poll.

Retrieves and removes the next watch key, waiting if necessary up to the specified wait time if none are yet present.

Annotations
@Override
Exceptions
InterruptedException:
if interrupted while waiting
registerback to summary
pack-priv abstract WatchKey register(Path path, WatchEvent.Kind<?>[] events, WatchEvent.Modifier... modifiers) throws IOException

Register the given object with this watch service

takeback to summary
public final WatchKey take() throws InterruptedException

Implements java.nio.file.WatchService.take.

Doc from java.nio.file.WatchService.take.

Retrieves and removes next watch key, waiting if none are yet present.

Annotations
@Override
Exceptions
InterruptedException:
if interrupted while waiting