1 package org.enhydra.shark.repositorypersistence; 2 3 import org.enhydra.shark.api.*; 4 import com.lutris.appserver.server.sql.DBTransaction; 5 6 7 11 public class DODSRepositoryTransaction implements RepositoryTransaction { 12 13 private static int noOfCreations=0; 14 private static int noOfCommits=0; 15 private static int noOfRollbacks=0; 16 private static int noOfReleases=0; 17 18 private DBTransaction transaction; 19 20 public DODSRepositoryTransaction (DBTransaction transaction) { 21 if (DODSRepositoryPersistenceManager._debug_) { 22 synchronized (DODSRepositoryTransaction.class) { 23 noOfCreations++; 24 System.out.println("CREATING Repository T No"+noOfCreations); 25 } 26 } 28 this.transaction=transaction; 29 } 30 31 public DBTransaction getDODSTransaction () { 32 return transaction; 33 } 34 35 public void commit () throws TransactionException { 36 if (DODSRepositoryPersistenceManager._debug_) { 37 synchronized (DODSRepositoryTransaction.class) { 38 System.out.println("COMMITING Repository T "); 39 } 40 } 42 try { 43 transaction.commit(); 44 if (DODSRepositoryPersistenceManager._debug_) { 46 synchronized (DODSRepositoryTransaction.class) { 47 noOfCommits++; 48 System.out.println("COMMITED Repository T No"+noOfCommits); 49 } 50 } 52 } catch (Exception ex) { 53 ex.printStackTrace(); 54 throw new TransactionException(ex); 55 } 56 } 57 58 public void rollback () throws TransactionException { 59 try { 60 if (DODSRepositoryPersistenceManager._debug_) { 63 synchronized (DODSRepositoryTransaction.class) { 64 noOfRollbacks++; 65 System.out.println("ROLLING BACK Repository T"+noOfRollbacks); 66 } 67 } 69 } catch (Exception ex) { 70 if (DODSRepositoryPersistenceManager._debug_) { 71 System.out.println("ROLLING BACK Repository T FAILED"); 72 } 73 throw new TransactionException(ex); 74 } 75 } 76 77 public void release() throws TransactionException { 78 try { 79 transaction.release(); 80 if (DODSRepositoryPersistenceManager._debug_) { 81 synchronized (DODSRepositoryTransaction.class) { 82 noOfReleases++; 83 System.out.println("RELEASE Repository T "+noOfReleases); 84 } 85 } 86 } catch (Exception ex) { 87 if (DODSRepositoryPersistenceManager._debug_) { 88 System.out.println("RELEASE Repository T FAILED"); 89 } 90 throw new TransactionException(ex); 91 } 92 } 93 94 95 public static synchronized void info () { 96 if (noOfCreations != noOfReleases) { 97 System.err.println("PANIC!!!\nI've lost repository transcaton counts."); 98 } 99 System.err.println("MTCRE="+noOfCreations+", MTCOMM="+noOfCommits+", MTROLL="+noOfRollbacks+", MTREL="+noOfReleases); 100 } 101 102 } 103 104 | Popular Tags |