org.aselect.system.storagemanager
Class StorageManager

java.lang.Object
  extended by org.aselect.system.storagemanager.StorageManager
Direct Known Subclasses:
AssertionSessionManager, AuthSPSessionManager, SessionManager, TGTManager

public class StorageManager
extends java.lang.Object

Store objects to some sort of physical storage.

Description:
The StorageManager is designed to store objects, like a Hashtable, to some sort of physical storage.

The StorageManager uses StorageHandler s to actual store the objects. Objects can be stored for a limited amount of time. A Cleaner will remove the objects that have expired.

Concurrency issues:
-

Author:
Alfa & Ariss

Field Summary
static java.lang.String MODULE
          The module name.
 
Constructor Summary
StorageManager()
          Default constructor.
 
Method Summary
 boolean containsKey(java.lang.Object oKey)
          Checks if the supplied key already exists in the physical storage
 void destroy()
          Clean up all used resources.
 java.lang.Object get(java.lang.Object oKey)
          Retrieve object from storage.
 java.util.Hashtable getAll()
          Retrieve all stored objects.
 long getCount()
          Retrieve the number of stored objects.
 long getExpirationTime(java.lang.Object oKey)
          Retrieve an object its expiration time from storage.
 long getTimestamp(java.lang.Object oKey)
          Retrieve an object its timestamp from storage.
 void init(java.lang.Object oConfigSection, ConfigManager oConfigManager, SystemLogger systemLogger, SAMAgent oSAMAgent)
          (Re)initialize the storage.
 void put(java.lang.Object oKey, java.lang.Object oValue)
          Insert an object in storage.
 void remove(java.lang.Object oKey)
          Remove a storage object.
 void removeAll()
          Remove all stored objects.
 void update(java.lang.Object oKey, java.lang.Object oValue)
          Updates an object in storage.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MODULE

public static final java.lang.String MODULE
The module name.

See Also:
Constant Field Values
Constructor Detail

StorageManager

public StorageManager()
Default constructor.

Method Detail

init

public void init(java.lang.Object oConfigSection,
                 ConfigManager oConfigManager,
                 SystemLogger systemLogger,
                 SAMAgent oSAMAgent)
          throws ASelectStorageException
(Re)initialize the storage.

Description:
This function initializes the StorageManager. The following steps are taken:
Concurrency issues:
-

Preconditions:
Postconditions:
The storage is initialized.

Parameters:
oConfigSection - The section within the configuration file in which the parameters for the StorageManager can be found.
oConfigManager - The configuration to be used.
systemLogger - The logger for system entries.
oSAMAgent - The SAM agent to be used.
Throws:
ASelectStorageException - If storage initialization fails.

get

public java.lang.Object get(java.lang.Object oKey)
                     throws ASelectStorageException
Retrieve object from storage.

Description:
Returns a particular object from the storage. Calls the handler its get().

Concurrency issues:
-

Preconditions:
oKey != null

Postconditions:
-

Parameters:
oKey - The identifier of the object that needs to be obtained from the storage.
Returns:
The stored object.
Throws:
ASelectStorageException - If retrieving fails.
See Also:
IStorageHandler.get(Object)

getExpirationTime

public long getExpirationTime(java.lang.Object oKey)
                       throws ASelectStorageException
Retrieve an object its expiration time from storage.

Description:
Returns the storage expiration time of a particular object from the storage. Calls the handler its getTimestamp() and adds the configured expiration time.

Concurrency issues:
-

Preconditions:
oKey != null

Postconditions:
-

Parameters:
oKey - The identifier of the object that needs to be obtained from the storage.
Returns:
The expiration time of the stored object.
Throws:
ASelectStorageException - If retrieving fails.
See Also:
IStorageHandler.getTimestamp(Object)

getTimestamp

public long getTimestamp(java.lang.Object oKey)
                  throws ASelectStorageException
Retrieve an object its timestamp from storage.

Description:
Returns the storage timestamp of a particular object from the storage. Calls the handler its getTimestamp().

Concurrency issues:
-

Preconditions:
oKey != null

Postconditions:
-

Parameters:
oKey - The identifier of the object that needs to be obtained from the storage.
Returns:
The timestamp of the stored object.
Throws:
ASelectStorageException - If retrieving fails.
See Also:
IStorageHandler.getTimestamp(Object)

getAll

public java.util.Hashtable getAll()
                           throws ASelectStorageException
Retrieve all stored objects.

Description:
Returns all the stored objects. Calls the handler its getAll().

Concurrency issues:
-

Preconditions:
The storage manager and handler must be initialized.

Postconditions:
-

Returns:
A Hashtable containing all stored object as key/value.
Throws:
ASelectStorageException - if retrieving fails.
See Also:
IStorageHandler.getAll()

getCount

public long getCount()
              throws ASelectStorageException
Retrieve the number of stored objects.

Description:
Returns the number of stored objects. Calls the handler its getCount().

Concurrency issues:
-

Preconditions:
The storage manager and handler must be initialized.

Postconditions:
-

Returns:
The number of stored objects
Throws:
ASelectStorageException - if retrieving fails.
See Also:
IStorageHandler.getCount()

put

public void put(java.lang.Object oKey,
                java.lang.Object oValue)
         throws ASelectStorageException
Insert an object in storage.

Description:
Inserts an object into the storage. Along with the storing of the object, a timestamp is created. This timestamp is used to evaluate whether or not the object should be kept in storage (expiration).

Calls the handler its put().

Concurrency issues:
-

Preconditions:
Postconditions:
The storage contains the given object.

Parameters:
oKey - The identifier of the object that is to be stored.
oValue - The object that is to be stored.
Throws:
ASelectStorageException - If storing fails.
See Also:
IStorageHandler.put(Object, Object, Long)

update

public void update(java.lang.Object oKey,
                   java.lang.Object oValue)
            throws ASelectStorageException
Updates an object in storage.

Description:
Updates an object into the storage. Along with the storing of the object, a timestamp is created. This timestamp is used to evaluate whether or not the object should be kept in storage (expiration).

Calls the handler its put().

Concurrency issues:
-

Preconditions:
Postconditions:
The storage contains the given object.

Parameters:
oKey - The identifier of the object that is to be stored.
oValue - The object that is to be stored.
Throws:
ASelectStorageException - If storing fails.
See Also:
IStorageHandler.put(Object, Object, Long)

containsKey

public boolean containsKey(java.lang.Object oKey)
                    throws ASelectStorageException
Checks if the supplied key already exists in the physical storage

Parameters:
oKey - The unique key that will be checked for existance
Returns:
TRUE if the key exists
Throws:
ASelectStorageException - if IO error occurred with physical storage

remove

public void remove(java.lang.Object oKey)
            throws ASelectStorageException
Remove a storage object.

Description:
Removes a particular object from the storage. Calls the handler its remove().

Concurrency issues:
-

Preconditions:
oKey != null

Postconditions:
The object with the given key is removed from the storage.

Parameters:
oKey - The identifier of the object that needs to be removed.
Throws:
ASelectStorageException - If removal fails.
See Also:
IStorageHandler.remove(Object)

removeAll

public void removeAll()
               throws ASelectStorageException
Remove all stored objects.

Description:
Removes all the stored objects from the storage. Calls the handler its removeAll().

Concurrency issues:
-

Preconditions:
-

Postconditions:
All objects in storage are removed.

Throws:
ASelectStorageException - If removal fails.
See Also:
IStorageHandler.removeAll()

destroy

public void destroy()
Clean up all used resources.

Description:
Performs the following steps:
Concurrency issues:
-

Preconditions:
-

Postconditions:
The storage manager is cleared.

See Also:
IStorageHandler.destroy(), Cleaner#destroy()


Copyright © 2008 SURFnet BV. All Rights Reserved.