net.sf.ehcache.Cache.getTransactionManagerLookup()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(11.9k)|赞(0)|评价(0)|浏览(121)

本文整理了Java中net.sf.ehcache.Cache.getTransactionManagerLookup()方法的一些代码示例,展示了Cache.getTransactionManagerLookup()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Cache.getTransactionManagerLookup()方法的具体详情如下:
包路径:net.sf.ehcache.Cache
类名称:Cache
方法名:getTransactionManagerLookup

Cache.getTransactionManagerLookup介绍

[英]Get the TransactionManagerLookup implementation used to lookup the TransactionManager. This is generally only set for XA transactional caches
[中]获取用于查找TransactionManager的TransactionManagerLookup实现。这通常仅为XA事务缓存设置

代码示例

代码示例来源:origin: net.sf.ehcache/ehcache

/**
 * Sets the TransactionManagerLookup that needs to be used for this cache to lookup the TransactionManager
 * This needs to be set before {@link Cache#initialise()} is called
 * @param lookup The {@link net.sf.ehcache.transaction.manager.TransactionManagerLookup} instance
 */
public void setTransactionManagerLookup(TransactionManagerLookup lookup) {
  TransactionManagerLookup oldValue = getTransactionManagerLookup();
  this.transactionManagerLookup = lookup;
  firePropertyChange("TransactionManagerLookup", oldValue, lookup);
}

代码示例来源:origin: net.sf.ehcache/ehcache

/**
 * Check if a transaction has begun on the current thread if the cache is configured as
 * transactional, otherwise always return false.
 * @param cache the cache to check if a transaction started for
 * @return true if the cache is transactional and a transaction started, false otherwise
 * @throws CacheException if anything wrong happens
 */
public static boolean isTransactionStarted(Ehcache cache) throws CacheException {
  try {
    switch (cache.getCacheConfiguration().getTransactionalMode()) {
      case LOCAL:
        TransactionController ctrl = cache.getCacheManager().getTransactionController();
        return ctrl.getCurrentTransactionContext() != null;
      case XA:
      case XA_STRICT:
        Object tm = ((net.sf.ehcache.Cache) cache).getTransactionManagerLookup().getTransactionManager();
        return ((Integer) tm.getClass().getMethod("getStatus").invoke(tm)) != XA_STATUS_NO_TRANSACTION;
      case OFF:
      default:
        return false;
    }
  } catch (Exception e) {
    e.printStackTrace();
    throw new CacheException("error checking if transaction started: " + e);
  }
}

代码示例来源:origin: net.sf.ehcache/ehcache

/**
 * Begin a transaction on the current thread if the cache is configured as transactional,
 * otherwise this method does nothing.
 *
 * @param cache the cache to begin a transaction for
 * @throws CacheException if anything wrong happens
 */
public static void beginTransactionIfNeeded(Ehcache cache) throws CacheException {
  try {
    switch (cache.getCacheConfiguration().getTransactionalMode()) {
      case LOCAL:
        TransactionController ctrl = cache.getCacheManager().getTransactionController();
        ctrl.begin();
        break;
      case XA:
      case XA_STRICT:
        Object tm = ((net.sf.ehcache.Cache) cache).getTransactionManagerLookup().getTransactionManager();
        tm.getClass().getMethod("begin").invoke(tm);
        break;
      case OFF:
      default:
        break;
    }
  } catch (Exception e) {
    e.printStackTrace();
    throw new CacheException("error beginning transaction:" + e);
  }
}

代码示例来源:origin: net.sf.ehcache/ehcache

Object tm = ((net.sf.ehcache.Cache) cache).getTransactionManagerLookup().getTransactionManager();
tm.getClass().getMethod("commit").invoke(tm);
break;

代码示例来源:origin: org.sonatype.nexus.bundles/org.sonatype.nexus.bundles.ehcache

/**
 * Sets the TransactionManagerLookup that needs to be used for this cache to lookup the TransactionManager
 * This needs to be set before {@link Cache#initialise()} is called
 * @param lookup The {@link net.sf.ehcache.transaction.manager.TransactionManagerLookup} instance
 */
public void setTransactionManagerLookup(TransactionManagerLookup lookup) {
  TransactionManagerLookup oldValue = getTransactionManagerLookup();
  this.transactionManagerLookup = lookup;
  firePropertyChange("TransactionManagerLookup", oldValue, lookup);
}

代码示例来源:origin: net.sf.ehcache.internal/ehcache-core

/**
 * Sets the TransactionManagerLookup that needs to be used for this cache to lookup the TransactionManager
 * This needs to be set before {@link Cache#initialise()} is called
 * @param lookup The {@link net.sf.ehcache.transaction.manager.TransactionManagerLookup} instance
 */
public void setTransactionManagerLookup(TransactionManagerLookup lookup) {
  TransactionManagerLookup oldValue = getTransactionManagerLookup();
  this.transactionManagerLookup = lookup;
  firePropertyChange("TransactionManagerLookup", oldValue, lookup);
}

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.ehcache

/**
 * Sets the TransactionManagerLookup that needs to be used for this cache to lookup the TransactionManager
 * This needs to be set before {@link Cache#initialise()} is called
 * @param lookup The {@link net.sf.ehcache.transaction.manager.TransactionManagerLookup} instance
 */
public void setTransactionManagerLookup(TransactionManagerLookup lookup) {
  TransactionManagerLookup oldValue = getTransactionManagerLookup();
  this.transactionManagerLookup = lookup;
  firePropertyChange("TransactionManagerLookup", oldValue, lookup);
}

代码示例来源:origin: org.nuxeo.ecm.core/nuxeo-core-storage-sql

protected boolean hasTransaction() {
  TransactionManagerLookup transactionManagerLookup = cache.getTransactionManagerLookup();
  if (transactionManagerLookup == null) {
    return false;
  }
  TransactionManager transactionManager = transactionManagerLookup.getTransactionManager();
  if (transactionManager == null) {
    return false;
  }
  Transaction transaction;
  try {
    transaction = transactionManager.getTransaction();
  } catch (SystemException e) {
    throw new RuntimeException(e);
  }
  return transaction != null;
}

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.ehcache

/**
 * Check if a transaction has begun on the current thread if the cache is configured as
 * transactional, otherwise always return false.
 * @param cache the cache to check if a transaction started for
 * @return true if the cache is transactional and a transaction started, false otherwise
 * @throws CacheException if anything wrong happens
 */
public static boolean isTransactionStarted(Ehcache cache) throws CacheException {
  try {
    switch (cache.getCacheConfiguration().getTransactionalMode()) {
      case LOCAL:
        TransactionController ctrl = cache.getCacheManager().getTransactionController();
        return ctrl.getCurrentTransactionContext() != null;
      case XA:
      case XA_STRICT:
        Object tm = ((net.sf.ehcache.Cache) cache).getTransactionManagerLookup().getTransactionManager();
        return ((Integer) tm.getClass().getMethod("getStatus").invoke(tm)) != XA_STATUS_NO_TRANSACTION;
      case OFF:
      default:
        return false;
    }
  } catch (Exception e) {
    e.printStackTrace();
    throw new CacheException("error checking if transaction started: " + e);
  }
}

代码示例来源:origin: net.sf.ehcache.internal/ehcache-core

Object tm = ((net.sf.ehcache.Cache) cache).getTransactionManagerLookup().getTransactionManager();
tm.getClass().getMethod("commit").invoke(tm);
break;

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.ehcache

Object tm = ((net.sf.ehcache.Cache) cache).getTransactionManagerLookup().getTransactionManager();
tm.getClass().getMethod("commit").invoke(tm);
break;

代码示例来源:origin: org.sonatype.nexus.bundles/org.sonatype.nexus.bundles.ehcache

/**
 * Begin a transaction on the current thread if the cache is configured as transactional,
 * otherwise this method does nothing.
 *
 * @param cache the cache to begin a transaction for
 * @throws CacheException if anything wrong happens
 */
public static void beginTransactionIfNeeded(Ehcache cache) throws CacheException {
  try {
    switch (cache.getCacheConfiguration().getTransactionalMode()) {
      case LOCAL:
        TransactionController ctrl = cache.getCacheManager().getTransactionController();
        ctrl.begin();
        break;
      case XA:
      case XA_STRICT:
        Object tm = ((net.sf.ehcache.Cache) cache).getTransactionManagerLookup().getTransactionManager();
        tm.getClass().getMethod("begin").invoke(tm);
        break;
      case OFF:
      default:
        break;
    }
  } catch (Exception e) {
    e.printStackTrace();
    throw new CacheException("error beginning transaction:" + e);
  }
}

代码示例来源:origin: net.sf.ehcache.internal/ehcache-core

/**
 * Begin a transaction on the current thread if the cache is configured as transactional,
 * otherwise this method does nothing.
 *
 * @param cache the cache to begin a transaction for
 * @throws CacheException if anything wrong happens
 */
public static void beginTransactionIfNeeded(Ehcache cache) throws CacheException {
  try {
    switch (cache.getCacheConfiguration().getTransactionalMode()) {
      case LOCAL:
        TransactionController ctrl = cache.getCacheManager().getTransactionController();
        ctrl.begin();
        break;
      case XA:
      case XA_STRICT:
        Object tm = ((net.sf.ehcache.Cache) cache).getTransactionManagerLookup().getTransactionManager();
        tm.getClass().getMethod("begin").invoke(tm);
        break;
      case OFF:
      default:
        break;
    }
  } catch (Exception e) {
    e.printStackTrace();
    throw new CacheException("error beginning transaction:" + e);
  }
}

代码示例来源:origin: net.sf.ehcache.internal/ehcache-core

/**
 * Check if a transaction has begun on the current thread if the cache is configured as
 * transactional, otherwise always return false.
 * @param cache the cache to check if a transaction started for
 * @return true if the cache is transactional and a transaction started, false otherwise
 * @throws CacheException if anything wrong happens
 */
public static boolean isTransactionStarted(Ehcache cache) throws CacheException {
  try {
    switch (cache.getCacheConfiguration().getTransactionalMode()) {
      case LOCAL:
        TransactionController ctrl = cache.getCacheManager().getTransactionController();
        return ctrl.getCurrentTransactionContext() != null;
      case XA:
      case XA_STRICT:
        Object tm = ((net.sf.ehcache.Cache) cache).getTransactionManagerLookup().getTransactionManager();
        return ((Integer) tm.getClass().getMethod("getStatus").invoke(tm)) != XA_STATUS_NO_TRANSACTION;
      case OFF:
      default:
        return false;
    }
  } catch (Exception e) {
    e.printStackTrace();
    throw new CacheException("error checking if transaction started: " + e);
  }
}

代码示例来源:origin: org.sonatype.nexus.bundles/org.sonatype.nexus.bundles.ehcache

/**
 * Check if a transaction has begun on the current thread if the cache is configured as
 * transactional, otherwise always return false.
 * @param cache the cache to check if a transaction started for
 * @return true if the cache is transactional and a transaction started, false otherwise
 * @throws CacheException if anything wrong happens
 */
public static boolean isTransactionStarted(Ehcache cache) throws CacheException {
  try {
    switch (cache.getCacheConfiguration().getTransactionalMode()) {
      case LOCAL:
        TransactionController ctrl = cache.getCacheManager().getTransactionController();
        return ctrl.getCurrentTransactionContext() != null;
      case XA:
      case XA_STRICT:
        Object tm = ((net.sf.ehcache.Cache) cache).getTransactionManagerLookup().getTransactionManager();
        return ((Integer) tm.getClass().getMethod("getStatus").invoke(tm)) != XA_STATUS_NO_TRANSACTION;
      case OFF:
      default:
        return false;
    }
  } catch (Exception e) {
    e.printStackTrace();
    throw new CacheException("error checking if transaction started: " + e);
  }
}

代码示例来源:origin: org.sonatype.nexus.bundles/org.sonatype.nexus.bundles.ehcache

Object tm = ((net.sf.ehcache.Cache) cache).getTransactionManagerLookup().getTransactionManager();
tm.getClass().getMethod("commit").invoke(tm);
break;

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.ehcache

/**
 * Begin a transaction on the current thread if the cache is configured as transactional,
 * otherwise this method does nothing.
 *
 * @param cache the cache to begin a transaction for
 * @throws CacheException if anything wrong happens
 */
public static void beginTransactionIfNeeded(Ehcache cache) throws CacheException {
  try {
    switch (cache.getCacheConfiguration().getTransactionalMode()) {
      case LOCAL:
        TransactionController ctrl = cache.getCacheManager().getTransactionController();
        ctrl.begin();
        break;
      case XA:
      case XA_STRICT:
        Object tm = ((net.sf.ehcache.Cache) cache).getTransactionManagerLookup().getTransactionManager();
        tm.getClass().getMethod("begin").invoke(tm);
        break;
      case OFF:
      default:
        break;
    }
  } catch (Exception e) {
    e.printStackTrace();
    throw new CacheException("error beginning transaction:" + e);
  }
}

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.ehcache

private synchronized void initializeNonstopStore() {
  if (nonstopStore == null) {
    if (!cache.getCacheConfiguration().isTerracottaClustered()) {
      throw new AssertionError("NonstopStore supported for Terracotta clustered caches only");
    }
    if (!cache.getCacheConfiguration().getTerracottaConfiguration().isNonstopEnabled()) {
      throw new AssertionError("Nonstop is not enabled");
    }
    nonstopStore = new NonstopStoreImpl(this, cache.getCacheCluster(), cache.getCacheConfiguration()
        .getTerracottaConfiguration().getNonstopConfiguration(), cache.getCacheConfiguration().getTransactionalMode(),
        cache.getTransactionManagerLookup());
  }
}

相关文章

Cache类方法