# This patch file was generated by NetBeans IDE # Following Index: paths are relative to: /export/home/workspace/glassfish/jts/src/java/com/sun/jts/CosTransactions # This patch can be applied using context Tools: Patch action on respective folder. # It uses platform neutral UTF-8 encoding and \n newlines. # Above lines and this line are ignored by the patching process. Index: XATerminatorImpl.java *** /export/home/workspace/glassfish/jts/src/java/com/sun/jts/CosTransactions/XATerminatorImpl.java Base (1.4) --- /export/home/workspace/glassfish/jts/src/java/com/sun/jts/CosTransactions/XATerminatorImpl.java Locally Modified (Based On 1.4) *************** *** 50,55 **** --- 50,60 ---- import org.omg.CosTransactions.Vote; import org.omg.CosTransactions.HeuristicMixed; + import com.sun.enterprise.transaction.TransactionImport; + import javax.naming.Context; + import javax.naming.InitialContext; + import javax.naming.NamingException; + /** * This is used for transaction completion and crash recovery flows. * *************** *** 96,102 **** // that is being committed as specified in // in method javax.Synchronization.beforeCompletion try { ! CurrentTransaction.recreate(tid, 0); } catch (Throwable e) { // failed check for concurrent activity XAException xaExc = new XAException(XAException.XAER_PROTO); --- 101,108 ---- // that is being committed as specified in // in method javax.Synchronization.beforeCompletion try { ! //CurrentTransaction.recreate(tid, 0); ! recreate(xid, 0); } catch (Throwable e) { // failed check for concurrent activity XAException xaExc = new XAException(XAException.XAER_PROTO); *************** *** 160,166 **** // Complete full transactional context created for // beforeCompletion calls in prepare phase of one phase commit. try { ! CurrentTransaction.release(tid); } catch (Throwable t) { if (!exceptionFlag) { XAException xaExc = new XAException(XAException.XAER_PROTO); --- 166,173 ---- // Complete full transactional context created for // beforeCompletion calls in prepare phase of one phase commit. try { ! // CurrentTransaction.release(tid); ! release(xid); } catch (Throwable t) { if (!exceptionFlag) { XAException xaExc = new XAException(XAException.XAER_PROTO); *************** *** 220,226 **** // executed with the transaction context of the transaction // that is being committed as specified in // in method javax.Synchronization.beforeCompletion ! CurrentTransaction.recreate(tid, 0); } catch (Throwable e) { // failed check for concurrent activity for transaction tid. XAException xaExc = new XAException(XAException.XAER_PROTO); --- 227,234 ---- // executed with the transaction context of the transaction // that is being committed as specified in // in method javax.Synchronization.beforeCompletion ! //CurrentTransaction.recreate(tid, 0); ! recreate(xid, 0); } catch (Throwable e) { // failed check for concurrent activity for transaction tid. XAException xaExc = new XAException(XAException.XAER_PROTO); *************** *** 264,270 **** throw xaExc; } finally { try { ! CurrentTransaction.release(tid); } catch (Throwable t) { if (!exceptionFlag) { errorCode = XAException.XAER_PROTO; --- 272,279 ---- throw xaExc; } finally { try { ! //CurrentTransaction.release(tid); ! release(xid); } catch (Throwable t) { if (!exceptionFlag) { errorCode = XAException.XAER_PROTO; *************** *** 365,373 **** --- 374,413 ---- } } } + + static private final TransactionImport tim = getTransactionImportManager(); + + // no standardized JNDI name exists across as implementations for TM, this is Sun App Server specific. + private static final String AS_TXN_MGR_JNDI_NAME = "java:appserver/TransactionManager"; + + static private Object jndiLookup(final String jndiName) { + Object result = null; + try { + final Context ctx = new InitialContext(); + result = ctx.lookup(jndiName); + } catch (NamingException e) { } + return result; } + static private TransactionImport getTransactionImportManager() { + return (TransactionImport)jndiLookup(AS_TXN_MGR_JNDI_NAME); + } + static private void recreate(Xid xid, int timeout) { + if (tim != null) { + tim.recreate(xid, timeout); + } + } + + static private void release(Xid xid) { + if (tim != null) { + tim.release(xid); + } + } + } + +