com.metamatrix.console.models
Class Manager

java.lang.Object
  extended by com.metamatrix.console.models.Manager
Direct Known Subclasses:
AuthenticationProviderManager, ConfigurationManager, ConnectorManager, EntitlementManager, ExtensionSourceManager, GroupsManager, PropertiesManager, ResourceManager, RuntimeMgmtManager, TimedManager, VdbManager

public abstract class Manager
extends java.lang.Object

Superclass of all Managers. Handles the collection and notification of ManagerListeners with ModelChangeEvents

See Also:
ModelChangeEvent, ManagerListener

Field Summary
static java.lang.String MODEL_CHANGED
          This is the message sent along with a ModelChangedEvent, in the event that a Manager now has new data
static java.lang.String MODEL_STALE
          This is the message sent along with a ModelChangedEvent, in the event that a Manager's data has become stale.
 
Constructor Summary
Manager(ConnectionInfo connection)
           
 
Method Summary
 void addManagerListener(ManagerListener listener)
          Objects wishing to listen for ModelChangedEvents can register themselves as a listener for this Manager.
protected  void fireModelChangedEvent(java.lang.String message)
          This method is intended to be called by subclasses to fire event with a specific meaning (indicated by the message parameter).
protected  void fireModelChangedEvent(java.lang.String message, java.lang.Object arg)
          This method is intended to be called by subclasses to fire event with a specific meaning (indicated by the message parameter and the Object argument).
 ConnectionInfo getConnection()
          Get a connection to the server.
 ConnectionInfo getConnection(boolean reconnect)
          Get a connection to the server.
 Encryptor getEncryptor()
          Get encryptor to use for encrypting passwords to send from the client to the server.
protected  java.util.List getEventListeners()
           
 boolean getIsStale()
          Indicates whether this Manager's cached data is stale (i.e.
 void init()
          Needs to be called by subclasses - sets up event listening.
 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 removeManagerListener(ManagerListener listener)
          Objects not wishing to listen to this Manager's ModelChangedEvents anymore can unregister themselves as a listener
 void setIsStale(boolean isStale)
          Sets the isStale flag.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MODEL_CHANGED

public static final java.lang.String MODEL_CHANGED
This is the message sent along with a ModelChangedEvent, in the event that a Manager now has new data

See Also:
ModelChangedEvent, Constant Field Values

MODEL_STALE

public static final java.lang.String MODEL_STALE
This is the message sent along with a ModelChangedEvent, in the event that a Manager's data has become stale. In response, a ModelListener will usually request some data - this would trigger another ModelChangedEvent, this time with a Model Changed message

See Also:
MODEL_CHANGED, ModelChangedEvent, Constant Field Values
Constructor Detail

Manager

public Manager(ConnectionInfo connection)
Method Detail

getConnection

public ConnectionInfo getConnection(boolean reconnect)
Get a connection to the server.

Parameters:
reconnect - If true, reconnect if not currently connected.
Returns:
Since:
4.3

getConnection

public ConnectionInfo getConnection()
Get a connection to the server. Reconnect if not currently connected.

Returns:
Since:
4.3

init

public void init()
Needs to be called by subclasses - sets up event listening. (Subclasses should call super.init() in the body of their init() method.)

TODO: Perhaps this superclass should set itself to stale as part of the initialization process (see commented code in method body). That would broadcast an event to listeners which would prompt them to begin calling methods on a Manager - or perhaps a start() method with this code should be defined that will be called after init() (allowing subclasses to extend init() before start() would be called)


refresh

public 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.

Currently this method simply calls setIsStale(false)

See Also:
setIsStale(boolean)

addManagerListener

public void addManagerListener(ManagerListener listener)
Objects wishing to listen for ModelChangedEvents can register themselves as a listener for this Manager.

Parameters:
listener - an object implementing ManagerListener interface
See Also:
ModelChangedEvent, ManagerListener

removeManagerListener

public void removeManagerListener(ManagerListener listener)
Objects not wishing to listen to this Manager's ModelChangedEvents anymore can unregister themselves as a listener

Parameters:
listener - an object implementing ManagerListener interface
See Also:
ModelChangedEvent, ManagerListener

fireModelChangedEvent

protected void fireModelChangedEvent(java.lang.String message)
This method is intended to be called by subclasses to fire event with a specific meaning (indicated by the message parameter).

Parameters:
message - String assumed to be passed in by subclass using this message. This class provides some String constants which can be used for this message, and each subclass will likely provide additional String constants
See Also:
MODEL_CHANGED, MODEL_STALE

fireModelChangedEvent

protected void fireModelChangedEvent(java.lang.String message,
                                     java.lang.Object arg)
This method is intended to be called by subclasses to fire event with a specific meaning (indicated by the message parameter and the Object argument).

Parameters:
message - String assumed to be passed in by subclass using this message. This class provides some String constants which can be used for this message, and each subclass will likely provide additional String constants
arg - optional Object argument
See Also:
MODEL_CHANGED, MODEL_STALE

getIsStale

public boolean getIsStale()
Indicates whether this Manager's cached data is stale (i.e. invalid, expired, dirty). In a client-server environment, this means that the Manager has decided it's cached data no longer accurately reflects the up-to-date data on the server.

Listeners are notified once a Manager becomes stale - it is up to a listener to request a specific service from a Manager (subclass) and thus prompt a Manager to update its data. This allows for the case where a Manager becomes stale, and a listener (perhaps part of a GUI that is currently not visible) does not yet need refreshed data.

Returns:
boolean indicates whether this Manager considers it's data to be stale and is due to refresh it

setIsStale

public void setIsStale(boolean isStale)
Sets the isStale flag. If this flag is set to false, the Manager fires a ModelChanged event with a message indicating that data is stale. ManagerListener's will typically want to retrieve data from its Manager in response, although in some cases maybe not (a listener may be a GUI component that is currently hidden from the user).

Parameters:
isStale - boolean indicates whether this Manager considers it's data to be stale and is due to refresh it
See Also:
ModelChangedEvent, ManagerListener, MODEL_STALE

getEventListeners

protected java.util.List getEventListeners()

getEncryptor

public Encryptor getEncryptor()
Get encryptor to use for encrypting passwords to send from the client to the server.

Returns:
Since:
4.3


Copyright © 2009. All Rights Reserved.