© 2001 BEA Systems, Inc.

com.beasys.commerce.axiom.contact.security
Class GroupCache

com.beasys.commerce.axiom.contact.security.GroupCache

public class GroupCache

This class is responsible for creating and maintaining a pre-calculated cache of group membership information. It can be used to speed up group membership lookups in a system with a deep group hierarchy.


Field Summary
protected static java.lang.String CACHE_TABLE
          Name of the table used to store precalculated group data
static long DEFAULT_RELOAD_INTERVAL
          The default value for the reload interval (in seconds)
static long INITIAL_LOAD_INTERVAL
          The interval to wait before performing the initial load (in seconds)
protected  long reloadInterval
          The cache reload interval
protected  weblogic.common.T3ServicesDef services
          The services object passed in by WLS
static java.lang.String UPDATE_PROPERTY_NAME
          flag to indicate that this copy should do the database updates
protected  boolean updateDb
          Flag to indicate that database updates should occur
static boolean VERBOSE
          A flag used to indicate whether or not messages should be printed
 
Constructor Summary
GroupCache()
          Default Constructor A default constructor is required by WLS
 
Method Summary
protected static void close(java.sql.Connection c)
           
protected static void close(java.sql.PreparedStatement ps)
           
protected static void close(java.sql.ResultSet rs)
           
static java.lang.String[] getCachedGroupNamesForUser(java.lang.String userName)
          Gets a list of names of the groups to which a user has membership
protected static java.sql.Connection getReadConnection()
          Returns a connection for reading from the pre-calculated table.
protected static java.sql.Connection getWriteConnection()
          Returns a connection to use when regenerating the pre-calculated table.
protected  void insertGroupMembers(java.lang.String groupName, java.util.Set members, java.sql.Connection conn)
          Get the user id's of the members of the group specified by groupId; add them to the members Set; insert them into the cache table for that group; then call itself recursively for each child of the given group, with the augmented set of members.
protected  void regenerateGroupTable()
          Kicks off the pre-calculated membership table process by dropping all rows, getting a list of the top level groups, and then calling insertGroupMembers for each of them.
protected  void reloadCache()
          Reloads the group cache
 long schedule(long time)
          Determines schedule for trigger
 void setServices(weblogic.common.T3ServicesDef services)
          Sets the T3ServicesDef object to be used by the instance of GroupCache
 java.lang.String startup(java.lang.String name, java.util.Hashtable startupArgs)
          Starts the instance of GroupCache
 void trigger(weblogic.time.common.Schedulable schedulable)
          Call back for WLS time service to notify the group cache that a cache reload should be performed
 

Field Detail

DEFAULT_RELOAD_INTERVAL

public static final long DEFAULT_RELOAD_INTERVAL
The default value for the reload interval (in seconds)

INITIAL_LOAD_INTERVAL

public static final long INITIAL_LOAD_INTERVAL
The interval to wait before performing the initial load (in seconds)

UPDATE_PROPERTY_NAME

public static final java.lang.String UPDATE_PROPERTY_NAME
flag to indicate that this copy should do the database updates

VERBOSE

public static final boolean VERBOSE
A flag used to indicate whether or not messages should be printed

reloadInterval

protected long reloadInterval
The cache reload interval

services

protected weblogic.common.T3ServicesDef services
The services object passed in by WLS

updateDb

protected boolean updateDb
Flag to indicate that database updates should occur

CACHE_TABLE

protected static final java.lang.String CACHE_TABLE
Name of the table used to store precalculated group data
Constructor Detail

GroupCache

public GroupCache()
Default Constructor A default constructor is required by WLS
Method Detail

getCachedGroupNamesForUser

public static java.lang.String[] getCachedGroupNamesForUser(java.lang.String userName)
                                                     throws ServiceProviderException
Gets a list of names of the groups to which a user has membership
Parameters:
userName - A user name
Returns:
A list of group names

schedule

public long schedule(long time)
Determines schedule for trigger
Parameters:
time - The time to which the reload interval should be added
Returns:
The scheduled trigger time

setServices

public void setServices(weblogic.common.T3ServicesDef services)
Sets the T3ServicesDef object to be used by the instance of GroupCache

startup

public java.lang.String startup(java.lang.String name,
                                java.util.Hashtable startupArgs)
                         throws java.lang.Exception
Starts the instance of GroupCache
Parameters:
name - The name GroupCache name set in weblogic.properties
startupArgs - The startup args set in weblogic.properties
Returns:
String A startup message that is sent to the log
Throws:
java.lang.Exception - Thrown if anything whatsoever goes wrong

trigger

public void trigger(weblogic.time.common.Schedulable schedulable)
Call back for WLS time service to notify the group cache that a cache reload should be performed
Parameters:
schedulable - The cache reload schedulable

regenerateGroupTable

protected void regenerateGroupTable()
Kicks off the pre-calculated membership table process by dropping all rows, getting a list of the top level groups, and then calling insertGroupMembers for each of them.

insertGroupMembers

protected void insertGroupMembers(java.lang.String groupName,
                                  java.util.Set members,
                                  java.sql.Connection conn)
                           throws java.sql.SQLException,
                                  ServiceProviderException
Get the user id's of the members of the group specified by groupId; add them to the members Set; insert them into the cache table for that group; then call itself recursively for each child of the given group, with the augmented set of members. This will build the cached group membership table hierarchically.

reloadCache

protected void reloadCache()
Reloads the group cache

close

protected static void close(java.sql.ResultSet rs)

close

protected static void close(java.sql.PreparedStatement ps)

close

protected static void close(java.sql.Connection c)

getReadConnection

protected static java.sql.Connection getReadConnection()
                                                throws java.sql.SQLException
Returns a connection for reading from the pre-calculated table. This connection tries to be TRANSACTION_READ_COMMITTED, but will fall back to TRANSACTION_SERIALIZABLE if the database or driver does not support it.

getWriteConnection

protected static java.sql.Connection getWriteConnection()
                                                 throws java.sql.SQLException
Returns a connection to use when regenerating the pre-calculated table. This connection is marked TRANSACTION_SERIALIZABLE, and has AutoCommit set to false so that the entire operation will be done in a single transaction. This will prevent queries from reading partially calculated information.

© 2001 BEA Systems, Inc.

Copyright © 2001 BEA Systems, Inc. All Rights Reserved