Package org.jgrapes.util
Class FileSystemWatcher
java.lang.Object
org.jgrapes.core.internal.ComponentVertex
org.jgrapes.core.Component
org.jgrapes.util.FileSystemWatcher
- All Implemented Interfaces:
Iterable<ComponentType>,Channel,ComponentType,Eligible,Manager
A component that watches paths in the file system for changes
and sends events if such changes occur.
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.jgrapes.core.Channel
Channel.Default -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new component base with its channel set to itself.FileSystemWatcher(Channel componentChannel) Creates a new component base with its channel set to the given channel. -
Method Summary
Modifier and TypeMethodDescriptionvoidonWatchFile(WatchFile event, Channel channel) Register a path to wath.Methods inherited from class org.jgrapes.core.Component
channel, component, defaultCriterion, isEligibleFor, setNameMethods inherited from class org.jgrapes.core.internal.ComponentVertex
activeEventPipeline, addHandler, attach, channelReplacements, children, componentPath, componentVertex, detach, fire, initComponentsHandlers, iterator, name, newEventPipeline, newEventPipeline, parent, registerAsGenerator, root, toString, unregisterAsGeneratorMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Field Details
-
logger
-
-
Constructor Details
-
FileSystemWatcher
public FileSystemWatcher()Creates a new component base with its channel set to itself. -
FileSystemWatcher
Creates a new component base with its channel set to the given channel.As a special case
Channel.SELFcan be passed to the constructor to make the component use itself as channel. The special value is necessary as you obviously cannot pass an object to be constructed to its constructor.- Parameters:
componentChannel- the channel that the component’s handlers listen on by default and thatManager.fire(Event, Channel...)sends the event to
-
-
Method Details
-
onWatchFile
Register a path to wath.Subsequent
FileChangedevents will be fire on the channel(s) on which theWatchFileevent was fired.The channel is stored using a weak reference, so no explicit “clear watch” is required.
- Parameters:
event- the eventchannel- the channel- Throws:
IOException- if an I/O exception occurs
-