Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.jgroups.persistence
Class DBPersistenceManager  view DBPersistenceManager download DBPersistenceManager.java

java.lang.Object
  extended byorg.jgroups.persistence.DBPersistenceManager
All Implemented Interfaces:
PersistenceManager

public class DBPersistenceManager
extends java.lang.Object
implements PersistenceManager

Class will be utilized


Field Summary
private  java.lang.String connStr
           
private  java.lang.String createTable
           
private static java.lang.String createTableGen
           
private static java.lang.String createTableOra
           
private  java.lang.String driverName
           
private static java.lang.String insertStat
           
private  java.util.Vector list
           
protected  org.apache.commons.logging.Log log
           
private  boolean oracleDB
           
private  java.util.Properties props
           
private static java.lang.String removeStat
           
private static java.lang.String tabName
           
private static java.lang.String updateStat
           
private  java.lang.String userName
           
private  java.lang.String userPass
           
 
Constructor Summary
DBPersistenceManager(java.io.InputStream input)
          Duplicate constructor allowing inputstream
DBPersistenceManager(java.lang.String filename)
          Default construct
 
Method Summary
private  void addNewEntry(java.io.Serializable key, java.io.Serializable val)
          Used to enter a completely new row in to the current table
private  void addNewEntryGen(java.io.Serializable key, java.io.Serializable val)
          Used to enter a completely new row in to the current table
private  void addNewEntryOra(java.io.Serializable key, java.io.Serializable val)
          Used to enter a completely new row in to the current table
private  void addSchemaToDB(java.sql.Connection conn)
          used to create required table within the DB
 void clear()
          Clears the key-cache as well as all entries
private  void closeConnection(java.sql.Connection conn)
          Method is used for closing created connection.
private  void createDBTables()
          Used to create table provided the DB instance
private  boolean entryExists(java.io.Serializable key)
          Cache checking
private  java.io.InputStream getBinaryInputStream(java.io.Serializable ser)
          Gets a binaryinputstream from a serialized object
private  byte[] getBytes(java.io.Serializable ser)
          Conversion helper
private  java.sql.Connection getConnection()
          Once the driver is loaded, the DB is ready to be connected.
private  java.io.Serializable getSerializable(java.io.InputStream stream)
          Gets a serializable back from a InputStream
protected  void init(java.io.InputStream in)
          used to intitiailize complete DB access.
private  void loadDriver()
          Loads the driver using the driver class name.
private  void readProps(java.io.InputStream input)
          Duplicate reader using stream instead of dile
private  void readProps(java.lang.String filePath)
          This method will be invoked by defauly by each persistence manager to read from a default location or one provided by the caller.
 java.io.Serializable remove(java.io.Serializable key)
          Removes existing entry.
 java.util.Map retrieveAll()
          Used to retrieve the persisted map back to its last known state
private  java.util.Map retrieveAll(java.sql.ResultSet result)
          Helper method to get get back the map
 void save(java.io.Serializable key, java.io.Serializable val)
          Saves NV pair as serializable object; creates if new, stores new state if already exists.
 void saveAll(java.util.Map map)
          Saves all row entries for the map to DB.
 void shutDown()
          Shutting down the database cleanly
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

protected final org.apache.commons.logging.Log log

props

private java.util.Properties props

driverName

private java.lang.String driverName

userName

private java.lang.String userName

userPass

private java.lang.String userPass

connStr

private java.lang.String connStr

createTable

private java.lang.String createTable

oracleDB

private final boolean oracleDB
See Also:
Constant Field Values

list

private java.util.Vector list

tabName

private static final java.lang.String tabName
See Also:
Constant Field Values

insertStat

private static final java.lang.String insertStat
See Also:
Constant Field Values

updateStat

private static final java.lang.String updateStat
See Also:
Constant Field Values

removeStat

private static final java.lang.String removeStat
See Also:
Constant Field Values

createTableGen

private static final java.lang.String createTableGen
See Also:
Constant Field Values

createTableOra

private static final java.lang.String createTableOra
See Also:
Constant Field Values
Constructor Detail

DBPersistenceManager

public DBPersistenceManager(java.lang.String filename)
                     throws java.lang.Exception
Default construct


DBPersistenceManager

public DBPersistenceManager(java.io.InputStream input)
                     throws java.lang.Exception
Duplicate constructor allowing inputstream

Method Detail

init

protected void init(java.io.InputStream in)
             throws java.lang.Exception
used to intitiailize complete DB access. THis method will use existing database to create schema (if it doesnt exist) and get PersistenceManager in usable condition


save

public void save(java.io.Serializable key,
                 java.io.Serializable val)
          throws CannotPersistException
Saves NV pair as serializable object; creates if new, stores new state if already exists.

Specified by:
save in interface PersistenceManager

remove

public java.io.Serializable remove(java.io.Serializable key)
                            throws CannotRemoveException
Removes existing entry.

Specified by:
remove in interface PersistenceManager

saveAll

public void saveAll(java.util.Map map)
             throws CannotPersistException
Saves all row entries for the map to DB.

Specified by:
saveAll in interface PersistenceManager

retrieveAll

public java.util.Map retrieveAll()
                          throws CannotRetrieveException
Used to retrieve the persisted map back to its last known state

Specified by:
retrieveAll in interface PersistenceManager

retrieveAll

private java.util.Map retrieveAll(java.sql.ResultSet result)
                           throws java.lang.Exception
Helper method to get get back the map


clear

public void clear()
           throws CannotRemoveException
Clears the key-cache as well as all entries

Specified by:
clear in interface PersistenceManager

shutDown

public void shutDown()
Shutting down the database cleanly

Specified by:
shutDown in interface PersistenceManager

addNewEntry

private void addNewEntry(java.io.Serializable key,
                         java.io.Serializable val)
                  throws CannotPersistException,
                         CannotConnectException
Used to enter a completely new row in to the current table


getBinaryInputStream

private java.io.InputStream getBinaryInputStream(java.io.Serializable ser)
                                          throws java.lang.Exception
Gets a binaryinputstream from a serialized object


getSerializable

private java.io.Serializable getSerializable(java.io.InputStream stream)
                                      throws java.lang.Exception
Gets a serializable back from a InputStream


addNewEntryGen

private void addNewEntryGen(java.io.Serializable key,
                            java.io.Serializable val)
                     throws CannotPersistException,
                            CannotConnectException
Used to enter a completely new row in to the current table


addNewEntryOra

private void addNewEntryOra(java.io.Serializable key,
                            java.io.Serializable val)
                     throws CannotPersistException,
                            CannotConnectException
Used to enter a completely new row in to the current table


entryExists

private boolean entryExists(java.io.Serializable key)
Cache checking


getBytes

private byte[] getBytes(java.io.Serializable ser)
                 throws java.lang.Exception
Conversion helper


readProps

private void readProps(java.lang.String filePath)
                throws java.lang.Exception
This method will be invoked by defauly by each persistence manager to read from a default location or one provided by the caller.


readProps

private void readProps(java.io.InputStream input)
                throws java.lang.Exception
Duplicate reader using stream instead of dile


loadDriver

private void loadDriver()
                 throws java.lang.Exception
Loads the driver using the driver class name. Drivers can be simply loaded by loading the class or by registering specifically using the JDBC DriverManager


getConnection

private java.sql.Connection getConnection()
                                   throws CannotConnectException
Once the driver is loaded, the DB is ready to be connected. This method provides a handle to connect to the DB.


closeConnection

private void closeConnection(java.sql.Connection conn)
Method is used for closing created connection. Pooling is not implemented currently, but will be made available as soon as this manager uses large number of transactions


createDBTables

private void createDBTables()
                     throws CannotCreateSchemaException,
                            CannotConnectException
Used to create table provided the DB instance


addSchemaToDB

private void addSchemaToDB(java.sql.Connection conn)
                    throws CannotCreateSchemaException
used to create required table within the DB