/** * Constructor * @param transactionManagerLookup the transaction manager lookup implementation * @param softLockManager the soft lock manager * @param transactionIdFactory the transaction ID factory * @param cache the cache * @param store the underlying store */ public XATransactionStore(TransactionManagerLookup transactionManagerLookup, SoftLockManager softLockManager, TransactionIDFactory transactionIdFactory, Ehcache cache, Store store, ElementValueComparator comparator) { super(store); this.transactionManagerLookup = transactionManagerLookup; this.transactionIdFactory = transactionIdFactory; this.comparator = comparator; if (transactionManagerLookup.getTransactionManager() == null) { throw new TransactionException("no JTA transaction manager could be located, cannot bind twopc cache with JTA"); } this.softLockManager = softLockManager; this.cache = cache; // this xaresource is for initial registration and recovery this.recoveryResource = new EhcacheXAResourceImpl(cache, underlyingStore, transactionManagerLookup, softLockManager, transactionIdFactory, comparator, commitObserver, rollbackObserver, recoveryObserver); transactionManagerLookup.register(recoveryResource, true); }
private XATransactionContext getTransactionContext() { try { Transaction transaction = getCurrentTransaction(); EhcacheXAResourceImpl xaResource = (EhcacheXAResourceImpl) transactionToXAResourceMap.get(transaction); if (xaResource == null) { return null; } XATransactionContext transactionContext = xaResource.getCurrentTransactionContext(); if (transactionContext == null) { transactionManagerLookup.register(xaResource, false); LOG.debug("creating new XA context"); transactionContext = xaResource.createTransactionContext(); xaResource.addTwoPcExecutionListener(new UnregisterXAResource()); } else { transactionContext = xaResource.getCurrentTransactionContext(); } LOG.debug("using XA context {}", transactionContext); return transactionContext; } catch (SystemException e) { throw new TransactionException("cannot get the current transaction", e); } catch (RollbackException e) { throw new TransactionException("transaction rolled back", e); } }
private XATransactionContext getOrCreateTransactionContext() { try { EhcacheXAResourceImpl xaResource = getOrCreateXAResource(); XATransactionContext transactionContext = xaResource.getCurrentTransactionContext(); if (transactionContext == null) { transactionManagerLookup.register(xaResource, false); LOG.debug("creating new XA context"); transactionContext = xaResource.createTransactionContext(); xaResource.addTwoPcExecutionListener(new UnregisterXAResource()); } else { transactionContext = xaResource.getCurrentTransactionContext(); } LOG.debug("using XA context {}", transactionContext); return transactionContext; } catch (SystemException e) { throw new TransactionException("cannot get the current transaction", e); } catch (RollbackException e) { throw new TransactionException("transaction rolled back", e); } }
transactionManagerLookup.register(xaRes, false); tx.enlistResource(xaRes); } else {
/** * Constructor * @param transactionManagerLookup the transaction manager lookup implementation * @param softLockManager the soft lock manager * @param transactionIdFactory the transaction ID factory * @param cache the cache * @param store the underlying store */ public XATransactionStore(TransactionManagerLookup transactionManagerLookup, SoftLockManager softLockManager, TransactionIDFactory transactionIdFactory, Ehcache cache, Store store, ElementValueComparator comparator) { super(store); this.transactionManagerLookup = transactionManagerLookup; this.transactionIdFactory = transactionIdFactory; this.comparator = comparator; if (transactionManagerLookup.getTransactionManager() == null) { throw new TransactionException("no JTA transaction manager could be located, cannot bind twopc cache with JTA"); } this.softLockManager = softLockManager; this.cache = cache; // this xaresource is for initial registration and recovery this.recoveryResource = new EhcacheXAResourceImpl(cache, underlyingStore, transactionManagerLookup, softLockManager, transactionIdFactory, comparator, commitObserver, rollbackObserver, recoveryObserver); transactionManagerLookup.register(recoveryResource, true); }
/** * Constructor * @param transactionManagerLookup the transaction manager lookup implementation * @param softLockManager the soft lock manager * @param transactionIdFactory the transaction ID factory * @param cache the cache * @param store the underlying store */ public XATransactionStore(TransactionManagerLookup transactionManagerLookup, SoftLockManager softLockManager, TransactionIDFactory transactionIdFactory, Ehcache cache, Store store, ElementValueComparator comparator) { super(store); this.transactionManagerLookup = transactionManagerLookup; this.transactionIdFactory = transactionIdFactory; this.comparator = comparator; if (transactionManagerLookup.getTransactionManager() == null) { throw new TransactionException("no JTA transaction manager could be located, cannot bind twopc cache with JTA"); } this.softLockManager = softLockManager; this.cache = cache; // this xaresource is for initial registration and recovery this.recoveryResource = new EhcacheXAResourceImpl(cache, underlyingStore, transactionManagerLookup, softLockManager, transactionIdFactory, comparator, commitObserver, rollbackObserver, recoveryObserver); transactionManagerLookup.register(recoveryResource, true); }
private XATransactionContext getTransactionContext() { try { Transaction transaction = getCurrentTransaction(); EhcacheXAResourceImpl xaResource = (EhcacheXAResourceImpl) transactionToXAResourceMap.get(transaction); if (xaResource == null) { return null; } XATransactionContext transactionContext = xaResource.getCurrentTransactionContext(); if (transactionContext == null) { transactionManagerLookup.register(xaResource, false); LOG.debug("creating new XA context"); transactionContext = xaResource.createTransactionContext(); xaResource.addTwoPcExecutionListener(new UnregisterXAResource()); } else { transactionContext = xaResource.getCurrentTransactionContext(); } LOG.debug("using XA context {}", transactionContext); return transactionContext; } catch (SystemException e) { throw new TransactionException("cannot get the current transaction", e); } catch (RollbackException e) { throw new TransactionException("transaction rolled back", e); } }
private XATransactionContext getTransactionContext() { try { Transaction transaction = getCurrentTransaction(); EhcacheXAResourceImpl xaResource = (EhcacheXAResourceImpl) transactionToXAResourceMap.get(transaction); if (xaResource == null) { return null; } XATransactionContext transactionContext = xaResource.getCurrentTransactionContext(); if (transactionContext == null) { transactionManagerLookup.register(xaResource, false); LOG.debug("creating new XA context"); transactionContext = xaResource.createTransactionContext(); xaResource.addTwoPcExecutionListener(new UnregisterXAResource()); } else { transactionContext = xaResource.getCurrentTransactionContext(); } LOG.debug("using XA context {}", transactionContext); return transactionContext; } catch (SystemException e) { throw new TransactionException("cannot get the current transaction", e); } catch (RollbackException e) { throw new TransactionException("transaction rolled back", e); } }
private XATransactionContext getTransactionContext() { try { Transaction transaction = getCurrentTransaction(); EhcacheXAResourceImpl xaResource = (EhcacheXAResourceImpl) transactionToXAResourceMap.get(transaction); if (xaResource == null) { return null; } XATransactionContext transactionContext = xaResource.getCurrentTransactionContext(); if (transactionContext == null) { transactionManagerLookup.register(xaResource, false); LOG.debug("creating new XA context"); transactionContext = xaResource.createTransactionContext(); xaResource.addTwoPcExecutionListener(new UnregisterXAResource()); } else { transactionContext = xaResource.getCurrentTransactionContext(); } LOG.debug("using XA context {}", transactionContext); return transactionContext; } catch (SystemException e) { throw new TransactionException("cannot get the current transaction", e); } catch (RollbackException e) { throw new TransactionException("transaction rolled back", e); } }
private XATransactionContext getOrCreateTransactionContext() { try { EhcacheXAResourceImpl xaResource = getOrCreateXAResource(); XATransactionContext transactionContext = xaResource.getCurrentTransactionContext(); if (transactionContext == null) { transactionManagerLookup.register(xaResource, false); LOG.debug("creating new XA context"); transactionContext = xaResource.createTransactionContext(); xaResource.addTwoPcExecutionListener(new UnregisterXAResource()); } else { transactionContext = xaResource.getCurrentTransactionContext(); } LOG.debug("using XA context {}", transactionContext); return transactionContext; } catch (SystemException e) { throw new TransactionException("cannot get the current transaction", e); } catch (RollbackException e) { throw new TransactionException("transaction rolled back", e); } }
private XATransactionContext getOrCreateTransactionContext() { try { EhcacheXAResourceImpl xaResource = getOrCreateXAResource(); XATransactionContext transactionContext = xaResource.getCurrentTransactionContext(); if (transactionContext == null) { transactionManagerLookup.register(xaResource, false); LOG.debug("creating new XA context"); transactionContext = xaResource.createTransactionContext(); xaResource.addTwoPcExecutionListener(new UnregisterXAResource()); } else { transactionContext = xaResource.getCurrentTransactionContext(); } LOG.debug("using XA context {}", transactionContext); return transactionContext; } catch (SystemException e) { throw new TransactionException("cannot get the current transaction", e); } catch (RollbackException e) { throw new TransactionException("transaction rolled back", e); } }
private XATransactionContext getOrCreateTransactionContext() { try { EhcacheXAResourceImpl xaResource = getOrCreateXAResource(); XATransactionContext transactionContext = xaResource.getCurrentTransactionContext(); if (transactionContext == null) { transactionManagerLookup.register(xaResource, false); LOG.debug("creating new XA context"); transactionContext = xaResource.createTransactionContext(); xaResource.addTwoPcExecutionListener(new UnregisterXAResource()); } else { transactionContext = xaResource.getCurrentTransactionContext(); } LOG.debug("using XA context {}", transactionContext); return transactionContext; } catch (SystemException e) { throw new TransactionException("cannot get the current transaction", e); } catch (RollbackException e) { throw new TransactionException("transaction rolled back", e); } }
transactionManagerLookup.register(xaRes, false); tx.enlistResource(xaRes); } else {
transactionManagerLookup.register(xaRes, false); tx.enlistResource(xaRes); } else {
transactionManagerLookup.register(xaRes, false); tx.enlistResource(xaRes); } else {
private Store makeXaStrictTransactionalIfNeeded(Store clusteredStore, ReadWriteCopyStrategy<Element> copyStrategy) { Store wrappedStore; if (configuration.isXaStrictTransactional()) { if (transactionManagerLookup.getTransactionManager() == null) { throw new CacheException("You've configured cache " + cacheManager.getName() + "." + configuration.getName() + " to be transactional, but no TransactionManager could be found!"); } //set xa enabled if (configuration.isTerracottaClustered()) { configuration.getTerracottaConfiguration().setCacheXA(true); } SoftLockManager softLockManager = cacheManager.createSoftLockManager(this); TransactionIDFactory transactionIDFactory = cacheManager.getOrCreateTransactionIDFactory(); // this xaresource is for initial registration and recovery xaResource = new EhcacheXAResourceImpl(this, clusteredStore, transactionManagerLookup, softLockManager, transactionIDFactory, copyStrategy); transactionManagerLookup.register(xaResource, true); wrappedStore = new XATransactionStore(transactionManagerLookup, softLockManager, transactionIDFactory, this, clusteredStore, copyStrategy); } else { wrappedStore = clusteredStore; } return wrappedStore; }