org.edg.security.voms.database.connection
Class Update

java.lang.Object
  |
  +--org.edg.security.voms.database.connection.ConnectionWrapper
        |
        +--org.edg.security.voms.database.connection.ClientConnection
              |
              +--org.edg.security.voms.database.connection.Update

public final class Update
extends ClientConnection

A subclass of ConnectionWrapper for updates with convenient transaction management.

Version:
$Name: v0_7_0 $
Author:
Karoly Lorentey

Field Summary
private static long lastRealtimeTimestamp
          The last time we created a transaction timestamp.
private static long lastRealtimeTransaction
          The last transaction id that has a timestamp.
private static org.apache.log4j.Logger log
          Logger.
private static Sequence seq
          The sequence object for accessing the database-wide transaction id.
private  long transaction
          Current transaction id.
 
Fields inherited from class org.edg.security.voms.database.connection.ClientConnection
 
Fields inherited from class org.edg.security.voms.database.connection.ConnectionWrapper
conn, id, inTransaction, pool, stmts
 
Constructor Summary
Update(java.sql.Connection conn, ConnectionPool pool, int id)
          Creates a new Update.
 
Method Summary
static Update begin()
          Allocates an Update from the connection pool, and starts a transaction on it.
(package private)  void beginTransaction()
          Starts a new transaction.
 void commit()
          Commit the current transaction, and release this connection.
 long getTransaction()
          Returns the transaction value.
 boolean isInTransaction(long id)
          Return true if the wrapper is still in the specified transaction.
 boolean isReadonly()
           
 void rollback()
          Roll back the current transaction, and release this connection.
static void writeTransactionTimestamp()
          Unconditionally write out a timestamp record with the current transaction number.
 void writeTransactionTimestampIfNecessary()
          Write a new timestamp record for the last transaction if necessary.
 
Methods inherited from class org.edg.security.voms.database.connection.ClientConnection
endTransaction, getClient, getClientId
 
Methods inherited from class org.edg.security.voms.database.connection.ConnectionWrapper
close, getConnection, getStatement, isClosed, isDirty, isFunctional, isInTransaction, setDirty, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

seq

private static Sequence seq
The sequence object for accessing the database-wide transaction id.


transaction

private long transaction
Current transaction id.


log

private static org.apache.log4j.Logger log
Logger.


lastRealtimeTimestamp

private static long lastRealtimeTimestamp
The last time we created a transaction timestamp.


lastRealtimeTransaction

private static long lastRealtimeTransaction
The last transaction id that has a timestamp.

Constructor Detail

Update

public Update(java.sql.Connection conn,
              ConnectionPool pool,
              int id)
Creates a new Update.

Method Detail

begin

public static Update begin()
                    throws VOMSException
Allocates an Update from the connection pool, and starts a transaction on it.

Returns:
the allocated Update.
VOMSException

beginTransaction

void beginTransaction()
                throws VOMSException
Starts a new transaction.

Overrides:
beginTransaction in class ClientConnection
Returns:
the transaction id of the new transaction.
VOMSException

commit

public void commit()
            throws GeneralDatabaseException
Commit the current transaction, and release this connection.

GeneralDatabaseException

rollback

public void rollback()
Roll back the current transaction, and release this connection.


isInTransaction

public boolean isInTransaction(long id)
Return true if the wrapper is still in the specified transaction.


getTransaction

public long getTransaction()
Returns the transaction value.


writeTransactionTimestamp

public static void writeTransactionTimestamp()
Unconditionally write out a timestamp record with the current transaction number.


writeTransactionTimestampIfNecessary

public void writeTransactionTimestampIfNecessary()
Write a new timestamp record for the last transaction if necessary. This is automatically called at the start of each new transaction.


isReadonly

public boolean isReadonly()
Specified by:
isReadonly in class ClientConnection