org.bsf.listOfValues.client
Class LovManager

java.lang.Object
  extended byorg.bsf.listOfValues.client.LovManager

public class LovManager
extends java.lang.Object

Enables access to the LOV using the given LovService. Is usaully used as a cache between the server and the client.

See Also:
LovValue, LOVService, LovListener

Field Summary
private static java.util.Hashtable _listOfValues
          Holds the retrieved list of values (aLovOID, aList of LovValue).
private static java.util.Hashtable _listOfValuesPerPK
          Holds the retrieved list of values (aLovOID, (aLovValuePK, aList of LovValue)).
private static java.util.Hashtable _lovListeners
          Holds the listeners (LovOID, List of LovListeners).
private static LOVService _lovService
           
static java.lang.Long ALL_LOVS
          To specify that a listener is interested in all the lovs.
private static int DEFAULT_HASH_TABLE_SIZE
           
 
Constructor Summary
LovManager()
           
 
Method Summary
static void addLovManagerListener(LovListener p_lovListener, java.lang.Long p_lovOID)
          Registers a LovListener for the given lovOID.
static void clearLocalCache(java.lang.Long p_lovOID)
          Removes the LOV, whose OID is the given oid, from the cache.
static java.util.List getListOfValues(java.lang.Long p_lovOID)
          Return the requested list of values, checking in its cache first.
static java.util.List getListOfValues(LovListener p_lovListener, java.lang.Long p_lovOID)
          Return the requested list of values, checking in its cache first.
protected static LOVService getLovService()
           
static LovValue getLovValue(java.lang.Long p_lovOID, java.lang.Object p_lovValuePK)
          Return the requested LovValue that belongs to the specified LOV.
static LovValue getLovValue(LovListener p_lovListener, java.lang.Long p_lovOID, java.lang.Object p_lovValuePK)
          Return the requested LovValue that belongs to the specified LOV.
static void notifyLovListeners(java.lang.Long p_lovOID)
          Notify all the listeners interested for the given lovOID.
static void removeLovManagerListener(LovListener p_lovListener)
          Removes the given LovListener from the registered listeners.
static void resynchronizeLov(java.lang.Long p_lovOID)
          Clears the server and client cache and notifies the registered listeners that the LOV has changed.
static void setLovService(LOVService p_lovService)
          Set the LovService to be used to access the LovServiceBean.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ALL_LOVS

public static final java.lang.Long ALL_LOVS
To specify that a listener is interested in all the lovs. Remember that a Lov OID shouldn't be negative (it's a rule :o).


_lovService

private static LOVService _lovService

DEFAULT_HASH_TABLE_SIZE

private static final int DEFAULT_HASH_TABLE_SIZE
See Also:
Constant Field Values

_listOfValues

private static java.util.Hashtable _listOfValues
Holds the retrieved list of values (aLovOID, aList of LovValue).


_listOfValuesPerPK

private static java.util.Hashtable _listOfValuesPerPK
Holds the retrieved list of values (aLovOID, (aLovValuePK, aList of LovValue)).


_lovListeners

private static java.util.Hashtable _lovListeners
Holds the listeners (LovOID, List of LovListeners).

Constructor Detail

LovManager

public LovManager()
Method Detail

getLovService

protected static LOVService getLovService()
Returns:
The lov service defined to be used. Can be null if not set.
See Also:
setLovService(LOVService)

setLovService

public static void setLovService(LOVService p_lovService)
Set the LovService to be used to access the LovServiceBean.

Parameters:
p_lovService - The LovService to use.
Throws:
java.lang.IllegalArgumentException - if the given LovService is null.

getListOfValues

public static java.util.List getListOfValues(java.lang.Long p_lovOID)
                                      throws NoSuchLovException,
                                             java.rmi.RemoteException
Return the requested list of values, checking in its cache first. If not found, request it from the actually registered LovService, and store it in the cache before returning it.

Parameters:
p_lovOID - The OID of the desired list of values.
Returns:
The list of values corresponding to the given LovOID.
Throws:
NoSuchLovException - If the LOV doesn't exist.
java.rmi.RemoteException - If a communication problem occurs.
java.lang.IllegalArgumentException - if the given LovOID is null.
java.lang.IllegalStateException - if no LovService is registered

getListOfValues

public static java.util.List getListOfValues(LovListener p_lovListener,
                                             java.lang.Long p_lovOID)
                                      throws NoSuchLovException,
                                             java.rmi.RemoteException
Return the requested list of values, checking in its cache first. If not found, request it from the actually registered LovService, and store it in the cache before returning it. It register the given LovListener as interested in notification of LOV modification.

Parameters:
p_lovListener - The lovListener to be notified if this requested lov changes. Can be null (no effect on the listener list).
p_lovOID - The OID of the desired list of values.
Returns:
The list of values corresponding to the given LovOID.
Throws:
NoSuchLovException - If the LOV doesn't exist.
java.rmi.RemoteException - If a communication problem occurs.
java.lang.IllegalArgumentException - if the given LovOID is null.
java.lang.IllegalStateException - if no LovService is registered

getLovValue

public static LovValue getLovValue(java.lang.Long p_lovOID,
                                   java.lang.Object p_lovValuePK)
                            throws NoSuchLovValueException,
                                   NoSuchLovException,
                                   java.rmi.RemoteException
Return the requested LovValue that belongs to the specified LOV. The whole list of values is retrieved from the server if not yet in cache. It creates a map to store the LovValue per their oid to accelerate later data access. Can be really useful for example when the getLovValue method is used in an often called renderer (TableCellRenderer for example).

Parameters:
p_lovOID - The OID of the desired list of values.
p_lovValuePK - The PK of the LovValue (belonging to the LOV whose oid is p_lovOID) desired.
Returns:
The list of values corresponding to the given LovOID.
Throws:
NoSuchLovValueException - if the requested lov value doesn't exist.
NoSuchLovException - if the LOV doesn't exist.
java.rmi.RemoteException - if a communication problem occurs.
java.lang.IllegalStateException - if no LovService is registered.
java.lang.ClassCastException - if the LOV contains anything else than LovValue.

getLovValue

public static LovValue getLovValue(LovListener p_lovListener,
                                   java.lang.Long p_lovOID,
                                   java.lang.Object p_lovValuePK)
                            throws NoSuchLovValueException,
                                   NoSuchLovException,
                                   java.rmi.RemoteException
Return the requested LovValue that belongs to the specified LOV. The whole list of values is retrieved from the server if not yet in cache. It creates a map to store the LovValue per their oid to accelerate later data access. Can be really useful for example when the getLovValue method is used in an often called renderer (TableCellRenderer for example).

Parameters:
p_lovListener - The listener to be notify is the requested LOV changes. Can be null (no effect on the listeners list).
p_lovOID - The OID of the desired list of values.
p_lovValuePK - The OID of the LovValue (belonging to the LOV whose oid is p_lovOID) desired.
Returns:
The list of values corresponding to the given LovOID.
Throws:
NoSuchLovValueException - if the requested lov value doesn't exist.
NoSuchLovException - if the LOV doesn't exist.
java.rmi.RemoteException - if a communication problem occurs.
java.lang.IllegalStateException - if no LovService is registered.
java.lang.ClassCastException - if the LOV contains anything else than LovValue.

resynchronizeLov

public static void resynchronizeLov(java.lang.Long p_lovOID)
                             throws NoSuchLovException,
                                    java.rmi.RemoteException
Clears the server and client cache and notifies the registered listeners that the LOV has changed. The LOV isn't reloaded through this call... It will notifies the listeners (if any). It will be reloaded the next time this lov is loaded.

Parameters:
p_lovOID - The OID of the Lov to synchronize with the server.
Throws:
NoSuchLovException - If no lov has the given OID.
java.rmi.RemoteException - If a communication problem occurs.
java.lang.IllegalArgumentException - if the given oid is null.
java.lang.IllegalStateException - if no LovService has been set.
See Also:
LOVService, setLovService(LOVService)

clearLocalCache

public static void clearLocalCache(java.lang.Long p_lovOID)
Removes the LOV, whose OID is the given oid, from the cache.

Parameters:
p_lovOID - The OID of the LOV to remove from the cache. Should not be null.
Throws:
java.lang.IllegalArgumentException - if the given oid is null.

addLovManagerListener

public static void addLovManagerListener(LovListener p_lovListener,
                                         java.lang.Long p_lovOID)
Registers a LovListener for the given lovOID. If the lovOID equals ALL_LISTENERS the LovListener will be notified of the modification of every lov. Does nothing if the LovListener is null.

Parameters:
p_lovListener - The LovListener that we want to be notified.
p_lovOID - The OID of the LOV that the LovListener listens to, if equals to ALL_LOVS can be used to specify that a listener is interested by all the Lovs.

removeLovManagerListener

public static void removeLovManagerListener(LovListener p_lovListener)
Removes the given LovListener from the registered listeners.

Parameters:
p_lovListener - The LovListener that we want to remove.
Throws:
java.lang.IllegalArgumentException - if the LovListener is null.

notifyLovListeners

public static void notifyLovListeners(java.lang.Long p_lovOID)
Notify all the listeners interested for the given lovOID.

Parameters:
p_lovOID - The OID of the LOV of which we want to notify the modificaiton.
Throws:
java.lang.IllegalArgumentException - if the given lovOID is null.