fr.paris.lutece.util.sql
Class MultiPluginTransaction

java.lang.Object
  extended by fr.paris.lutece.util.sql.Transaction
      extended by fr.paris.lutece.util.sql.MultiPluginTransaction

public class MultiPluginTransaction
extends Transaction

Class to represents transactions that are shared between plugins. Such transactions will be shared by each plugin using the same pool than the one that created the transaction.


Field Summary
 
Fields inherited from class fr.paris.lutece.util.sql.Transaction
COMMITTED, OPENED, ROLLEDBACK
 
Constructor Summary
MultiPluginTransaction()
          Constructor
MultiPluginTransaction(Plugin plugin)
          Constructor
 
Method Summary
 void commit()
          Commit the transaction
 void decrementNbTransactionsOpened()
          Decrement the number of transactions by one.
 void executeStatement()
          Execute the current statement
 int getNbTransactionsOpened()
          Get the number of transactions that plugins tried to open simultaneously on the same pool.
 void incrementNbTransactionsOpened()
          Increment the number of transactions by one.
 PreparedStatement prepareStatement(String strSQL)
          Gets a prepared statement
 void rollback(Exception e)
          Rollback the transaction
 
Methods inherited from class fr.paris.lutece.util.sql.Transaction
beginTransaction, finalize, getConnection, getStatement, getStatus, rollback
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MultiPluginTransaction

public MultiPluginTransaction()
Constructor


MultiPluginTransaction

public MultiPluginTransaction(Plugin plugin)
Constructor

Parameters:
plugin - The plugin owner of the transaction
Method Detail

getNbTransactionsOpened

public int getNbTransactionsOpened()
Get the number of transactions that plugins tried to open simultaneously on the same pool. If the number if 1, then the transaction can be safely committed. If it is more than 1, then this number should be decremented and the transaction should not be committed.

Returns:
The number of transactions that was required

incrementNbTransactionsOpened

public void incrementNbTransactionsOpened()
Increment the number of transactions by one. See getNbTransactionsOpened() for more details.


decrementNbTransactionsOpened

public void decrementNbTransactionsOpened()
Decrement the number of transactions by one. See getNbTransactionsOpened() for more details.


prepareStatement

public PreparedStatement prepareStatement(String strSQL)
                                   throws SQLException
Gets a prepared statement

Overrides:
prepareStatement in class Transaction
Parameters:
strSQL - The SQL statement
Returns:
The prepared statement
Throws:
SQLException - If an SQL error occurs

executeStatement

public void executeStatement()
                      throws SQLException
Execute the current statement

Overrides:
executeStatement in class Transaction
Throws:
SQLException - If an SQL error occurs

commit

public void commit()
Commit the transaction

Overrides:
commit in class Transaction

rollback

public void rollback(Exception e)
Rollback the transaction

Overrides:
rollback in class Transaction
Parameters:
e - The exception that cause the rollback


Copyright © 2014 Mairie de Paris. All rights reserved.