1 4 package org.enhydra.shark.appmappersistence; 5 6 import org.enhydra.shark.api.ApplicationMappingTransaction; 7 import org.enhydra.shark.api.TransactionException; 8 9 import com.lutris.appserver.server.sql.DBTransaction; 10 11 16 public class DODSApplicationMappingTransaction implements ApplicationMappingTransaction { 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 DODSApplicationMappingTransaction (DBTransaction transaction) { 26 if (DODSApplicationMappingMgr._debug_) { 27 synchronized (DODSApplicationMappingTransaction.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 (DODSApplicationMappingMgr._debug_) { 42 synchronized (DODSApplicationMappingTransaction.class) { 43 System.out.println("COMMITING Mapping T "); 44 } 45 } 47 try { 48 transaction.commit(); 49 if (DODSApplicationMappingMgr._debug_) { 51 synchronized (DODSApplicationMappingTransaction.class) { 52 noOfCommits++; 53 System.out.println("COMMITED Mapping T No"+noOfCommits); 54 } 55 } 57 } catch (Exception ex) { 58 ex.printStackTrace(); 59 throw new TransactionException(ex); 60 } 61 } 62 63 public void rollback () throws TransactionException { 64 try { 65 if (DODSApplicationMappingMgr._debug_) { 68 synchronized (DODSApplicationMappingTransaction.class) { 69 noOfRollbacks++; 70 System.out.println("ROLLING BACK Mapping T"+noOfRollbacks); 71 } 72 } 74 } catch (Exception ex) { 75 if (DODSApplicationMappingMgr._debug_) { 76 System.out.println("ROLLING BACK Mapping T FAILED"); 77 } 78 throw new TransactionException(ex); 79 } 80 } 81 82 public void release() throws TransactionException { 83 try { 84 transaction.release(); 85 if (DODSApplicationMappingMgr._debug_) { 86 synchronized (DODSApplicationMappingTransaction.class) { 87 noOfReleases++; 88 System.out.println("RELEASE Mapping T "+noOfReleases); 89 } 90 } 91 } catch (Exception ex) { 92 if (DODSApplicationMappingMgr._debug_) { 93 System.out.println("RELEASE Mapping T FAILED"); 94 } 95 throw new TransactionException(ex); 96 } 97 } 98 99 100 public static synchronized void info () { 101 if (noOfCreations != noOfReleases) { 102 System.err.println("PANIC!!!\nI've lost mapping transcaton counts."); 103 } 104 System.err.println("MTCRE="+noOfCreations+", MTCOMM="+noOfCommits+", MTROLL="+noOfRollbacks+", MTREL="+noOfReleases); 105 } 106 107 } 108 | Popular Tags |