org.limitless.nmc.Client
Class AvailableMuCollection

java.lang.Object
  extended by org.limitless.nmc.Client.AvailableMuCollection

public class AvailableMuCollection
extends java.lang.Object

This class represents only the names of MUs as established in an external index.

This class is meant to be used basically as a cache. As such, it can be told to discard it's current values. The next time it's hit, it will reload them.

The reload mechanism is done by the Template Method (or Hollywood) pattern. This class expects to be derived from, and the derived class will carry out the protected reloadNames() on demand. There's no means to add manual entries to this; all work is done by the appropriate derived class. Since this is a singleton, the creation of the derived class object causes the useless base-class object to be discarded.

Author:
Brian Jones

Field Summary
private static AvailableMuCollection instance
          This holds the current object that does the work.
(package private) static org.apache.log4j.Logger logger
          Log4J Logger
private  java.util.Set muNames
          This holds the list of strings that are the MU names.
private  java.util.Set readOnlyMuNames
          This holds an unmodifiable version, suitable for handing to external users without risk of corruption.
private  boolean reloadNextHit
          This goes true if the collection requires a load of entries.
 
Constructor Summary
protected AvailableMuCollection()
          This makes clear that only derived classes should create these.
 
Method Summary
protected  void addMuName(java.lang.String name)
          This allows the derived class to add an entry.
 void discard()
          This causes the object to throw away all that's stored.
 java.util.Set getNames()
          This provides access to the set to outside users.
static AvailableMuCollection Instance()
          This requests the current worker object.
private  void reload()
          This is the template-method which calles reloadNames() when it's ready for the derived class to reload.
protected  void reloadNames()
          This causes the set to be re-populated by the derived class.
protected  void setInstance(AvailableMuCollection n)
          This allows the derived class to "set" its new object as the current object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

static org.apache.log4j.Logger logger
Log4J Logger


instance

private static AvailableMuCollection instance
This holds the current object that does the work.


reloadNextHit

private boolean reloadNextHit
This goes true if the collection requires a load of entries. Typically, this is on a discard() or creation.


muNames

private java.util.Set muNames
This holds the list of strings that are the MU names.


readOnlyMuNames

private java.util.Set readOnlyMuNames
This holds an unmodifiable version, suitable for handing to external users without risk of corruption.

Constructor Detail

AvailableMuCollection

protected AvailableMuCollection()
This makes clear that only derived classes should create these.

Method Detail

Instance

public static AvailableMuCollection Instance()
This requests the current worker object.


discard

public void discard()
This causes the object to throw away all that's stored.


getNames

public java.util.Set getNames()
This provides access to the set to outside users.

Returns:
An un-modifiable set of all known MU names.

reloadNames

protected void reloadNames()
This causes the set to be re-populated by the derived class. This base-class implementation adds test entries only, which is pretty useless except in testing. The real implementation class should call "discard()" when done if the load doesn't succeed to cause a re-try later.


setInstance

protected void setInstance(AvailableMuCollection n)
This allows the derived class to "set" its new object as the current object. This is called by the derived class to enable it for use.


addMuName

protected void addMuName(java.lang.String name)
This allows the derived class to add an entry.


reload

private void reload()
This is the template-method which calles reloadNames() when it's ready for the derived class to reload. This shouldn't be (and since it's private, won't likely be) over-ridden.



Copyright © 1995, 2004 Limitless Knowledge Association, All Rights Reserved.