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


Java MutableConfiguration.setManagementEnabled方法代码示例

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


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

示例1: 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

示例2: testManagementDisabledOverriddenFromTemplate

import javax.cache.configuration.MutableConfiguration; //导入方法依赖的package包/类
@Test
public void testManagementDisabledOverriddenFromTemplate() throws Exception {
  CacheManager cacheManager = provider.getCacheManager(getClass().getResource("/ehcache-107-mbeans-template-config.xml")
          .toURI(),
      provider.getDefaultClassLoader());

  MutableConfiguration<Long, String> configuration = new MutableConfiguration<>();
  configuration.setTypes(Long.class, String.class);
  configuration.setManagementEnabled(false);
  configuration.setStatisticsEnabled(false);

  Cache<Long, String> cache = cacheManager.createCache("enables-mbeans", configuration);

  @SuppressWarnings("unchecked")
  Eh107Configuration<Long, String> eh107Configuration = cache.getConfiguration(Eh107Configuration.class);
  assertThat(eh107Configuration.isManagementEnabled(), is(true));
  assertThat(eh107Configuration.isStatisticsEnabled(), is(true));

  assertThat(isMbeanRegistered("enables-mbeans", MBEAN_MANAGEMENT_TYPE), is(true));
  assertThat(isMbeanRegistered("enables-mbeans", MBEAN_STATISTICS_TYPE), is(true));
}
 
开发者ID:ehcache,项目名称:ehcache3,代码行数:22,代码来源:ConfigStatsManagementActivationTest.java

示例3: testManagementEnabledOverriddenFromTemplate

import javax.cache.configuration.MutableConfiguration; //导入方法依赖的package包/类
@Test
public void testManagementEnabledOverriddenFromTemplate() throws Exception {
  CacheManager cacheManager = provider.getCacheManager(getClass().getResource("/ehcache-107-mbeans-template-config.xml")
          .toURI(),
      provider.getDefaultClassLoader());

  MutableConfiguration<Long, String> configuration = new MutableConfiguration<>();
  configuration.setTypes(Long.class, String.class);
  configuration.setManagementEnabled(true);
  configuration.setStatisticsEnabled(true);

  Cache<Long, String> cache = cacheManager.createCache("disables-mbeans", configuration);

  @SuppressWarnings("unchecked")
  Eh107Configuration<Long, String> eh107Configuration = cache.getConfiguration(Eh107Configuration.class);
  assertThat(eh107Configuration.isManagementEnabled(), is(false));
  assertThat(eh107Configuration.isStatisticsEnabled(), is(false));

  assertThat(isMbeanRegistered("disables-mbeans", MBEAN_MANAGEMENT_TYPE), is(false));
  assertThat(isMbeanRegistered("disables-mbeans", MBEAN_STATISTICS_TYPE), is(false));
}
 
开发者ID:ehcache,项目名称:ehcache3,代码行数:22,代码来源:ConfigStatsManagementActivationTest.java

示例4: basicJsr107StillWorks

import javax.cache.configuration.MutableConfiguration; //导入方法依赖的package包/类
@Test
public void basicJsr107StillWorks() throws Exception {
  CacheManager cacheManager = provider.getCacheManager();

  MutableConfiguration<Long, String> configuration = new MutableConfiguration<>();
  configuration.setTypes(Long.class, String.class);
  configuration.setManagementEnabled(true);
  configuration.setStatisticsEnabled(true);

  Cache<Long, String> cache = cacheManager.createCache("cache", configuration);
  @SuppressWarnings("unchecked")
  Eh107Configuration eh107Configuration = cache.getConfiguration(Eh107Configuration.class);

  assertThat(eh107Configuration.isManagementEnabled(), is(true));
  assertThat(eh107Configuration.isStatisticsEnabled(), is(true));

  assertThat(isMbeanRegistered("cache", MBEAN_MANAGEMENT_TYPE), is(true));
  assertThat(isMbeanRegistered("cache", MBEAN_STATISTICS_TYPE), is(true));
}
 
开发者ID:ehcache,项目名称:ehcache3,代码行数:20,代码来源:ConfigStatsManagementActivationTest.java

示例5: testCacheManagementOffThenOnThenOff

import javax.cache.configuration.MutableConfiguration; //导入方法依赖的package包/类
@Test
public void testCacheManagementOffThenOnThenOff() throws Exception {
  MutableConfiguration configuration = new MutableConfiguration();
  configuration.setManagementEnabled(false);
  cacheManager.createCache("cache1", configuration);
  cacheManager.createCache("cache2", configuration);
  Set<? extends ObjectName> names = mBeanServer.queryNames(new ObjectName("javax.cache:*"), null);
  Assert.assertTrue(names.size() == 0);

  configuration.setManagementEnabled(true);
  cacheManager.createCache("cache3", configuration);
  cacheManager.createCache("cache4", configuration);
  assertThat(mBeanServer.queryNames(new ObjectName("javax.cache:*"), null), hasSize(2));

  cacheManager.enableManagement("cache3", false);
  assertThat(mBeanServer.queryNames(new ObjectName("javax.cache:*"), null), hasSize(1));


  cacheManager.enableManagement("cache3", true);
  assertThat(mBeanServer.queryNames(new ObjectName("javax.cache:*"), null), hasSize(2));
}
 
开发者ID:cache2k,项目名称:cache2k,代码行数:22,代码来源:CacheManagerManagementTest.java

示例6: createCacheConfiguration

import javax.cache.configuration.MutableConfiguration; //导入方法依赖的package包/类
/**
 * Prep cache configuration.
 *
 * @param expiryDuration the expiry duration
 * @return the mutable configuration
 */
protected static MutableConfiguration<String, Map<String, Object>> createCacheConfiguration(final Duration expiryDuration) {
    final MutableConfiguration<String, Map<String, Object>> config = new MutableConfiguration<>();
    config.setStatisticsEnabled(true);
    config.setManagementEnabled(true);
    config.setStoreByValue(true);
    config.setExpiryPolicyFactory(CreatedExpiryPolicy.factoryOf(expiryDuration));
    return config;
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:15,代码来源:CachingPrincipalAttributesRepository.java

示例7: getConfiguration

import javax.cache.configuration.MutableConfiguration; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public <C extends Configuration<K, V>> C getConfiguration(Class<C> _class) {
  if (CompleteConfiguration.class.isAssignableFrom(_class)) {
    MutableConfiguration<K, V> cfg = new MutableConfiguration<K, V>();
    cfg.setTypes(keyType, valueType);
    cfg.setStatisticsEnabled(jmxStatisticsEnabled);
    cfg.setManagementEnabled(jmxEnabled);
    cfg.setStoreByValue(storeByValue);
    Collection<CacheEntryListenerConfiguration<K,V>> _listenerConfigurations = eventHandling.getAllListenerConfigurations();
    for (CacheEntryListenerConfiguration<K,V> _listenerConfig : _listenerConfigurations) {
      cfg.addCacheEntryListenerConfiguration(_listenerConfig);
    }
    return (C) cfg;
  }
  return (C) new Configuration<K, V>() {
    @Override
    public Class<K> getKeyType() {
      return keyType;
    }

    @Override
    public Class<V> getValueType() {
      return valueType;
    }

    @Override
    public boolean isStoreByValue() {
      return storeByValue;
    }
  };
}
 
开发者ID:cache2k,项目名称:cache2k,代码行数:33,代码来源:JCacheAdapter.java

示例8: testCacheManagementBean

import javax.cache.configuration.MutableConfiguration; //导入方法依赖的package包/类
@Test
@Repeat(times = 2)
public void testCacheManagementBean()
    throws Exception
{
    try (CachingProvider cachingProvider = Caching.getCachingProvider(GuavaCachingProvider.class.getName()))
    {
        CacheManager cacheManager = cachingProvider.getCacheManager();

        MutableConfiguration<String, Integer> configuration = new MutableConfiguration<>();

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

        Cache<String, Integer> managementCache = cacheManager.createCache("managementCache", configuration);

        MBeanServer beanServer = ManagementFactory.getPlatformMBeanServer();

        assertNotNull(beanServer);

        ObjectName name = new ObjectName(GuavaCacheMXBean.getObjectName(managementCache));

        Object keyType = beanServer.getAttribute(name, "KeyType");
        Object valueType = beanServer.getAttribute(name, "ValueType");
        Object readThrough = beanServer.getAttribute(name, "ReadThrough");
        Object writeThrough = beanServer.getAttribute(name, "WriteThrough");
        Object storeByValue = beanServer.getAttribute(name, "StoreByValue");
        Object statisticsEnabled = beanServer.getAttribute(name, "StatisticsEnabled");
        Object managementEnabled = beanServer.getAttribute(name, "ManagementEnabled");

        assertNotNull(keyType);
        assertNotNull(valueType);
        assertNotNull(readThrough);
        assertNotNull(writeThrough);
        assertNotNull(storeByValue);
        assertNotNull(statisticsEnabled);
        assertNotNull(managementEnabled);

        assertEquals("java.lang.String", keyType);
        assertEquals("java.lang.Integer", valueType);
        assertFalse((boolean) readThrough);
        assertFalse((boolean) writeThrough);
        assertFalse((boolean) storeByValue);
        assertFalse((boolean) statisticsEnabled);
        assertTrue((boolean) managementEnabled);
    }
}
 
开发者ID:ocafebabe,项目名称:guava-jcache,代码行数:49,代码来源:GuavaCacheMXBeanTest.java


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