当前位置: 首页>>代码示例>>Java>>正文


Java MutableConfiguration类代码示例

本文整理汇总了Java中javax.cache.configuration.MutableConfiguration的典型用法代码示例。如果您正苦于以下问题:Java MutableConfiguration类的具体用法?Java MutableConfiguration怎么用?Java MutableConfiguration使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


MutableConfiguration类属于javax.cache.configuration包,在下文中一共展示了MutableConfiguration类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: JCacheConfiguration

import javax.cache.configuration.MutableConfiguration; //导入依赖的package包/类
public JCacheConfiguration(Configuration<K, V> configuration) {
    if (configuration != null) {
        if (configuration instanceof RedissonConfiguration) {
            configuration = ((RedissonConfiguration<K, V>)configuration).getJcacheConfig();
        }
        
        if (configuration instanceof CompleteConfiguration) {
            delegate = new MutableConfiguration<K, V>((CompleteConfiguration<K, V>) configuration);
        } else {
            delegate = new MutableConfiguration<K, V>();
            delegate.setStoreByValue(configuration.isStoreByValue());
            delegate.setTypes(configuration.getKeyType(), configuration.getValueType());
        }
    } else {
        delegate = new MutableConfiguration<K, V>();
    }
    
    this.expiryPolicy = delegate.getExpiryPolicyFactory().create();
}
 
开发者ID:qq1588518,项目名称:JRediClients,代码行数:20,代码来源:JCacheConfiguration.java

示例2: configure

import javax.cache.configuration.MutableConfiguration; //导入依赖的package包/类
@Override
public void configure(Binder binder) {

    //programmatically configured cache
    Configuration<String, String> programmaticCache =
            new MutableConfiguration<String, String>()
                    .setTypes(String.class, String.class)
                    .setExpiryPolicyFactory(AccessedExpiryPolicy.factoryOf(Duration.ONE_HOUR))
                    .setReadThrough(true)
                    .setWriteThrough(true)
                    .addCacheEntryListenerConfiguration(new MyCache2EntryListenerConfiguration());

    //contribute the cache into BQ
    JCacheModule.extend(binder).setConfiguration("myCache2", programmaticCache);

    BQCoreModule.extend(binder).addCommand(DemoHazelcastCommand.class);
}
 
开发者ID:bootique-examples,项目名称:bootique-jcache-demo,代码行数:18,代码来源:Application.java

示例3: cacheExposesMetrics

import javax.cache.configuration.MutableConfiguration; //导入依赖的package包/类
@ParameterizedTest
@MethodSource("cachingProviders")
void cacheExposesMetrics(CachingProvider provider) {
    CacheManager cacheManager = provider.getCacheManager();

    MutableConfiguration<Integer, String> configuration = new MutableConfiguration<>();
    configuration.setTypes(Integer.class, String.class)
        .setExpiryPolicyFactory(AccessedExpiryPolicy.factoryOf(ONE_HOUR))
        .setStatisticsEnabled(true);

    Cache<Integer, String> cache = cacheManager.createCache("a", configuration);
    cache.put(1, "test");

    MeterRegistry registry = new SimpleMeterRegistry();
    JCacheMetrics.monitor(registry, cache, "jcache", emptyList());

    assertThat(registry.mustFind("jcache.puts").tags("name", "a").gauge().value()).isEqualTo(1.0);
}
 
开发者ID:micrometer-metrics,项目名称:micrometer,代码行数:19,代码来源:JCacheMetricsTest.java

示例4: createCache

import javax.cache.configuration.MutableConfiguration; //导入依赖的package包/类
/**
 * Create a new cache from the given cache manager.
 *
 * @param cacheName         Name of the cache.
 * @param keyClass          Type of the key class.
 * @param valueClass        Type of the value class.
 * @param defaultExpiryTime Cache expire time in minutes.
 * @param cacheConfigMap    Cache config map.
 * @param cacheManager      Cache manager to use to create the cache.
 * @param <K>               Type of the Key.
 * @param <V>               Type of the Value.
 * @return Created cache.
 */
public static <K, V> Cache<K, V> createCache(String cacheName, Class<K> keyClass, Class<V> valueClass,
                                             int defaultExpiryTime, Map<String, CacheConfig> cacheConfigMap,
                                             CacheManager cacheManager) {

    Duration cacheExpiry = new Duration(TimeUnit.MINUTES, getExpireTime(cacheConfigMap, cacheName,
            defaultExpiryTime));

    boolean isStatisticsEnabled = false;

    if (cacheConfigMap.get(cacheName) != null) {
        isStatisticsEnabled = cacheConfigMap.get(cacheName).isStatisticsEnabled();
    }

    MutableConfiguration<K, V> configuration = new MutableConfiguration<>();
    configuration.setStoreByValue(false)
            .setTypes(keyClass, valueClass)
            .setExpiryPolicyFactory(AccessedExpiryPolicy.factoryOf(cacheExpiry))
            .setStatisticsEnabled(isStatisticsEnabled);

    return cacheManager.createCache(cacheName, configuration);
}
 
开发者ID:wso2,项目名称:carbon-identity-mgt,代码行数:35,代码来源:CacheHelper.java

示例5: testCacheManagerWithCustomInvalidProperties

import javax.cache.configuration.MutableConfiguration; //导入依赖的package包/类
@Test(expected = IllegalArgumentException.class)
public void testCacheManagerWithCustomInvalidProperties()
    throws Exception
{
    Properties properties = new Properties();

    properties.setProperty("unknownProperty", "true");

    try (CacheManager cacheManager = cachingProvider.getCacheManager(null, null, properties);)
    {
        assertNotNull(cacheManager);

        MutableConfiguration configuration = new MutableConfiguration();

        configuration.setStoreByValue(false);

        cacheManager.createCache("test", configuration);
    }
}
 
开发者ID:ocafebabe,项目名称:guava-jcache,代码行数:20,代码来源:GuavaCacheManagerTest.java

示例6: testCreateCacheWithModifiedExpiryPolicy

import javax.cache.configuration.MutableConfiguration; //导入依赖的package包/类
@Test
public void testCreateCacheWithModifiedExpiryPolicy()
{
    CacheManager cacheManager = cachingProvider.getCacheManager();

    MutableConfiguration<Number, Number> configuration = new MutableConfiguration<>();

    configuration.setStoreByValue(false);
    configuration.setExpiryPolicyFactory(ModifiedExpiryPolicy.factoryOf(Duration.ONE_DAY));

    Cache cache = cacheManager.createCache("cache", configuration);

    CompleteConfiguration actualConfiguration =
        (CompleteConfiguration) cache.getConfiguration(CompleteConfiguration.class);

    assertEquals(ModifiedExpiryPolicy.factoryOf(Duration.ONE_DAY), actualConfiguration.getExpiryPolicyFactory());
}
 
开发者ID:ocafebabe,项目名称:guava-jcache,代码行数:18,代码来源:GuavaCacheManagerTest.java

示例7: testCreateCacheWithTouchedExpiryPolicy

import javax.cache.configuration.MutableConfiguration; //导入依赖的package包/类
@Test
public void testCreateCacheWithTouchedExpiryPolicy()
{
    CacheManager cacheManager = cachingProvider.getCacheManager();

    MutableConfiguration<Number, Number> configuration = new MutableConfiguration<>();

    configuration.setStoreByValue(false);
    configuration.setExpiryPolicyFactory(TouchedExpiryPolicy.factoryOf(Duration.ONE_MINUTE));

    Cache cache = cacheManager.createCache("cache", configuration);

    CompleteConfiguration actualConfiguration =
        (CompleteConfiguration) cache.getConfiguration(CompleteConfiguration.class);

    assertEquals(TouchedExpiryPolicy.factoryOf(Duration.ONE_MINUTE), actualConfiguration.getExpiryPolicyFactory());
}
 
开发者ID:ocafebabe,项目名称:guava-jcache,代码行数:18,代码来源:GuavaCacheManagerTest.java

示例8: init

import javax.cache.configuration.MutableConfiguration; //导入依赖的package包/类
@Before
public void init()
{
    cachingProvider = Caching.getCachingProvider(GuavaCachingProvider.class.getName());
    assertNotNull(cachingProvider);

    cacheManager = cachingProvider.getCacheManager();
    assertNotNull(cacheManager);

    configuration.setStoreByValue(false);
    configuration.setTypes(String.class, Integer.class);

    cache = cacheManager.createCache("cache", configuration);
    assertNotNull(cache);
    assertEquals("cache", cache.getName());
    assertEquals(cacheManager, cache.getCacheManager());
    assertEquals(configuration, cache.getConfiguration(MutableConfiguration.class));
}
 
开发者ID:ocafebabe,项目名称:guava-jcache,代码行数:19,代码来源:GuavaCacheTest.java

示例9: getOrCreateCacheConfiguration

import javax.cache.configuration.MutableConfiguration; //导入依赖的package包/类
Configuration getOrCreateCacheConfiguration() {
    if (configuration.getCacheConfiguration() != null) {
        return configuration.getCacheConfiguration();
    }

    MutableConfiguration mutableConfiguration = new MutableConfiguration();
    if (configuration.getCacheLoaderFactory() != null) {
        mutableConfiguration.setCacheLoaderFactory(configuration.getCacheLoaderFactory());
    }
    if (configuration.getCacheWriterFactory() != null) {
        mutableConfiguration.setCacheWriterFactory(configuration.getCacheWriterFactory());
    }
    if (configuration.getExpiryPolicyFactory() != null) {
        mutableConfiguration.setExpiryPolicyFactory(configuration.getExpiryPolicyFactory());
    }

    mutableConfiguration.setManagementEnabled(configuration.isManagementEnabled());
    mutableConfiguration.setStatisticsEnabled(configuration.isStatisticsEnabled());
    mutableConfiguration.setReadThrough(configuration.isReadThrough());
    mutableConfiguration.setStoreByValue(configuration.isStoreByValue());

    return mutableConfiguration;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:24,代码来源:JCacheManager.java

示例10: maybeCreateCache

import javax.cache.configuration.MutableConfiguration; //导入依赖的package包/类
public synchronized <K, V> Cache<K, V> maybeCreateCache(final String name,
                                                        final MutableConfiguration<K, V> mutableConfiguration) {
  checkNotNull(name);
  checkNotNull(mutableConfiguration);

  Cache<K, V> cache = manager()
      .getCache(name, mutableConfiguration.getKeyType(), mutableConfiguration.getValueType());

  if (cache == null) {
    cache = manager().createCache(name, mutableConfiguration);
    log.debug("Created cache: {}", cache);
  }
  else {
    log.debug("Re-using existing cache: {}", cache);
  }

  return cache;
}
 
开发者ID:sonatype,项目名称:nexus-public,代码行数:19,代码来源:CacheHelper.java

示例11: createCacheConfig

import javax.cache.configuration.MutableConfiguration; //导入依赖的package包/类
public static <K, V> MutableConfiguration<K, V> createCacheConfig(
    @Nullable final Class<K> keyType,
    @Nullable final Class<V> valueType,
    final Factory<? extends ExpiryPolicy> expiryPolicyFactory)
{
  MutableConfiguration<K, V> config = new MutableConfiguration<K, V>()
      .setStoreByValue(false)
      .setExpiryPolicyFactory(expiryPolicyFactory)
      .setManagementEnabled(true)
      .setStatisticsEnabled(true);

  if (keyType != null && valueType != null) {
    config.setTypes(keyType, valueType);
  }
  return config;
}
 
开发者ID:sonatype,项目名称:nexus-public,代码行数:17,代码来源:CacheHelper.java

示例12: setup

import javax.cache.configuration.MutableConfiguration; //导入依赖的package包/类
@Override
protected void setup(Settings settings, CacheManager cacheManager) {
    cacheManager.createCache(STRING_LONG_CACHE, new MutableConfiguration()
            .setExpiryPolicyFactory(EternalExpiryPolicy.factoryOf())
            .setStatisticsEnabled(true)
            .setStoreByValue(true));

    cacheManager.createCache(STRING_STRING_CACHE, new MutableConfiguration()
            .setExpiryPolicyFactory(EternalExpiryPolicy.factoryOf())
            .setStatisticsEnabled(true)
            .setStoreByValue(true));

    cacheManager.createCache(LONG_STRING_CACHE, new MutableConfiguration()
            .setExpiryPolicyFactory(EternalExpiryPolicy.factoryOf())
            .setStatisticsEnabled(true)
            .setStoreByValue(true));

}
 
开发者ID:gitblit,项目名称:fathom,代码行数:19,代码来源:Caches.java

示例13: before

import javax.cache.configuration.MutableConfiguration; //导入依赖的package包/类
@BeforeClass
public static void before() throws Exception {
    dataModel = Converters.toDataModel(new XSSFWorkbook(pathDataModel));
    
    CacheManager cacheManager = Caching.getCachingProvider().getCacheManager();

    MutableConfiguration config = new MutableConfiguration();
    config.setStoreByValue(false)
          .setExpiryPolicyFactory(AccessedExpiryPolicy.factoryOf(Duration.ETERNAL))
          .setStatisticsEnabled(false);

    cacheManager.createCache(CacheBasedDataSetAccessor.DATA_SET_TO_ID_CACHE_NAME, config.setTypes(IDataModelId.class, IDataSet.class));
    cacheManager.createCache(CacheBasedDataSetAccessor.DATA_SET_TO_NAME_CACHE_NAME, config.setTypes(String.class, IDataSet.class));
    
    ExternalServices.INSTANCE.setDataSetAccessor(new CacheBasedDataSetAccessor());

    expectedValues = new HashMap<>();
    
    SpreadsheetEvaluator evaluator = new SpreadsheetEvaluator(dataModel);
    for (int i = expectedRowStart; i <= expectedRowEnd; i++) {
        ICellValue value = evaluator.evaluate(A1Address.fromA1Address(expectedColumn + i)).getResult();
        expectedValues.put(expectedColumn + i, value.get());
    }
}
 
开发者ID:DataArt,项目名称:CalculationEngine,代码行数:25,代码来源:Validate_Function_Test.java

示例14: JCacheTemplateCache

import javax.cache.configuration.MutableConfiguration; //导入依赖的package包/类
public JCacheTemplateCache() {
    Iterator<CachingProvider> cachingProviders = Caching.getCachingProviders().iterator();
    if (cachingProviders.hasNext()) {
        CachingProvider cachingProvider = cachingProviders.next();
        CacheManager cacheManager = cachingProvider.getCacheManager();
        Configuration<String, Template> config = new MutableConfiguration<String, Template>()
                .setTypes(String.class, Template.class)
                .setExpiryPolicyFactory(AccessedExpiryPolicy.factoryOf(new Duration(TimeUnit.MINUTES, 5)));
        Cache<String, Template> cache = cacheManager.getCache("TemplateCache", String.class, Template.class);
        if (cache == null) {
            this.cache = cacheManager.createCache("TemplateCache", config);
        } else {
            this.cache = cache;
        }
    } else {
        this.cache = null; // to keep compatibility with 0.1.0, but ugly
    }
}
 
开发者ID:kawasima,项目名称:moshas,代码行数:19,代码来源:JCacheTemplateCache.java

示例15: testStatistics

import javax.cache.configuration.MutableConfiguration; //导入依赖的package包/类
@Test
public void testStatistics() {
    CachingProvider cachingProvider = Caching.getCachingProvider();
    Properties p = new Properties();
    try (CacheManager cacheManager = cachingProvider.getCacheManager(cachingProvider.getDefaultURI(), cachingProvider.getDefaultClassLoader(), p)) {
        MutableConfiguration<String, String> config
                = new MutableConfiguration<String, String>()
                .setTypes(String.class, String.class)
                .setStatisticsEnabled(true)
                .setManagementEnabled(true);
        BlazingCacheCache<String, String> cache = cacheManager.createCache("simpleCache", config).unwrap(BlazingCacheCache.class);
        BlazingCacheStatisticsMXBean<String, String> stats = cache.getStatisticsMXBean();
        cache.put("1", "test");
        cache.get("1");
        assertEquals(1L, stats.getCachePuts());
        assertEquals(1L, stats.getCacheGets());
        assertEquals(1L, stats.getCacheHits());
        cache.get("2");
        assertEquals(1L, stats.getCacheMisses());
        stats.clear();
        assertEquals(0L, stats.getCachePuts());
        assertEquals(0L, stats.getCacheGets());
        assertEquals(0L, stats.getCacheHits());
        assertEquals(0L, stats.getCacheMisses());
    }
}
 
开发者ID:diennea,项目名称:blazingcache,代码行数:27,代码来源:ManagementTest.java


注:本文中的javax.cache.configuration.MutableConfiguration类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。