示例#1
0
  @SuppressWarnings("rawtypes")
  ServiceController<?> installJndiService(
      ServiceTarget target,
      String containerName,
      String cacheName,
      String jndiNameString,
      ServiceVerificationHandler verificationHandler) {

    final String jndiName =
        InfinispanJndiName.createCacheJndiNameOrDefault(jndiNameString, containerName, cacheName);
    final ServiceName cacheServiceName = CacheService.getServiceName(containerName, cacheName);
    final ContextNames.BindInfo bindInfo = ContextNames.bindInfoFor(jndiName);
    final BinderService binder = new BinderService(bindInfo.getBindName());
    return 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)
        .install();
  }
示例#2
0
  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);
  }