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
-
Constructor Summary
ConstructorDescriptionCreates 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 TypeMethodDescriptionvoid
onWatchFile
(WatchFile event, Channel channel) Register a path to wath.Methods inherited from class org.jgrapes.core.Component
channel, component, defaultCriterion, isEligibleFor, setName
Methods 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, unregisterAsGenerator
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods 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.SELF
can 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
FileChanged
events will be fire on the channel(s) on which theWatchFile
event 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
-