Package org.apache.wicket.util.watch
Class ModificationWatcher
- java.lang.Object
-
- org.apache.wicket.util.watch.ModificationWatcher
-
- All Implemented Interfaces:
IModificationWatcher
public class ModificationWatcher extends Object implements IModificationWatcher
Monitors one or moreIModifiableobjects, calling aIChangeListenerwhen 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 classModificationWatcher.EntryContainer 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 aDurationargument representing the poll frequency.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanadd(IModifiable modifiable, IChangeListener<IModifiable> listener)Adds anIModifiableobject and anIChangeListenerobject to call when the modifiable object is modified.protected voidcheckModified()Checks which IModifiables were modified and notifies their listenersvoiddestroy()Stops thisModificationWatcher.Set<IModifiable>getEntries()Retrieves a key set of allIModifiableobjects currently being monitored.IModifiableremove(IModifiable modifiable)Removes all entries associated with anIModifiableobject.voidstart(Duration pollFrequency)Starts watching at a givenDurationpolling rate.
-
-
-
Constructor Detail
-
ModificationWatcher
public ModificationWatcher()
Default constructor for two-phase construction.
-
ModificationWatcher
public ModificationWatcher(Duration pollFrequency)
Constructor that accepts aDurationargument representing the poll frequency.- Parameters:
pollFrequency- how often to check onIModifiables
-
-
Method Detail
-
add
public final boolean add(IModifiable modifiable, IChangeListener<IModifiable> listener)
Description copied from interface:IModificationWatcherAdds anIModifiableobject and anIChangeListenerobject to call when the modifiable object is modified.- Specified by:
addin interfaceIModificationWatcher- Parameters:
modifiable- anIModifiableobject to monitorlistener- anIChangeListenerto call if theIModifiableobject is modified- Returns:
trueif the set did not already contain the specified element
-
remove
public IModifiable remove(IModifiable modifiable)
Description copied from interface:IModificationWatcherRemoves all entries associated with anIModifiableobject.- Specified by:
removein interfaceIModificationWatcher- Parameters:
modifiable- anIModifiableobject- Returns:
- the
IModifiableobject that was removed, elsenull
-
start
public void start(Duration pollFrequency)
Description copied from interface:IModificationWatcherStarts watching at a givenDurationpolling rate.- Specified by:
startin 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:IModificationWatcherStops thisModificationWatcher.- Specified by:
destroyin interfaceIModificationWatcher
-
getEntries
public final Set<IModifiable> getEntries()
Description copied from interface:IModificationWatcherRetrieves a key set of allIModifiableobjects currently being monitored.- Specified by:
getEntriesin interfaceIModificationWatcher- Returns:
- a
Setof allIModifiableentries currently maintained
-
-