info.aduna.gee.publication.servlets.cache
Class AliasInfoCache

java.lang.Object
  extended by info.aduna.gee.publication.servlets.cache.AliasInfoCache

public class AliasInfoCache
extends Object

Class AliasInfoCache


Field Summary
protected static HashMap _aliasesPerHost
          A mapping of hostnames to (Array)Lists of AliasInfo objects.
 
Constructor Summary
AliasInfoCache()
           
 
Method Summary
protected static ArrayList _fillCache(String host)
          Fills the cache for the indicated host with the info from the aliasdb.
static int binarySearch(List aliases, String alias)
          See Arrays.binarySearch() for comments.
static void changeCover(String host, String alias, String cover)
          Change the cover for a certain alias.
static ArrayList ensureAliasesLoaded(String host)
          Ensures the list of aliases for a certain host is loaded.
static AliasInfo get(String host, String alias)
          Gets a AliasInfo object from this cache.
static List getAll(String host, String user)
          Gets all aliases of a certain user.
static List getAllAliases(String host)
          Gets all aliases known for a certain host.
static void put(String host, UserInfo userInfo, String alias)
          Puts a (new) alias into the AliasInfoCache and the underlying aliasdb.
static void refresh(String host)
          Refreshes (throws away) the cached info for a certain host.
static void remove(String host, String alias)
          Removes an alias from the AliasInfoCache and the underlying aliasdb.
static void removeAll(String host, String username)
          Removes all aliases of a certain user.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_aliasesPerHost

protected static HashMap _aliasesPerHost
A mapping of hostnames to (Array)Lists of AliasInfo objects.

Constructor Detail

AliasInfoCache

public AliasInfoCache()
Method Detail

refresh

public static void refresh(String host)
Refreshes (throws away) the cached info for a certain host.

Parameters:
host - the name of the server to refresh the cache for

ensureAliasesLoaded

public static ArrayList ensureAliasesLoaded(String host)
Ensures the list of aliases for a certain host is loaded.

Parameters:
host - the name of the server to ensure the loaded list for
Returns:
the list of aliases (guaranteed non-null).

get

public static AliasInfo get(String host,
                            String alias)
Gets a AliasInfo object from this cache.

Parameters:
host - the Zpad server on which the user is registered
alias - the alias of a user
Returns:
the AliasInfo object for the alias or null if not found.

getAll

public static List getAll(String host,
                          String user)
Gets all aliases of a certain user.

Returns:
a List of aliases (Strings)

getAllAliases

public static List getAllAliases(String host)
Gets all aliases known for a certain host. The returned List is the object used by this cache, so be carefull with that (DON'T CHANGE)! Also, the returned List is unsynchronized!


put

public static void put(String host,
                       UserInfo userInfo,
                       String alias)
Puts a (new) alias into the AliasInfoCache and the underlying aliasdb. Any info with the same alias will be overwritten.


remove

public static void remove(String host,
                          String alias)
Removes an alias from the AliasInfoCache and the underlying aliasdb.


removeAll

public static void removeAll(String host,
                             String username)
Removes all aliases of a certain user.

Parameters:
host - the name of the server
username - the real name of the user

changeCover

public static void changeCover(String host,
                               String alias,
                               String cover)
Change the cover for a certain alias.


_fillCache

protected static ArrayList _fillCache(String host)
Fills the cache for the indicated host with the info from the aliasdb. If the aliasdb for that host does not exist, an empty ArrayList will be inserted.


binarySearch

public static int binarySearch(List aliases,
                               String alias)
See Arrays.binarySearch() for comments.



Copyright © 1997-2008 Aduna. All Rights Reserved.