|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.metamatrix.console.models.Manager
com.metamatrix.console.models.TimedManager
public abstract class TimedManager
Abstract superclass of timed managers - timed managers maintain data which becomes stale after a certain amount of time, and needs periodic refreshing.
Clients can specify a refresh rate in seconds, and dynamically enable or disable auto refreshing.
A TimedManager has a true
property, which subclasses should
set to true
when about to start a lengthy network operation,
and then set to false
when and if the operation finishes.
The TimedManager class will ignore it's internal timer while
busy, since it is in the middle of refreshing itself anyway. Note:
it is a good idea to set the code that sets busy
back to
false
in a finally
block, to ensure that the
TimedManager will be un-busied in the event of a failed network operation.
Example:
public class SomeDataManager extends TimedManager{ public Collection retrieveSomeData(){ Collection result; try{ super.setBusy(true); //HERE'S THE OPERATION THAT CAN TAKE SOME TIME, AND //POTENTIALLY FAIL -------------------------------- result = remoteProxy.retrieveSomeData; //------------------------------------------------- }catch(SomeException e){ //do something }catch(OtherException e){ //do something }finally{ super.setBusy(false); } } }
Field Summary | |
---|---|
static int |
DEFAULT_DELAY
Default refresh rate (seconds) used if none is otherwise specified. |
Fields inherited from class com.metamatrix.console.models.Manager |
---|
MODEL_CHANGED, MODEL_STALE |
Constructor Summary | |
---|---|
TimedManager(ConnectionInfo connection)
Creates a TimedManager with the default refresh rate |
|
TimedManager(ConnectionInfo connection,
int refreshRateSeconds)
Creates a TimedManager with the specified refresh rate |
|
TimedManager(ConnectionInfo connection,
int refreshRateSeconds,
boolean isAutoRefreshEnabled)
Creates a TimedManager with the specified refresh rate |
Method Summary | |
---|---|
void |
actionPerformed(java.awt.event.ActionEvent e)
This method, called by this Manager's Timer, indicates that time has run out. |
boolean |
getIsAutoRefreshEnabled()
If the autoRefresh feature of TimedManager is enabled, the timer will run and the Manager will be notified each time the timer runs out, and will call it's own refresh() method. |
int |
getRefreshRate()
|
protected javax.swing.Timer |
getTimer()
Returns the Timer object used by TimedManager. |
void |
init()
Calls super.init() and also initializes timing behavior. |
boolean |
isBusy()
Indicates whether this TimedManager is in the middle of a network call or not. |
void |
refresh()
Refresh tells a manager that it's data is stale and it should retrieve real data (rather than cached data) the next time data is requested. |
void |
refresh(boolean setIsStale)
This method calls super.refresh and, additionally, stops the timer running. |
void |
setBusy(boolean busy)
Indicates whether this TimedManager is in the middle of a network call or not. |
void |
setIsAutoRefreshEnabled(boolean isAutoRefreshEnabled)
If the autoRefresh feature of TimedManager is enabled, the timer will run and the Manager will be notified each time the timer runs out, and will call it's own refresh() method. |
void |
setRefreshRate(int seconds)
Subclasses of TimedManager must be sure to set their refresh rate, in addition to other initialization behavior. |
void |
startTimer()
If the timer isn't already started, and autoRefresh is enabled, starts this Timed Manager's clock ticking until a Manager's data in memory is considered stale. |
Methods inherited from class com.metamatrix.console.models.Manager |
---|
addManagerListener, fireModelChangedEvent, fireModelChangedEvent, getConnection, getConnection, getEncryptor, getEventListeners, getIsStale, removeManagerListener, setIsStale |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int DEFAULT_DELAY
Constructor Detail |
---|
public TimedManager(ConnectionInfo connection)
DEFAULT_DELAY
public TimedManager(ConnectionInfo connection, int refreshRateSeconds)
refreshRateSeconds
- rate at which TimedManager refreshes itselfpublic TimedManager(ConnectionInfo connection, int refreshRateSeconds, boolean isAutoRefreshEnabled)
refreshRateSeconds
- rate at which TimedManager refreshes itselfisAutoRefreshEnabled
- controls whether TimedManager will
refresh itself or notMethod Detail |
---|
public void init()
init
in class Manager
setRefreshRate(int)
public void startTimer()
Note that this method may always be called - it will only start the timer if autoRefresh is enabled.
There is no explicit stopTimer method, rather the refresh method causes the timer to stop. (The refresh method is either called by some outside code, or by this TimedManager when it's timer runs out.)
refresh(boolean)
,
setIsAutoRefreshEnabled(boolean)
public void refresh(boolean setIsStale)
startTimer()
,
Manager.refresh()
public void refresh()
Manager
Currently this method simply calls setIsStale(false)
refresh
in class Manager
Manager.setIsStale(boolean)
public void actionPerformed(java.awt.event.ActionEvent e)
actionPerformed
in interface java.awt.event.ActionListener
refresh(boolean)
public int getRefreshRate()
public void setRefreshRate(int seconds)
seconds
- time after which data is stalepublic boolean getIsAutoRefreshEnabled()
public void setIsAutoRefreshEnabled(boolean isAutoRefreshEnabled)
protected javax.swing.Timer getTimer()
public boolean isBusy()
Managers should set themselves to busy right before beginning a potentially long network operation, and set themselves to not busy right after the operation completes.
public void setBusy(boolean busy)
Managers should set themselves to busy right before beginning a potentially long network operation, and set themselves to not busy right after the operation completes.
busy
- indicates TimedManager is in the middle of an atomic
network call
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |