Package org.apache.wicket.util.watch
Class ModificationWatcher
- java.lang.Object
-
- org.apache.wicket.util.watch.ModificationWatcher
-
- All Implemented Interfaces:
IModificationWatcher
- Direct Known Subclasses:
Nio2ModificationWatcher
public class ModificationWatcher extends Object implements IModificationWatcher
Monitors one or moreIModifiable
objects, calling aIChangeListener
when a given object's modification time changes.- Since:
- 1.2.6
- Author:
- Jonathan Locke
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static class
ModificationWatcher.Entry
Container class for holding modifiable entries to watch.
-
Constructor Summary
Constructors Constructor Description ModificationWatcher()
Default constructor for two-phase construction.ModificationWatcher(Duration pollFrequency)
Constructor that accepts aDuration
argument representing the poll frequency.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
add(IModifiable modifiable, IChangeListener<IModifiable> listener)
Adds anIModifiable
object and anIChangeListener
object to call when the modifiable object is modified.protected void
checkModified()
Checks which IModifiables were modified and notifies their listenersvoid
destroy()
Stops thisModificationWatcher
.Set<IModifiable>
getEntries()
Retrieves a key set of allIModifiable
objects currently being monitored.IModifiable
remove(IModifiable modifiable)
Removes all entries associated with anIModifiable
object.void
start(Duration pollFrequency)
Starts watching at a givenDuration
polling rate.
-
-
-
Constructor Detail
-
ModificationWatcher
public ModificationWatcher()
Default constructor for two-phase construction.
-
ModificationWatcher
public ModificationWatcher(Duration pollFrequency)
Constructor that accepts aDuration
argument representing the poll frequency.- Parameters:
pollFrequency
- how often to check onIModifiable
s
-
-
Method Detail
-
add
public final boolean add(IModifiable modifiable, IChangeListener<IModifiable> listener)
Description copied from interface:IModificationWatcher
Adds anIModifiable
object and anIChangeListener
object to call when the modifiable object is modified.- Specified by:
add
in interfaceIModificationWatcher
- Parameters:
modifiable
- anIModifiable
object to monitorlistener
- anIChangeListener
to call if theIModifiable
object is modified- Returns:
true
if the set did not already contain the specified element
-
remove
public IModifiable remove(IModifiable modifiable)
Description copied from interface:IModificationWatcher
Removes all entries associated with anIModifiable
object.- Specified by:
remove
in interfaceIModificationWatcher
- Parameters:
modifiable
- anIModifiable
object- Returns:
- the
IModifiable
object that was removed, elsenull
-
start
public void start(Duration pollFrequency)
Description copied from interface:IModificationWatcher
Starts watching at a givenDuration
polling rate.- Specified by:
start
in interfaceIModificationWatcher
- Parameters:
pollFrequency
- the polling rateDuration
-
checkModified
protected void checkModified()
Checks which IModifiables were modified and notifies their listeners
-
destroy
public void destroy()
Description copied from interface:IModificationWatcher
Stops thisModificationWatcher
.- Specified by:
destroy
in interfaceIModificationWatcher
-
getEntries
public final Set<IModifiable> getEntries()
Description copied from interface:IModificationWatcher
Retrieves a key set of allIModifiable
objects currently being monitored.- Specified by:
getEntries
in interfaceIModificationWatcher
- Returns:
- a
Set
of allIModifiable
entries currently maintained
-
-