builder.read(override.build(false)); builder.template(true); configureTransactionManager( builder ); dataTypeConfigurations.put(type, builder.build());
@Override public Collection<ServiceController<?>> installRuntimeServices(OperationContext context, ModelNode operation, ModelNode containerModel, ModelNode cacheModel) throws OperationFailedException { // get all required addresses, names and service names PathAddress configurationAddress = getCacheConfigurationAddressFromOperation(operation); PathAddress containerAddress = getCacheContainerAddressFromOperation(operation); String cacheName = configurationAddress.getLastElement().getValue(); String containerName = containerAddress.getLastElement().getValue(); // get model attributes ModelNode resolvedValue; final String templateConfiguration = (resolvedValue = CacheConfigurationResource.CONFIGURATION.resolveModelAttribute(context, cacheModel)).isDefined() ? resolvedValue.asString() : null; // create a list for dependencies which may need to be added during processing List<Dependency<?>> dependencies = new LinkedList<>(); // Infinispan Configuration to hold the operation data ConfigurationBuilder builder = new ConfigurationBuilder().read(getDefaultConfiguration(this.mode)); builder.template(CacheConfigurationResource.TEMPLATE.resolveModelAttribute(context, cacheModel).asBoolean()); // process cache configuration ModelNode describing overrides to defaults processModelNode(context, containerName, cacheModel, builder, dependencies); // install the cache configuration service (configures a cache) ServiceController<?> serviceController = installCacheConfigurationService(context.getServiceTarget(), containerName, cacheName, templateConfiguration, builder, dependencies); log.debugf("Cache configuration service for %s installed for container %s", cacheName, containerName); return Collections.singletonList(serviceController); }
public void createCacheTest() { ConfigurationBuilder builder = new ConfigurationBuilder(); builder.read(cacheManager.getDefaultCacheConfiguration()); builder.template(false); cacheManager.defineConfiguration("newCache", builder.build()); cacheManager.getCache("newCache"); }
@Override protected ConfigurationBuilder getConfigurationBuilder() { ConfigurationBuilder builder = new ConfigurationBuilder(); Configuration templateConfiguration = this.dependencies.getTemplateConfiguration(); if (templateConfiguration != null) { builder.read(templateConfiguration); } Configuration configuration = this.builder.build(); builder.read(configuration); builder.template(configuration.isTemplate()); builder.jmxStatistics().enabled(this.dependencies.getCacheContainer().getCacheManagerConfiguration().globalJmxStatistics().enabled()); TransactionManager tm = this.dependencies.getTransactionManager(); if (tm != null) { builder.transaction().transactionManagerLookup(new TransactionManagerProvider(tm)); } TransactionSynchronizationRegistry tsr = this.dependencies.getTransactionSynchronizationRegistry(); if (tsr != null) { builder.transaction().transactionSynchronizationRegistryLookup(new TransactionSynchronizationRegistryProvider(tsr)); } return builder; } }
@Override public void call() { ConfigurationBuilder builder = new ConfigurationBuilder(); CacheMode cacheMode = CacheMode.DIST_ASYNC; // DIST_ASYNC isn't default so it should stay applied builder.clustering().cacheMode(cacheMode); String distCacheName = "dist-cache"; cm.defineConfiguration(distCacheName, builder.build()); String templateName = "template"; cm.defineConfiguration(templateName, new ConfigurationBuilder().template(true).build()); Cache cache = cm.getCache(distCacheName, templateName); assertEquals(cacheMode, cache.getCacheConfiguration().clustering().cacheMode()); } });