コード例 #1
0
 private void dissectProperty(int prefixLoc, String key, Properties properties) {
   TypeOverrides cfgOverride = null;
   int suffixLoc = -1;
   if (!key.equals(INFINISPAN_CONFIG_RESOURCE_PROP)
       && (suffixLoc = key.indexOf(CONFIG_SUFFIX)) != -1) {
     cfgOverride = getOrCreateConfig(prefixLoc, key, suffixLoc);
     cfgOverride.setCacheName(ConfigurationHelper.extractPropertyValue(key, properties));
   } else if ((suffixLoc = key.indexOf(STRATEGY_SUFFIX)) != -1) {
     cfgOverride = getOrCreateConfig(prefixLoc, key, suffixLoc);
     cfgOverride.setEvictionStrategy(ConfigurationHelper.extractPropertyValue(key, properties));
   } else if ((suffixLoc = key.indexOf(WAKE_UP_INTERVAL_SUFFIX)) != -1) {
     cfgOverride = getOrCreateConfig(prefixLoc, key, suffixLoc);
     cfgOverride.setEvictionWakeUpInterval(
         Long.parseLong(ConfigurationHelper.extractPropertyValue(key, properties)));
   } else if ((suffixLoc = key.indexOf(MAX_ENTRIES_SUFFIX)) != -1) {
     cfgOverride = getOrCreateConfig(prefixLoc, key, suffixLoc);
     cfgOverride.setEvictionMaxEntries(ConfigurationHelper.getInt(key, properties, -1));
   } else if ((suffixLoc = key.indexOf(LIFESPAN_SUFFIX)) != -1) {
     cfgOverride = getOrCreateConfig(prefixLoc, key, suffixLoc);
     cfgOverride.setExpirationLifespan(
         Long.parseLong(ConfigurationHelper.extractPropertyValue(key, properties)));
   } else if ((suffixLoc = key.indexOf(MAX_IDLE_SUFFIX)) != -1) {
     cfgOverride = getOrCreateConfig(prefixLoc, key, suffixLoc);
     cfgOverride.setExpirationMaxIdle(
         Long.parseLong(ConfigurationHelper.extractPropertyValue(key, properties)));
   }
   //      else if ((suffixLoc = key.indexOf(STATISTICS_SUFFIX)) != -1) {
   //         cfgOverride = getOrCreateConfig(prefixLoc, key, suffixLoc);
   //
   // cfgOverride.setExposeStatistics(Boolean.parseBoolean(PropertiesHelper.extractPropertyValue(key, properties)));
   //      }
 }
コード例 #2
0
  private Configuration configureTransactionManager(
      Configuration regionOverrides, String templateCacheName, Properties properties) {
    // Get existing configuration to verify whether a tm was configured or not.
    Configuration templateConfig =
        manager.defineConfiguration(templateCacheName, new Configuration());
    String ispnTmLookupClassName = templateConfig.getTransactionManagerLookupClass();
    String hbTmLookupClassName =
        org.hibernate.cache.infinispan.tm.HibernateTransactionManagerLookup.class.getName();
    if (ispnTmLookupClassName != null && !ispnTmLookupClassName.equals(hbTmLookupClassName)) {
      log.debug(
          "Infinispan is configured ["
              + ispnTmLookupClassName
              + "] with a different transaction manager lookup "
              + "class than Hibernate ["
              + hbTmLookupClassName
              + "]");
    } else {
      regionOverrides.setTransactionManagerLookup(transactionManagerlookup);
    }

    String useSyncProp =
        ConfigurationHelper.extractPropertyValue(INFINISPAN_USE_SYNCHRONIZATION_PROP, properties);
    boolean useSync =
        useSyncProp == null ? DEF_USE_SYNCHRONIZATION : Boolean.parseBoolean(useSyncProp);
    regionOverrides.fluent().transaction().useSynchronization(useSync);

    return regionOverrides;
  }
コード例 #3
0
 private TypeOverrides overrideStatisticsIfPresent(TypeOverrides override, Properties properties) {
   String globalStats =
       ConfigurationHelper.extractPropertyValue(INFINISPAN_GLOBAL_STATISTICS_PROP, properties);
   if (globalStats != null) {
     override.setExposeStatistics(Boolean.parseBoolean(globalStats));
   }
   return override;
 }
コード例 #4
0
 protected EmbeddedCacheManager createCacheManager(Properties properties) throws CacheException {
   try {
     String configLoc =
         ConfigurationHelper.getString(
             INFINISPAN_CONFIG_RESOURCE_PROP, properties, DEF_INFINISPAN_CONFIG_RESOURCE);
     EmbeddedCacheManager manager = new DefaultCacheManager(configLoc, false);
     String globalStats =
         ConfigurationHelper.extractPropertyValue(INFINISPAN_GLOBAL_STATISTICS_PROP, properties);
     if (globalStats != null) {
       manager
           .getGlobalConfiguration()
           .setExposeGlobalJmxStatistics(Boolean.parseBoolean(globalStats));
     }
     manager.start();
     return manager;
   } catch (IOException e) {
     throw new CacheException("Unable to create default cache manager", e);
   }
 }