Exemplo n.º 1
0
  ServiceController<?> installJndiService(
      ServiceTarget target,
      String containerName,
      String jndiName,
      ServiceVerificationHandler verificationHandler) {

    final ServiceName containerServiceName =
        EmbeddedCacheManagerService.getServiceName(containerName);
    final ContextNames.BindInfo binding = createCacheContainerBinding(jndiName, containerName);

    final BinderService binder = new BinderService(binding.getBindName());
    return target
        .addService(binding.getBinderServiceName(), binder)
        .addAliases(ContextNames.JAVA_CONTEXT_SERVICE_NAME.append(binding.getBindName()))
        .addDependency(
            containerServiceName,
            CacheContainer.class,
            new ManagedReferenceInjector<CacheContainer>(binder.getManagedObjectInjector()))
        .addDependency(
            binding.getParentContextServiceName(),
            ServiceBasedNamingStore.class,
            binder.getNamingStoreInjector())
        .setInitialMode(ServiceController.Mode.PASSIVE)
        .install();
  }
  @Override
  public void execute(OperationContext context, ModelNode operation)
      throws OperationFailedException {
    ModelNode newValue = operation.require(CacheContainerResource.PROTO_URL.getName());
    String urlString = newValue.asString();

    final PathAddress address = PathAddress.pathAddress(operation.require(OP_ADDR));
    final String cacheContainerName = address.getElement(address.size() - 1).getValue();
    final ServiceController<?> controller =
        context
            .getServiceRegistry(false)
            .getService(EmbeddedCacheManagerService.getServiceName(cacheContainerName));

    EmbeddedCacheManager cacheManager = (EmbeddedCacheManager) controller.getValue();
    ProtobufMetadataManager protoManager =
        cacheManager.getGlobalComponentRegistry().getComponent(ProtobufMetadataManager.class);
    if (protoManager != null) {
      try {
        URL url = new URL(urlString);
        protoManager.registerProtofile(url.openStream());
      } catch (Exception e) {
        throw new OperationFailedException(
            new ModelNode().set(MESSAGES.failedToInvokeOperation(e.getLocalizedMessage())));
      }
    }
    context.stepCompleted();
  }
Exemplo n.º 3
0
  ServiceController<?> installContainerService(
      ServiceTarget target,
      String containerName,
      ServiceName[] aliases,
      Transport transport,
      ServiceController.Mode initialMode,
      ServiceVerificationHandler verificationHandler) {

    final ServiceName containerServiceName =
        EmbeddedCacheManagerService.getServiceName(containerName);
    final ServiceName configServiceName =
        EmbeddedCacheManagerConfigurationService.getServiceName(containerName);
    final InjectedValue<EmbeddedCacheManagerConfiguration> config = new InjectedValue<>();
    final Service<EmbeddedCacheManager> service = new EmbeddedCacheManagerService(config);
    ServiceBuilder<EmbeddedCacheManager> builder =
        target
            .addService(containerServiceName, service)
            .addDependency(configServiceName, EmbeddedCacheManagerConfiguration.class, config)
            .addAliases(aliases)
            .setInitialMode(initialMode);
    if (transport != null) {
      builder.addDependency(ChannelService.getServiceName(containerName));
    }
    return builder.install();
  }
Exemplo n.º 4
0
  ServiceController<?> installCacheConfigurationService(
      ServiceTarget target,
      String containerName,
      String cacheName,
      String defaultCache,
      ModuleIdentifier moduleId,
      ConfigurationBuilder builder,
      Configuration config,
      List<Dependency<?>> dependencies,
      ServiceVerificationHandler verificationHandler) {

    final InjectedValue<EmbeddedCacheManager> container = new InjectedValue<EmbeddedCacheManager>();
    final CacheConfigurationDependencies cacheConfigurationDependencies =
        new CacheConfigurationDependencies(container);
    final Service<Configuration> service =
        new CacheConfigurationService(cacheName, builder, moduleId, cacheConfigurationDependencies);
    final ServiceBuilder<?> configBuilder =
        target
            .addService(CacheConfigurationService.getServiceName(containerName, cacheName), service)
            .addDependency(
                EmbeddedCacheManagerService.getServiceName(containerName),
                EmbeddedCacheManager.class,
                container)
            .addDependency(
                Services.JBOSS_SERVICE_MODULE_LOADER,
                ModuleLoader.class,
                cacheConfigurationDependencies.getModuleLoaderInjector())
            .setInitialMode(ServiceController.Mode.PASSIVE);
    if (config.invocationBatching().enabled()) {
      cacheConfigurationDependencies
          .getTransactionManagerInjector()
          .inject(BatchModeTransactionManager.getInstance());
    } else if (config.transaction().transactionMode()
        == org.infinispan.transaction.TransactionMode.TRANSACTIONAL) {
      configBuilder.addDependency(
          TxnServices.JBOSS_TXN_TRANSACTION_MANAGER,
          TransactionManager.class,
          cacheConfigurationDependencies.getTransactionManagerInjector());
      if (config.transaction().useSynchronization()) {
        configBuilder.addDependency(
            TxnServices.JBOSS_TXN_SYNCHRONIZATION_REGISTRY,
            TransactionSynchronizationRegistry.class,
            cacheConfigurationDependencies.getTransactionSynchronizationRegistryInjector());
      }
    }

    // add in any additional dependencies resulting from ModelNode parsing
    for (Dependency<?> dependency : dependencies) {
      this.addDependency(configBuilder, dependency);
    }
    // add an alias for the default cache
    if (cacheName.equals(defaultCache)) {
      configBuilder.addAliases(CacheConfigurationService.getServiceName(containerName, null));
    }
    return configBuilder.install();
  }
Exemplo n.º 5
0
  void removeRuntimeServices(OperationContext context, ModelNode operation, ModelNode model)
      throws OperationFailedException {

    final PathAddress address = getCacheContainerAddressFromOperation(operation);
    final String containerName = address.getLastElement().getValue();

    // need to remove all container-related services started, in reverse order
    context.removeService(KeyAffinityServiceFactoryService.getServiceName(containerName));

    // remove the BinderService entry
    ModelNode resolvedValue = null;
    final String jndiName =
        (resolvedValue =
                    CacheContainerResourceDefinition.JNDI_NAME.resolveModelAttribute(
                        context, model))
                .isDefined()
            ? resolvedValue.asString()
            : null;
    context.removeService(
        createCacheContainerBinding(jndiName, containerName).getBinderServiceName());

    // remove the cache container
    context.removeService(EmbeddedCacheManagerService.getServiceName(containerName));
    context.removeService(EmbeddedCacheManagerConfigurationService.getServiceName(containerName));
    context.removeService(GlobalComponentRegistryService.getServiceName(containerName));

    // check if a channel was installed
    final ServiceName channelServiceName = ChannelService.getServiceName(containerName);
    final ServiceController<?> channelServiceController =
        context.getServiceRegistry(false).getService(channelServiceName);
    if (channelServiceController != null) {
      for (ChannelServiceProvider provider :
          ServiceLoader.load(
              ChannelServiceProvider.class, ChannelServiceProvider.class.getClassLoader())) {
        for (ServiceName name : provider.getServiceNames(containerName)) {
          context.removeService(name);
        }
      }
      // unregister the protocol metrics by adding a step
      ChannelInstanceResourceDefinition.addChannelProtocolMetricsDeregistrationStep(
          context, containerName);

      context.removeService(createChannelBinding(containerName).getBinderServiceName());
      context.removeService(channelServiceName);
    }
  }
Exemplo n.º 6
0
  ServiceController<?> installCacheService(
      ServiceTarget target,
      String containerName,
      String cacheName,
      String defaultCache,
      ServiceController.Mode initialMode,
      Configuration config,
      ServiceVerificationHandler verificationHandler) {

    final InjectedValue<EmbeddedCacheManager> container = new InjectedValue<EmbeddedCacheManager>();
    final CacheDependencies cacheDependencies = new CacheDependencies(container);
    final Service<Cache<Object, Object>> service =
        new CacheService<Object, Object>(cacheName, cacheDependencies);
    final ServiceBuilder<?> builder =
        AsynchronousService.addService(
                target, CacheService.getServiceName(containerName, cacheName), service)
            .addDependency(CacheConfigurationService.getServiceName(containerName, cacheName))
            .addDependency(
                EmbeddedCacheManagerService.getServiceName(containerName),
                EmbeddedCacheManager.class,
                container)
            .addDependency(
                config.clustering().cacheMode().isClustered()
                    ? DependencyType.REQUIRED
                    : DependencyType.OPTIONAL,
                ChannelService.getServiceName(containerName))
            .setInitialMode(initialMode);
    if (config.transaction().recovery().enabled()) {
      builder.addDependency(
          TxnServices.JBOSS_TXN_ARJUNA_RECOVERY_MANAGER,
          XAResourceRecoveryRegistry.class,
          cacheDependencies.getRecoveryRegistryInjector());
    }

    // add an alias for the default cache
    if (cacheName.equals(defaultCache)) {
      builder.addAliases(CacheService.getServiceName(containerName, null));
    }

    if (initialMode == ServiceController.Mode.ACTIVE) {
      builder.addListener(verificationHandler);
    }

    return builder.install();
  }
Exemplo n.º 7
0
 ServiceController<?> installGlobalComponentRegistryService(
     ServiceTarget target,
     String containerName,
     Transport transport,
     ServiceVerificationHandler verificationHandler) {
   InjectedValue<CacheContainer> container = new InjectedValue<>();
   ServiceBuilder<?> builder =
       AsynchronousService.addService(
               target,
               GlobalComponentRegistryService.getServiceName(containerName),
               new GlobalComponentRegistryService(container))
           .addDependency(
               EmbeddedCacheManagerService.getServiceName(containerName),
               CacheContainer.class,
               container)
           .setInitialMode(ServiceController.Mode.ON_DEMAND);
   if (transport != null) {
     builder.addDependency(ChannelService.getServiceName(containerName));
   }
   return builder.install();
 }
Exemplo n.º 8
0
  @Override
  protected void performRuntime(
      OperationContext context,
      ModelNode operation,
      ModelNode model,
      ServiceVerificationHandler verificationHandler,
      List<ServiceController<?>> newControllers)
      throws OperationFailedException {
    // Because we use child resources in a read-only manner to configure the cache container,
    // replace the local model with the full model
    model = Resource.Tools.readModel(context.readResource(PathAddress.EMPTY_ADDRESS));

    final PathAddress address = PathAddress.pathAddress(operation.get(OP_ADDR));
    final String name = address.getLastElement().getValue();

    String defaultCache = model.require(ModelKeys.DEFAULT_CACHE).asString();

    boolean hasTransport =
        model.hasDefined(ModelKeys.TRANSPORT)
            && model.get(ModelKeys.TRANSPORT).hasDefined(ModelKeys.TRANSPORT_NAME);
    Transport transportConfig = hasTransport ? new Transport() : null;
    EmbeddedCacheManagerDependencies dependencies =
        new EmbeddedCacheManagerDependencies(transportConfig);

    ServiceName[] aliases = null;
    if (model.hasDefined(ModelKeys.ALIASES)) {
      List<ModelNode> list = operation.get(ModelKeys.ALIASES).asList();
      aliases = new ServiceName[list.size()];
      for (int i = 0; i < list.size(); i++) {
        aliases[i] = EmbeddedCacheManagerService.getServiceName(list.get(i).asString());
      }
    }

    ServiceTarget target = context.getServiceTarget();
    ServiceName serviceName = EmbeddedCacheManagerService.getServiceName(name);
    ServiceBuilder<EmbeddedCacheManager> containerBuilder =
        target
            .addService(
                serviceName, new EmbeddedCacheManagerService(name, defaultCache, dependencies))
            .addDependency(
                DependencyType.OPTIONAL,
                ServiceName.JBOSS.append("mbean", "server"),
                MBeanServer.class,
                dependencies.getMBeanServerInjector())
            .addAliases(aliases)
            .setInitialMode(ServiceController.Mode.ON_DEMAND);

    String jndiName =
        (model.hasDefined(ModelKeys.JNDI_NAME)
                ? InfinispanJndiName.toJndiName(model.get(ModelKeys.JNDI_NAME).asString())
                : InfinispanJndiName.defaultCacheContainerJndiName(name))
            .getAbsoluteName();
    ContextNames.BindInfo bindInfo = ContextNames.bindInfoFor(jndiName);

    BinderService binder = new BinderService(bindInfo.getBindName());
    ServiceBuilder<ManagedReferenceFactory> binderBuilder =
        target
            .addService(bindInfo.getBinderServiceName(), binder)
            .addAliases(ContextNames.JAVA_CONTEXT_SERVICE_NAME.append(jndiName))
            .addDependency(
                serviceName,
                CacheContainer.class,
                new ManagedReferenceInjector<CacheContainer>(binder.getManagedObjectInjector()))
            .addDependency(
                bindInfo.getParentContextServiceName(),
                ServiceBasedNamingStore.class,
                binder.getNamingStoreInjector())
            .setInitialMode(ServiceController.Mode.ON_DEMAND);
    newControllers.add(binderBuilder.install());

    if (hasTransport) {
      String stack = null;
      ModelNode transport = model.get(ModelKeys.TRANSPORT, ModelKeys.TRANSPORT_NAME);
      if (transport.hasDefined(ModelKeys.STACK)) {
        stack = transport.get(ModelKeys.STACK).asString();
      }
      if (transport.hasDefined(ModelKeys.LOCK_TIMEOUT)) {
        transportConfig.setLockTimeout(transport.get(ModelKeys.LOCK_TIMEOUT).asLong());
      }
      addExecutorDependency(
          containerBuilder, transport, ModelKeys.EXECUTOR, transportConfig.getExecutorInjector());

      ServiceName channelServiceName = ChannelService.getServiceName(name);
      containerBuilder.addDependency(
          channelServiceName, Channel.class, transportConfig.getChannelInjector());

      InjectedValue<ChannelFactory> channelFactory = new InjectedValue<ChannelFactory>();
      ServiceBuilder<Channel> channelBuilder =
          target
              .addService(channelServiceName, new ChannelService(name, channelFactory))
              .addDependency(
                  ChannelFactoryService.getServiceName(stack), ChannelFactory.class, channelFactory)
              .setInitialMode(ServiceController.Mode.ON_DEMAND);
      newControllers.add(channelBuilder.install());
    }

    addExecutorDependency(
        containerBuilder,
        model,
        ModelKeys.LISTENER_EXECUTOR,
        dependencies.getListenerExecutorInjector());
    addScheduledExecutorDependency(
        containerBuilder,
        model,
        ModelKeys.EVICTION_EXECUTOR,
        dependencies.getEvictionExecutorInjector());
    addScheduledExecutorDependency(
        containerBuilder,
        model,
        ModelKeys.REPLICATION_QUEUE_EXECUTOR,
        dependencies.getReplicationQueueExecutorInjector());

    newControllers.add(containerBuilder.install());

    log.debugf("%s cache container installed", name);
  }
Exemplo n.º 9
0
 public static ServiceName getServiceName(String container, String cache) {
   return EmbeddedCacheManagerService.getServiceName(container)
       .append((cache != null) ? cache : CacheContainer.DEFAULT_CACHE_NAME);
 }
Exemplo n.º 10
0
  Collection<ServiceController<?>> installRuntimeServices(
      OperationContext context,
      ModelNode operation,
      ModelNode containerModel,
      ServiceVerificationHandler verificationHandler)
      throws OperationFailedException {

    final PathAddress address = getCacheContainerAddressFromOperation(operation);
    final String name = address.getLastElement().getValue();
    final ServiceTarget target = context.getServiceTarget();

    // pick up the attribute values from the model
    ModelNode resolvedValue = null;
    // make default cache non required (AS7-3488)
    final String defaultCache =
        (resolvedValue =
                    CacheContainerResourceDefinition.DEFAULT_CACHE.resolveModelAttribute(
                        context, containerModel))
                .isDefined()
            ? resolvedValue.asString()
            : null;
    final String jndiName =
        (resolvedValue =
                    CacheContainerResourceDefinition.JNDI_NAME.resolveModelAttribute(
                        context, containerModel))
                .isDefined()
            ? resolvedValue.asString()
            : null;
    final String listenerExecutor =
        (resolvedValue =
                    CacheContainerResourceDefinition.LISTENER_EXECUTOR.resolveModelAttribute(
                        context, containerModel))
                .isDefined()
            ? resolvedValue.asString()
            : null;
    final String evictionExecutor =
        (resolvedValue =
                    CacheContainerResourceDefinition.EVICTION_EXECUTOR.resolveModelAttribute(
                        context, containerModel))
                .isDefined()
            ? resolvedValue.asString()
            : null;
    final String replicationQueueExecutor =
        (resolvedValue =
                    CacheContainerResourceDefinition.REPLICATION_QUEUE_EXECUTOR
                        .resolveModelAttribute(context, containerModel))
                .isDefined()
            ? resolvedValue.asString()
            : null;
    final ServiceController.Mode initialMode =
        StartMode.valueOf(
                CacheContainerResourceDefinition.START
                    .resolveModelAttribute(context, containerModel)
                    .asString())
            .getMode();
    final boolean statistics =
        CacheContainerResourceDefinition.STATISTICS_ENABLED
            .resolveModelAttribute(context, containerModel)
            .asBoolean();

    ServiceName[] aliases = null;
    if (containerModel.hasDefined(ModelKeys.ALIASES)) {
      List<ModelNode> list = operation.get(ModelKeys.ALIASES).asList();
      aliases = new ServiceName[list.size()];
      for (int i = 0; i < list.size(); i++) {
        aliases[i] = EmbeddedCacheManagerService.getServiceName(list.get(i).asString());
      }
    }

    final ModuleIdentifier moduleId =
        (resolvedValue =
                    CacheContainerResourceDefinition.MODULE.resolveModelAttribute(
                        context, containerModel))
                .isDefined()
            ? ModuleIdentifier.fromString(resolvedValue.asString())
            : null;

    // if we have a transport defined, pick up the transport-related attributes and install a
    // channel
    final Transport transportConfig =
        containerModel.hasDefined(ModelKeys.TRANSPORT)
                && containerModel.get(ModelKeys.TRANSPORT).hasDefined(ModelKeys.TRANSPORT_NAME)
            ? new Transport()
            : null;

    String stack = null;
    String transportExecutor = null;

    Collection<ServiceController<?>> controllers = new LinkedList<>();

    if (transportConfig != null) {
      ModelNode transport = containerModel.get(ModelKeys.TRANSPORT, ModelKeys.TRANSPORT_NAME);

      stack =
          (resolvedValue =
                      TransportResourceDefinition.STACK.resolveModelAttribute(context, transport))
                  .isDefined()
              ? resolvedValue.asString()
              : null;
      // if cluster is not defined, use the cache container name as the default
      final String cluster =
          (resolvedValue =
                      TransportResourceDefinition.CLUSTER.resolveModelAttribute(context, transport))
                  .isDefined()
              ? resolvedValue.asString()
              : name;
      long lockTimeout =
          TransportResourceDefinition.LOCK_TIMEOUT
              .resolveModelAttribute(context, transport)
              .asLong();
      transportExecutor =
          (resolvedValue =
                      TransportResourceDefinition.EXECUTOR.resolveModelAttribute(
                          context, transport))
                  .isDefined()
              ? resolvedValue.asString()
              : null;

      // initialise the Transport
      transportConfig.setClusterName(cluster);
      transportConfig.setLockTimeout(lockTimeout);

      controllers.addAll(
          this.installChannelServices(target, name, cluster, stack, verificationHandler));

      // register the protocol metrics by adding a step
      ChannelInstanceResourceDefinition.addChannelProtocolMetricsRegistrationStep(
          context, cluster, stack);

      for (ChannelServiceProvider provider :
          ServiceLoader.load(
              ChannelServiceProvider.class, ChannelServiceProvider.class.getClassLoader())) {
        log.debugf("Installing %s for channel %s", provider.getClass().getSimpleName(), cluster);
        controllers.addAll(provider.install(target, name, moduleId));
      }
    }

    // install the cache container configuration service
    controllers.add(
        this.installContainerConfigurationService(
            target,
            name,
            defaultCache,
            statistics,
            moduleId,
            stack,
            transportConfig,
            transportExecutor,
            listenerExecutor,
            evictionExecutor,
            replicationQueueExecutor,
            verificationHandler));

    // install a cache container service
    controllers.add(
        this.installContainerService(
            target, name, aliases, transportConfig, initialMode, verificationHandler));

    // install a name service entry for the cache container
    controllers.add(this.installJndiService(target, name, jndiName, verificationHandler));

    controllers.add(
        this.installKeyAffinityServiceFactoryService(target, name, verificationHandler));

    controllers.add(
        this.installGlobalComponentRegistryService(
            target, name, transportConfig, verificationHandler));

    log.debugf("%s cache container installed", name);
    return controllers;
  }
Exemplo n.º 11
0
  @Override
  protected void performRuntime(
      OperationContext context,
      ModelNode operation,
      ModelNode model,
      ServiceVerificationHandler verificationHandler,
      List<ServiceController<?>> newControllers)
      throws OperationFailedException {
    // Because we use child resources in a read-only manner to configure the cache, replace the
    // local model with the full model
    model = Resource.Tools.readModel(context.readResource(PathAddress.EMPTY_ADDRESS));

    // Configuration to hold the operation data
    ConfigurationBuilder builder =
        new ConfigurationBuilder().read(getDefaultConfiguration(this.mode));

    // create a list for dependencies which may need to be added during processing
    List<Dependency<?>> dependencies = new LinkedList<Dependency<?>>();

    // process cache configuration ModelNode describing overrides to defaults
    processModelNode(model, builder, dependencies);

    // get all required addresses, names and service names
    PathAddress cacheAddress = PathAddress.pathAddress(operation.get(OP_ADDR));
    PathAddress containerAddress = cacheAddress.subAddress(0, cacheAddress.size() - 1);
    String cacheName = cacheAddress.getLastElement().getValue();
    String containerName = containerAddress.getLastElement().getValue();
    ServiceName containerServiceName = EmbeddedCacheManagerService.getServiceName(containerName);
    ServiceName cacheServiceName = containerServiceName.append(cacheName);
    ServiceName cacheConfigurationServiceName =
        CacheConfigurationService.getServiceName(containerName, cacheName);

    // get container Model
    Resource rootResource = context.getRootResource();
    ModelNode container = rootResource.navigate(containerAddress).getModel();

    // get default cache of the container and start mode
    String defaultCache = container.require(ModelKeys.DEFAULT_CACHE).asString();
    ServiceController.Mode initialMode =
        model.hasDefined(ModelKeys.START)
            ? StartMode.valueOf(model.get(ModelKeys.START).asString()).getMode()
            : ServiceController.Mode.ON_DEMAND;

    // install the cache configuration service (configures a cache)
    ServiceTarget target = context.getServiceTarget();
    InjectedValue<EmbeddedCacheManager> containerInjection =
        new InjectedValue<EmbeddedCacheManager>();
    CacheConfigurationDependencies cacheConfigurationDependencies =
        new CacheConfigurationDependencies(containerInjection);
    CacheConfigurationService cacheConfigurationService =
        new CacheConfigurationService(cacheName, builder, cacheConfigurationDependencies);

    ServiceBuilder<Configuration> configBuilder =
        target
            .addService(cacheConfigurationServiceName, cacheConfigurationService)
            .addDependency(containerServiceName, EmbeddedCacheManager.class, containerInjection)
            .setInitialMode(ServiceController.Mode.PASSIVE);

    Configuration config = builder.build();
    if (config.invocationBatching().enabled()) {
      cacheConfigurationDependencies
          .getTransactionManagerInjector()
          .inject(BatchModeTransactionManager.getInstance());
    } else if (config.transaction().transactionMode()
        == org.infinispan.transaction.TransactionMode.TRANSACTIONAL) {
      configBuilder.addDependency(
          TxnServices.JBOSS_TXN_TRANSACTION_MANAGER,
          TransactionManager.class,
          cacheConfigurationDependencies.getTransactionManagerInjector());
      if (config.transaction().useSynchronization()) {
        configBuilder.addDependency(
            TxnServices.JBOSS_TXN_SYNCHRONIZATION_REGISTRY,
            TransactionSynchronizationRegistry.class,
            cacheConfigurationDependencies.getTransactionSynchronizationRegistryInjector());
      }
    }

    // add in any additional dependencies resulting from ModelNode parsing
    for (Dependency<?> dependency : dependencies) {
      this.addDependency(configBuilder, dependency);
    }
    // add an alias for the default cache
    if (cacheName.equals(defaultCache)) {
      configBuilder.addAliases(CacheConfigurationService.getServiceName(containerName, null));
    }
    newControllers.add(configBuilder.install());
    log.debugf(
        "Cache configuration service for %s installed for container %s", cacheName, containerName);

    // now install the corresponding cache service (starts a configured cache)
    CacheDependencies cacheDependencies = new CacheDependencies(containerInjection);
    CacheService<Object, Object> cacheService =
        new CacheService<Object, Object>(cacheName, cacheDependencies);

    ServiceBuilder<Cache<Object, Object>> cacheBuilder =
        target
            .addService(cacheServiceName, cacheService)
            .addDependency(cacheConfigurationServiceName)
            .setInitialMode(initialMode);

    if (config.transaction().recovery().enabled()) {
      cacheBuilder.addDependency(
          TxnServices.JBOSS_TXN_ARJUNA_RECOVERY_MANAGER,
          XAResourceRecoveryRegistry.class,
          cacheDependencies.getRecoveryRegistryInjector());
    }

    // add an alias for the default cache
    if (cacheName.equals(defaultCache)) {
      cacheBuilder.addAliases(CacheService.getServiceName(containerName, null));
    }

    if (initialMode == ServiceController.Mode.ACTIVE) {
      cacheBuilder.addListener(verificationHandler);
    }

    newControllers.add(cacheBuilder.install());

    String jndiName =
        (model.hasDefined(ModelKeys.JNDI_NAME)
                ? InfinispanJndiName.toJndiName(model.get(ModelKeys.JNDI_NAME).asString())
                : InfinispanJndiName.defaultCacheJndiName(containerName, cacheName))
            .getAbsoluteName();
    ContextNames.BindInfo bindInfo = ContextNames.bindInfoFor(jndiName);

    BinderService binder = new BinderService(bindInfo.getBindName());
    @SuppressWarnings("rawtypes")
    ServiceBuilder<ManagedReferenceFactory> binderBuilder =
        target
            .addService(bindInfo.getBinderServiceName(), binder)
            .addAliases(ContextNames.JAVA_CONTEXT_SERVICE_NAME.append(jndiName))
            .addDependency(
                cacheServiceName,
                Cache.class,
                new ManagedReferenceInjector<Cache>(binder.getManagedObjectInjector()))
            .addDependency(
                bindInfo.getParentContextServiceName(),
                ServiceBasedNamingStore.class,
                binder.getNamingStoreInjector())
            .setInitialMode(ServiceController.Mode.PASSIVE);
    newControllers.add(binderBuilder.install());

    log.debugf("Cache service for cache %s installed for container %s", cacheName, containerName);
  }