class WatchServiceTask extends Runnable
WatchService class that implements a Run method for passing into a thread
Largely inspired by http://www.javacodegeeks.com/2013/04/watchservice-combined-with-akka-actors.html Takes care of registering paths to be monitored as well as logic that takes care of properly shutting down and monitoring the watcher thread
- Alphabetic
- By Inheritance
- WatchServiceTask
- Runnable
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Instance Constructors
- new WatchServiceTask(notifyActor: ActorRef)
Value Members
-
final
def
!=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
##(): Int
- Definition Classes
- AnyRef → Any
-
final
def
==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
def
clone(): AnyRef
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @native() @throws( ... )
-
def
contextAbsolutePath(key: WatchKey, contextPath: Path): Path
Returns the absolute path for a given event.context().asInstancOf[Path] path taken from a WatchService event
Returns the absolute path for a given event.context().asInstancOf[Path] path taken from a WatchService event
This is actually taken from http://www.javacodegeeks.com/2013/04/watchservice-combined-with-akka-actors.html The way it works is a context is taken from the events originating from a WatchKey, which itself is registered to an actual watchable object. In this case, the watchable object is a Path. By using the watchable object as a path and calling resolve, passing in the relative path obtained from the context, we obtain the "full" relative-to-watchable path. Afterwards, toAbsolutePath is called to get the real absolute path.
- key
WatchKey
- contextPath
Path relative to the key's watchable
- returns
Path
-
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
equals(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
finalize(): Unit
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( classOf[java.lang.Throwable] )
-
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
def
hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
-
final
def
ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
final
def
notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
def
run(): Unit
Not meant to be called directly
Not meant to be called directly
As an object that extends the Runnable interface, this method is required so that it can be passed into a Thread object and be run when #start is called on the thread object
- Definition Classes
- WatchServiceTask → Runnable
-
def
stopService(): Unit
Stops the WatchService current
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
-
def
toString(): String
- Definition Classes
- AnyRef → Any
-
final
def
wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @throws( ... )
-
def
watch(path: Path, modifier: Option[Modifier], eventTypes: Kind[_]*): Option[WatchKey]
Adds the path to the WatchService of this WatchServiceTask
Adds the path to the WatchService of this WatchServiceTask
This allows the thread running the run() method to do take() on the watchService to get a key for polling for events on registered paths
- path
Path (Java7) path
- modifier
Option[Modifier], the modifiers, if any, that modify how the object is registered
- eventTypes
one or more WatchEvent.Kind[_], each being one of ENTRY_CREATE, ENTRY_MODIFY, ENTRY_DELETE
- returns
Option[WatchKey] a Java7 WatchService WatchKey