Пример #1
0
  /**
   * Transfer elements common to both operations and models
   *
   * @param fromModel
   * @param toModel
   */
  void populate(ModelNode fromModel, ModelNode toModel) throws OperationFailedException {

    CacheResourceDefinition.START.validateAndSet(fromModel, toModel);
    CacheResourceDefinition.BATCHING.validateAndSet(fromModel, toModel);
    CacheResourceDefinition.INDEXING.validateAndSet(fromModel, toModel);
    CacheResourceDefinition.JNDI_NAME.validateAndSet(fromModel, toModel);
    CacheResourceDefinition.CACHE_MODULE.validateAndSet(fromModel, toModel);
    CacheResourceDefinition.INDEXING_PROPERTIES.validateAndSet(fromModel, toModel);
  }
Пример #2
0
  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 =
                    CacheResourceDefinition.JNDI_NAME.resolveModelAttribute(context, cacheModel))
                .isDefined())
            ? resolvedValue.asString()
            : null;
    final ServiceController.Mode initialMode =
        StartMode.valueOf(
                CacheResourceDefinition.START.resolveModelAttribute(context, cacheModel).asString())
            .getMode();

    final ModuleIdentifier moduleId =
        (resolvedValue =
                    CacheResourceDefinition.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 =
        CacheContainerResourceDefinition.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,
            InfinispanJndiName.createCacheJndiName(jndiName, containerName, cacheName),
            verificationHandler));
    log.debugf("Cache service for cache %s installed for container %s", cacheName, containerName);

    return controllers;
  }