org.aselect.system.storagemanager.handler
Class JDBCStorageHandler

java.lang.Object
  extended by org.aselect.system.storagemanager.handler.JDBCStorageHandler
All Implemented Interfaces:
IStorageHandler

public class JDBCStorageHandler
extends java.lang.Object
implements IStorageHandler

DBMS storage handler.

Description:
The JDBCStorageHandler uses a DBMS for physical storage.

The DBMS is accessed through JDBC. Objects that are written to the DBMS are encoded to bytes, using the ObjectOutputStream mechanism of Java.

Concurrency issues:
-

Author:
Alfa & Ariss

Constructor Summary
JDBCStorageHandler()
           
 
Method Summary
 void cleanup(java.lang.Long lTimestamp)
          Removes the objects from the database that have expired.
 boolean containsKey(java.lang.Object oKey)
          Checks if the supplied key already exists in the database

 void destroy()
          Clean up all used recourses.
 java.lang.Object get(java.lang.Object oKey)
          Returns a particular object from the database.
 java.util.Hashtable getAll()
          Returns all the objects stored in the table.
 long getCount()
          Returns the number of objects stored in the table.
 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)
          Initialize the JDBCStorageHandler.
 boolean isMaximum(long lItemCount)
          Checks if the maximum items is reached.
 void put(java.lang.Object oKey, java.lang.Object oValue, java.lang.Long lTimestamp)
          Inserts a particular object into the database.
 void remove(java.lang.Object oKey)
          Removes a particular object from the database.
 void removeAll()
          Removes all the stored objects from the database.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JDBCStorageHandler

public JDBCStorageHandler()
Method Detail

init

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

Description: Initalises the JDBCStorageHandler:
Concurrency issues:
-

Preconditions:
Postconditions:

Specified by:
init in interface IStorageHandler
Parameters:
oConfigSection - The section within the configuration file in which the parameters for the IStorageHandler can be found.
oConfigManager - The configuration.
systemLogger - The logger for system entries.
oSAMAgent - The SAM agant to use.
Throws:
ASelectStorageException - If initialisation fails.
See Also:
IStorageHandler.init(java.lang.Object, org.aselect.system.configmanager.ConfigManager, org.aselect.system.logging.SystemLogger, org.aselect.system.sam.agent.SAMAgent)

get

public java.lang.Object get(java.lang.Object oKey)
                     throws ASelectStorageException
Returns a particular object from the database.

Specified by:
get in interface IStorageHandler
Parameters:
oKey - The identifier of the object that needs to be stored.
Returns:
The stored object.
Throws:
ASelectStorageException - If retrieving fails.
See Also:
IStorageHandler.get(java.lang.Object)

getTimestamp

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

Specified by:
getTimestamp in interface IStorageHandler
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(java.lang.Object)

getCount

public long getCount()
              throws ASelectStorageException
Returns the number of objects stored in the table.

Specified by:
getCount in interface IStorageHandler
Returns:
The number of all stored object.
Throws:
ASelectStorageException - If retrieving fails.
See Also:
IStorageHandler.getCount()

getAll

public java.util.Hashtable getAll()
                           throws ASelectStorageException
Returns all the objects stored in the table.

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

put

public void put(java.lang.Object oKey,
                java.lang.Object oValue,
                java.lang.Long lTimestamp)
         throws ASelectStorageException
Inserts a particular object into the database.

Specified by:
put in interface IStorageHandler
Parameters:
oKey - The identifier of the object that needs to be stored.
oValue - The object that needs to be stored.
lTimestamp - The time at which the object is stored.
Throws:
ASelectStorageException - If storing fails.
See Also:
IStorageHandler.put(java.lang.Object, java.lang.Object, java.lang.Long)

remove

public void remove(java.lang.Object oKey)
            throws ASelectStorageException
Removes a particular object from the database.

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

removeAll

public void removeAll()
               throws ASelectStorageException
Removes all the stored objects from the database.

Specified by:
removeAll in interface IStorageHandler
Throws:
ASelectStorageException - if removal fails.
See Also:
IStorageHandler.removeAll()

cleanup

public void cleanup(java.lang.Long lTimestamp)
             throws ASelectStorageException
Removes the objects from the database that have expired.

Specified by:
cleanup in interface IStorageHandler
Parameters:
lTimestamp - The expiration time.
Throws:
ASelectStorageException - If cleaning fails.
See Also:
IStorageHandler.cleanup(java.lang.Long)

destroy

public void destroy()
Clean up all used recourses.

Specified by:
destroy in interface IStorageHandler
See Also:
IStorageHandler.destroy()

isMaximum

public boolean isMaximum(long lItemCount)
                  throws ASelectStorageException
Checks if the maximum items is reached.

Specified by:
isMaximum in interface IStorageHandler
Parameters:
lItemCount - number of items that will be checked if it is the maximum
Returns:
TRUE if storage maximum is reached
Throws:
ASelectStorageException - if io error occurred with physical storage
See Also:
IStorageHandler.isMaximum(long)

containsKey

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

Specified by:
containsKey in interface IStorageHandler
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
See Also:
IStorageHandler.containsKey(java.lang.Object)


Copyright © 2008 SURFnet BV. All Rights Reserved.