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