1 22 package org.enhydra.jdbc.standard; 23 24 import java.sql.Connection ; 25 import javax.transaction.xa.Xid ; 26 import javax.transaction.Status ; 27 28 35 public class StandardXAStatefulConnection { 36 37 public static int nextId; public int id; public Connection con; private int state; public StandardXADataSource dataSource; Xid xid; public boolean commitOnPrepare; long timeout; boolean timedOut; 47 50 public StandardXAStatefulConnection( 51 StandardXADataSource dataSource, 52 Connection con) { 53 this.con = con; 54 this.dataSource = dataSource; 55 id = ++nextId; this.state = Status.STATUS_NO_TRANSACTION; 57 dataSource.log.debug("StandardXAStatefulConnection created"); 58 } 59 60 63 synchronized void setState(int newState) { 64 dataSource.log.debug( 65 "StandardXAStatefulConnection:setState Stateful connection: " 66 + id 67 + " (state before=" 68 + state 69 + ")"); 70 state = newState; 71 dataSource.log.debug( 72 "StandardXAStatefulConnection:setState Stateful connection: " 73 + id 74 + " (state after=" 75 + state 76 + ")"); 77 } 78 79 int getState() { 80 return state; 81 } 82 83 public String toString() { 84 StringBuffer sb = new StringBuffer (); 85 sb.append("StandardXAStatefulConnection:\n"); 86 sb.append(" commit on prepare =<"+this.commitOnPrepare+ ">\n"); 87 sb.append(" timed out =<"+this.timedOut+ ">\n"); 88 sb.append(" id =<"+this.id+ ">\n"); 89 sb.append(" state =<"+this.state+ ">\n"); 90 sb.append(" time out =<"+this.timeout+ ">\n"); 91 sb.append(" xid =<"+this.xid+ ">\n"); 92 93 return sb.toString(); 94 } 95 } 96 | Popular Tags |