jtaPropertyManager.getJTAEnvironmentBean().getTransactionSynchronizationRegistry(); InitialContext initContext = new InitialContext(); initContext.rebind(uniqueName, managedDataSource); initContext.rebind("java:comp/UserTransaction", com.arjuna.ats.jta.UserTransaction.userTransaction()); initContext.rebind("java:comp/TransactionManager", tm); initContext.rebind("java:comp/TransactionSynchronizationRegistry", tsr);
/** * Retrieve a reference to the transaction manager from the passed in JNDI initial context. * @param ctx The JNDI initial context to lookup the Transaction Manager reference from. * @return The transaction manager bound to the appropriate JNDI context. Returns null * if the transaction manager cannot be found. * */ public static javax.transaction.TransactionManager transactionManager (InitialContext ctx) { javax.transaction.TransactionManager transactionManager = null; try { transactionManager = (javax.transaction.TransactionManager)ctx.lookup(jtaPropertyManager.getJTAEnvironmentBean().getTransactionManagerJNDIContext()); } catch (Exception e) { jtaLogger.i18NLogger.warn_TransactionManager_jndifailure(e); } return transactionManager; }
/** * Retrieve a reference to the user transaction. * * @return The user transaction bound to the appropriate JNDI context */ public static synchronized javax.transaction.UserTransaction userTransaction (InitialContext ctx) { javax.transaction.UserTransaction userTransaction = null; try { userTransaction = (javax.transaction.UserTransaction) ctx.lookup(jtaPropertyManager.getJTAEnvironmentBean().getUserTransactionJNDIContext()); } catch (Exception e) { jtaLogger.i18NLogger.warn_UserTransaction_jndifailure(e); } return userTransaction; }
System.setProperty("ObjectStoreEnvironmentBean.objectStoreDir", _storeDir); System.setProperty("com.arjuna.ats.arjuna.objectstore.objectStoreDir", _storeDir); _jtaEnvironmentBean = jtaPropertyManager.getJTAEnvironmentBean(); _jtaEnvironmentBean.setTransactionManagerClassName(com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionManagerImple.class.getName()); _jtaEnvironmentBean.setUserTransactionClassName(com.arjuna.ats.internal.jta.transaction.arjunacore.UserTransactionImple.class.getName()); _jtaEnvironmentBean.setTransactionSynchronizationRegistryClassName(com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionSynchronizationRegistryImple.class.getName()); InitialContext initialContext = new InitialContext(); initialContext.bind("java:jboss/TransactionManager", _jtaEnvironmentBean.getTransactionManager()); initialContext.bind("java:jboss/UserTransaction", _jtaEnvironmentBean.getUserTransaction()); initialContext.bind("java:jboss/TransactionSynchronizationRegistry", _jtaEnvironmentBean.getTransactionSynchronizationRegistry());
@Test public void testRMFAILAfterCommit() throws Exception { jtaPropertyManager.getJTAEnvironmentBean().setNotifyCommitMarkableResourceRecoveryModuleOfCompleteBranches(false); final JdbcDataSource dataSource = new JdbcDataSource(); dataSource.setURL("jdbc:h2:mem:JBTMDB;MVCC=TRUE;DB_CLOSE_DELAY=-1"); new InitialContext().rebind("commitmarkableresource", dataSource);
/** * Retrieve a reference to the transaction manager from the passed in JNDI initial context. * @param ctx The JNDI initial context to lookup the Transaction Manager reference from. * @return The transaction manager bound to the appropriate JNDI context. Returns null * if the transaction manager cannot be found. * * @message com.arjuna.ats.jta.TransactionManager.jndifailure Failed to lookup transaction manager in JNDI context * @message com.arjuna.ats.jta.TransactionManager.generalfailure Failed to create instance of TransactionManager */ public static javax.transaction.TransactionManager transactionManager (InitialContext ctx) { javax.transaction.TransactionManager transactionManager = null; try { transactionManager = (javax.transaction.TransactionManager)ctx.lookup(jtaPropertyManager.getJTAEnvironmentBean().getJtaTMJNDIContext()); } catch (Exception e) { if ( jtaLogger.loggerI18N.isWarnEnabled() ) { jtaLogger.loggerI18N.warn("com.arjuna.ats.jta.TransactionManager.jndifailure", e); } } return transactionManager; }
/** * Retrieve a reference to the user transaction. * * @return The user transaction bound to the appropriate JNDI context * * @message com.arjuna.ats.jta.UserTransaction.jndifailure Failed to lookup * user transaction in JNDI context * @message com.arjuna.ats.jta.UserTransaction.generalfailure Failed to * create instance of UserTransaction */ public static synchronized javax.transaction.UserTransaction userTransaction (InitialContext ctx) { javax.transaction.UserTransaction userTransaction = null; try { userTransaction = (javax.transaction.UserTransaction) ctx.lookup(jtaPropertyManager.getJTAEnvironmentBean().getJtaUTJNDIContext()); } catch (Exception e) { if (jtaLogger.loggerI18N.isWarnEnabled()) { jtaLogger.loggerI18N.warn("com.arjuna.ats.jta.UserTransaction.jndifailure", e); } } return userTransaction; }
/** * Bind the currently configured transaction manager implementation to the JNDI * context passed in. * @param initialContext * @throws javax.naming.NamingException */ public static void bindJTATransactionManagerImplementation(InitialContext initialContext) throws javax.naming.NamingException { /** Look up and instantiate an instance of the configured transaction manager implementation **/ String tmImplementation = jtaPropertyManager.getJTAEnvironmentBean().getTransactionManagerClassName(); /** Bind the transaction manager to the appropriate JNDI context **/ Reference ref = new Reference(tmImplementation, tmImplementation, null); initialContext.rebind(getTransactionManagerJNDIName(), ref); }
/** * Bind the currently configured user transaction implementation to the passed in * JNDI context. * @param initialContext * @throws javax.naming.NamingException */ public static void bindJTAUserTransactionImplementation(InitialContext initialContext) throws javax.naming.NamingException { /** Look up and instantiate an instance of the configured user transaction implementation **/ String utImplementation = jtaPropertyManager.getJTAEnvironmentBean().getUserTransactionClassName(); /** Bind the user transaction to the appropriate JNDI context **/ Reference ref = new Reference(utImplementation, utImplementation, null); initialContext.rebind(getUserTransactionJNDIName(), ref); }
/** * Bind the currently configured transaction manager implementation to the JNDI * context passed in. * @param initialContext * @throws javax.naming.NamingException */ public static void bindJTATransactionManagerImplementation(InitialContext initialContext) throws javax.naming.NamingException { /** Look up and instantiate an instance of the configured transaction manager implementation **/ String tmImplementation = jtaPropertyManager.getJTAEnvironmentBean().getJtaTMImplementation(); /** Bind the transaction manager to the appropriate JNDI context **/ Reference ref = new Reference(tmImplementation, tmImplementation, null); initialContext.rebind(getTransactionManagerJNDIName(), ref); }
/** * Bind the currently configured user transaction implementation to the passed in * JNDI context. * @param initialContext * @throws javax.naming.NamingException */ public static void bindJTAUserTransactionImplementation(InitialContext initialContext) throws javax.naming.NamingException { /** Look up and instantiate an instance of the configured user transaction implementation **/ String utImplementation = jtaPropertyManager.getJTAEnvironmentBean().getJtaUTImplementation(); /** Bind the user transaction to the appropriate JNDI context **/ Reference ref = new Reference(utImplementation, utImplementation, null); initialContext.rebind(getUserTransactionJNDIName(), ref); }
/** * Bind the currently configured TransactionSynchronizationRegistry implementation to the passed in * JNDI context. * @param initialContext * @throws javax.naming.NamingException */ public static void bindJTATransactionSynchronizationRegistryImplementation(InitialContext initialContext) throws javax.naming.NamingException { /** Look up and instantiate an instance of the configured TransactionSynchronizationRegistry implementation **/ String tsrImplementation = jtaPropertyManager.getJTAEnvironmentBean().getTransactionSynchronizationRegistryClassName(); Object tsr = null; try { tsr = Class.forName(tsrImplementation).newInstance(); } catch(Exception e) { NamingException namingException = new ConfigurationException(jtaLogger.i18NLogger.get_utils_JNDIManager_tsr1()); namingException.setRootCause(e); throw namingException; } /** Bind the TransactionSynchronizationRegistry to the appropriate JNDI context **/ initialContext.rebind(getTransactionSynchronizationRegistryJNDIName(), tsr); }
@Override public Vote checkXid(Xid xid) { List<String> _xaRecoveryNodes = jtaPropertyManager.getJTAEnvironmentBean().getXaRecoveryNodes(); if(_xaRecoveryNodes == null || _xaRecoveryNodes.size() == 0) { jtaLogger.i18NLogger.info_recovery_noxanodes(); return Vote.ABSTAIN; } String nodeName = XATxConverter.getSubordinateNodeName(new XidImple(xid).getXID()); if (jtaLogger.logger.isDebugEnabled()) { jtaLogger.logger.debug("subordinate node name of " + xid + " is " + nodeName); } if (!_xaRecoveryNodes.contains(nodeName)) { // It either doesn't have a subordinate node name or isn't for this server return Vote.ABSTAIN; } // It does have an XID if (nodeName != null) { if (transactionLog(xid, nodeName)) { // it's owned by a logged transaction which // will recover it top down in due course return Vote.ABSTAIN; } else { return Vote.ROLLBACK; } } else { return Vote.ABSTAIN; } }
protected XARecoveryModule(XARecoveryResourceManager recoveryClass, String logName) { _logName = logName; _recoveryManagerClass = recoveryClass; if(_recoveryManagerClass == null) { jtaLogger.i18NLogger.warn_recovery_constfail(); } _xaRecoverers = jtaPropertyManager.getJTAEnvironmentBean().getXaResourceRecoveries(); _xaResourceOrphanFilters = jtaPropertyManager.getJTAEnvironmentBean().getXaResourceOrphanFilters(); }
/** * Bind the currently configured TransactionSynchronizationRegistry implementation to the passed in * JNDI context. * @param initialContext * @throws javax.naming.NamingException * * @message com.arjuna.ats.jta.utils.JNDIManager.tsr1 [message com.arjuna.ats.jta.utils.JNDIManager] Unable to instantiate TransactionSynchronizationRegistry implementation class! */ public static void bindJTATransactionSynchronizationRegistryImplementation(InitialContext initialContext) throws javax.naming.NamingException { /** Look up and instantiate an instance of the configured TransactionSynchronizationRegistry implementation **/ String tsrImplementation = jtaPropertyManager.getJTAEnvironmentBean().getJtaTSRImplementation(); Object tsr = null; try { tsr = Class.forName(tsrImplementation).newInstance(); } catch(Exception e) { NamingException namingException = new ConfigurationException(jtaLogger.logMesg.getString("com.arjuna.ats.jta.utils.JNDIManager.tsr1")); namingException.setRootCause(e); throw namingException; } /** Bind the TransactionSynchronizationRegistry to the appropriate JNDI context **/ initialContext.rebind(getTransactionSynchronizationRegistryJNDIName(), tsr); }
/** * Creates a new {@link TransactionContext}. * * @deprecated Please use the {@link #TransactionContext(Supplier, * Supplier)} constructor instead. */ @Deprecated public TransactionContext() { this(() -> jtaPropertyManager.getJTAEnvironmentBean().getTransactionManager(), () -> jtaPropertyManager.getJTAEnvironmentBean().getTransactionSynchronizationRegistry()); }
/** * Retrieve the singleton transaction manager reference. * @return The singleton transaction manager. Can return null if the instantiation failed. */ public synchronized static javax.transaction.TransactionManager transactionManager () { return jtaPropertyManager.getJTAEnvironmentBean().getTransactionManager(); } }
/** * Retrieve the singleton UserTransaction reference. * * @return The singleton UserTransaction reference. Can return null if the * instantiation failed. */ public static synchronized javax.transaction.UserTransaction userTransaction () { return jtaPropertyManager.getJTAEnvironmentBean().getUserTransaction(); } }
private final static String getTransactionSynchronizationRegistryJNDIName() { return jtaPropertyManager.getJTAEnvironmentBean().getTransactionSynchronizationRegistryJNDIContext(); } }
protected void resetUserTransactionAvailability(boolean previousUserTransactionAvailability) { UserTransactionOperationsProvider userTransactionProvider = jtaPropertyManager.getJTAEnvironmentBean().getUserTransactionOperationsProvider(); setAvailability(userTransactionProvider, previousUserTransactionAvailability); }