1 17 18 package org.apache.geronimo.transaction.context; 19 20 import javax.transaction.Synchronization ; 21 import javax.transaction.xa.XAResource ; 22 23 26 class UnspecifiedTransactionContext extends AbstractTransactionContext { 27 private boolean active = true; 28 private boolean failed = false; 29 30 public UnspecifiedTransactionContext() { 31 } 32 33 public boolean isInheritable() { 34 return false; 35 } 36 37 public boolean isActive() { 38 return active; 39 } 40 41 public boolean enlistResource(XAResource xaResource){ 42 throw new IllegalStateException ("There is no transaction in progress."); 43 } 44 45 public boolean delistResource(XAResource xaResource, int flag) { 46 throw new IllegalStateException ("There is no transaction in progress."); 47 } 48 49 public void registerSynchronization(Synchronization synchronization) { 50 throw new IllegalStateException ("There is no transaction in progress."); 51 } 52 53 public boolean getRollbackOnly() { 54 return failed; 55 } 56 57 public void setRollbackOnly() { 58 this.failed = true; 59 } 60 61 public void suspend() { 62 } 63 64 public void resume() { 65 } 66 67 public boolean commit() { 68 complete(); 69 return true; 70 } 71 72 public void rollback() { 73 setRollbackOnly(); 74 complete(); 75 } 76 77 private void complete() { 78 try { 79 if (!failed) { 80 flushState(); 81 } 82 } catch (Error e) { 83 throw e; 84 } catch (RuntimeException re) { 85 throw re; 86 } catch (Throwable e) { 87 log.error("Unable to flush state, continuing", e); 88 } finally { 89 active = false; 90 unassociateAll(); 91 } 92 } 93 } 94 | Popular Tags |