示例#1
0
  /**
   * Transfer elements common to both operations and models
   *
   * @param fromModel
   * @param toModel
   */
  void populate(ModelNode fromModel, ModelNode toModel) throws OperationFailedException {

    CommonAttributes.START.validateAndSet(fromModel, toModel);
    CommonAttributes.BATCHING.validateAndSet(fromModel, toModel);
    CommonAttributes.INDEXING.validateAndSet(fromModel, toModel);
    CommonAttributes.JNDI_NAME.validateAndSet(fromModel, toModel);
    CommonAttributes.CACHE_MODULE.validateAndSet(fromModel, toModel);
    CommonAttributes.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 = 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;
  }