void removeRuntimeServices(OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException { // get container and cache addresses final PathAddress cacheAddress = getCacheAddressFromOperation(operation); final PathAddress containerAddress = getCacheContainerAddressFromOperation(operation); // get container and cache names final String cacheName = cacheAddress.getLastElement().getValue(); final String containerName = containerAddress.getLastElement().getValue(); // remove all services started by CacheAdd, in reverse order // remove the binder service ModelNode resolvedValue = null; final String jndiNameString = (resolvedValue = CommonAttributes.JNDI_NAME.resolveModelAttribute(context, model)) .isDefined() ? resolvedValue.asString() : null; final String jndiName = InfinispanJndiName.createCacheJndiNameOrDefault(jndiNameString, containerName, cacheName); ContextNames.BindInfo bindInfo = ContextNames.bindInfoFor(jndiName); context.removeService(bindInfo.getBinderServiceName()); // remove the CacheService instance context.removeService(CacheService.getServiceName(containerName, cacheName)); // remove the cache configuration service context.removeService(CacheConfigurationService.getServiceName(containerName, cacheName)); log.debugf("cache %s removed for container %s", cacheName, containerName); }
Collection<ServiceController<?>> installRuntimeServices( OperationContext context, ModelNode operation, ModelNode containerModel, ModelNode cacheModel, ServiceVerificationHandler verificationHandler) throws OperationFailedException { // get all required addresses, names and service names PathAddress cacheAddress = getCacheAddressFromOperation(operation); PathAddress containerAddress = getCacheContainerAddressFromOperation(operation); String cacheName = cacheAddress.getLastElement().getValue(); String containerName = containerAddress.getLastElement().getValue(); // get model attributes ModelNode resolvedValue = null; final String jndiName = ((resolvedValue = CommonAttributes.JNDI_NAME.resolveModelAttribute(context, cacheModel)) .isDefined()) ? resolvedValue.asString() : null; final ServiceController.Mode initialMode = StartMode.valueOf( CommonAttributes.START.resolveModelAttribute(context, cacheModel).asString()) .getMode(); final ModuleIdentifier moduleId = (resolvedValue = CommonAttributes.CACHE_MODULE.resolveModelAttribute(context, cacheModel)) .isDefined() ? ModuleIdentifier.fromString(resolvedValue.asString()) : null; // create a list for dependencies which may need to be added during processing List<Dependency<?>> dependencies = new LinkedList<Dependency<?>>(); // Infinispan Configuration to hold the operation data ConfigurationBuilder builder = new ConfigurationBuilder().read(getDefaultConfiguration(this.mode)); // process cache configuration ModelNode describing overrides to defaults processModelNode(context, containerName, cacheModel, builder, dependencies); // get container Model to pick up the value of the default cache of the container // AS7-3488 make default-cache no required attribute String defaultCache = CommonAttributes.DEFAULT_CACHE.resolveModelAttribute(context, containerModel).asString(); ServiceTarget target = context.getServiceTarget(); Configuration config = builder.build(); Collection<ServiceController<?>> controllers = new ArrayList<ServiceController<?>>(3); // install the cache configuration service (configures a cache) controllers.add( this.installCacheConfigurationService( target, containerName, cacheName, defaultCache, moduleId, builder, config, dependencies, verificationHandler)); log.debugf( "Cache configuration service for %s installed for container %s", cacheName, containerName); // now install the corresponding cache service (starts a configured cache) controllers.add( this.installCacheService( target, containerName, cacheName, defaultCache, initialMode, config, verificationHandler)); // install a name service entry for the cache controllers.add( this.installJndiService(target, containerName, cacheName, jndiName, verificationHandler)); log.debugf("Cache service for cache %s installed for container %s", cacheName, containerName); return controllers; }