static void buildTransformation(
      ModelVersion version, ResourceTransformationDescriptionBuilder builder) {

    if (InfinispanModel.VERSION_4_0_0.requiresTransformation(version)) {
      // Converts pool name to its JNDI name
      Converter converter =
          new Converter() {
            @Override
            public void convert(
                PathAddress address,
                String name,
                ModelNode value,
                ModelNode model,
                TransformationContext context) {
              if (value.isDefined()) {
                PathAddress rootAddress = address.subAddress(0, address.size() - 4);
                PathAddress subsystemAddress =
                    rootAddress.append(
                        PathElement.pathElement(
                            ModelDescriptionConstants.SUBSYSTEM, "datasources"));
                Resource subsystem = context.readResourceFromRoot(subsystemAddress);
                String poolName = value.asString();
                for (String type : Arrays.asList("data-source", "xa-data-source")) {
                  if (subsystem.hasChildren(type)) {
                    for (Resource.ResourceEntry entry : subsystem.getChildren(type)) {
                      if (entry.getName().equals(poolName)) {
                        value.set(entry.getModel().get("jndi-name"));
                        return;
                      }
                    }
                  }
                }
              }
            }
          };
      builder
          .getAttributeBuilder()
          .addRename(Attribute.DATA_SOURCE.getName(), DeprecatedAttribute.DATASOURCE.getName())
          .setValueConverter(
              new SimpleAttributeConverter(converter), Attribute.DATA_SOURCE.getDefinition());
    }

    if (InfinispanModel.VERSION_3_0_0.requiresTransformation(version)) {
      builder
          .addOperationTransformationOverride(ModelDescriptionConstants.ADD)
          .setCustomOperationTransformer(
              new SimpleOperationTransformer(new LegacyPropertyAddOperationTransformer()))
          .inheritResourceAttributeDefinitions();
    }

    if (InfinispanModel.VERSION_2_0_0.requiresTransformation(version)) {
      builder
          .getAttributeBuilder()
          .setDiscard(DiscardAttributeChecker.UNDEFINED, Attribute.DIALECT.getDefinition())
          .addRejectCheck(RejectAttributeChecker.DEFINED, Attribute.DIALECT.getDefinition())
          .end();
    }

    StoreResourceDefinition.buildTransformation(version, builder);
  }
예제 #2
0
  private void registerTransformers_1_1(SubsystemRegistration registration) {

    ResourceTransformationDescriptionBuilder builder =
        ResourceTransformationDescriptionBuilder.Factory.createSubsystemInstance();
    builder
        .getAttributeBuilder()
        .addRejectCheck(
            RejectAttributeChecker.SIMPLE_EXPRESSIONS, RemotingSubsystemRootResource.ATTRIBUTES);

    builder.rejectChildResource(HttpConnectorResource.PATH);

    ResourceTransformationDescriptionBuilder connector =
        builder.addChildResource(ConnectorResource.PATH);
    connector
        .addChildResource(PropertyResource.PATH)
        .getAttributeBuilder()
        .addRejectCheck(RejectAttributeChecker.SIMPLE_EXPRESSIONS, PropertyResource.VALUE);

    ResourceTransformationDescriptionBuilder sasl =
        connector.addChildResource(SaslResource.SASL_CONFIG_PATH);
    sasl.getAttributeBuilder()
        .addRejectCheck(RejectAttributeChecker.SIMPLE_EXPRESSIONS, SaslResource.ATTRIBUTES);
    sasl.addChildResource(SaslPolicyResource.INSTANCE)
        .getAttributeBuilder()
        .addRejectCheck(RejectAttributeChecker.SIMPLE_EXPRESSIONS, SaslPolicyResource.ATTRIBUTES);
    sasl.addChildResource(PropertyResource.PATH)
        .getAttributeBuilder()
        .addRejectCheck(RejectAttributeChecker.SIMPLE_EXPRESSIONS, PropertyResource.VALUE);

    protocolTransform(
            builder
                .addChildResource(RemoteOutboundConnectionResourceDefinition.ADDRESS)
                .getAttributeBuilder())
        .addRejectCheck(
            RejectAttributeChecker.SIMPLE_EXPRESSIONS,
            RemoteOutboundConnectionResourceDefinition.USERNAME)
        .end()
        .addChildResource(PropertyResource.PATH)
        .getAttributeBuilder()
        .addRejectCheck(RejectAttributeChecker.SIMPLE_EXPRESSIONS, PropertyResource.VALUE)
        .end();

    builder
        .addChildResource(LocalOutboundConnectionResourceDefinition.ADDRESS)
        .addChildResource(PropertyResource.PATH)
        .getAttributeBuilder()
        .addRejectCheck(RejectAttributeChecker.SIMPLE_EXPRESSIONS, PropertyResource.VALUE)
        .end();

    builder
        .addChildResource(GenericOutboundConnectionResourceDefinition.ADDRESS)
        .addChildResource(PropertyResource.PATH)
        .getAttributeBuilder()
        .addRejectCheck(RejectAttributeChecker.SIMPLE_EXPRESSIONS, PropertyResource.VALUE)
        .end();

    TransformationDescription.Tools.register(builder.build(), registration, VERSION_1_1);
  }
예제 #3
0
  private void registerTransformers(SubsystemRegistration subsystem) {
    ResourceTransformationDescriptionBuilder builder =
        TransformationDescriptionBuilder.Factory.createSubsystemInstance();

    GlobalModulesRejecterConverter globalModulesRejecterConverter =
        new GlobalModulesRejecterConverter();

    builder
        .getAttributeBuilder()
        // Deal with https://issues.jboss.org/browse/AS7-4892 on 7.1.2
        .addRejectCheck(
            new JBossDescriptorPropertyReplacementRejectChecker(),
            EeSubsystemRootResource.JBOSS_DESCRIPTOR_PROPERTY_REPLACEMENT)
        // Deal with new attributes added to global-modules elements
        .addRejectCheck(globalModulesRejecterConverter, GlobalModulesDefinition.INSTANCE)
        .setValueConverter(globalModulesRejecterConverter, GlobalModulesDefinition.INSTANCE)
        // Deal with new attribute annotation-property-replacement
        .setDiscard(
            new DiscardAttributeChecker.DiscardAttributeValueChecker(new ModelNode(false)),
            EeSubsystemRootResource.ANNOTATION_PROPERTY_REPLACEMENT)
        .addRejectCheck(
            RejectAttributeChecker.DEFINED,
            EeSubsystemRootResource.ANNOTATION_PROPERTY_REPLACEMENT);
    builder.rejectChildResource(PathElement.pathElement(EESubsystemModel.CONTEXT_SERVICE));
    builder.rejectChildResource(PathElement.pathElement(EESubsystemModel.MANAGED_THREAD_FACTORY));
    builder.rejectChildResource(PathElement.pathElement(EESubsystemModel.MANAGED_EXECUTOR_SERVICE));
    builder.rejectChildResource(
        PathElement.pathElement(EESubsystemModel.MANAGED_SCHEDULED_EXECUTOR_SERVICE));
    builder.discardChildResource(EESubsystemModel.DEFAULT_BINDINGS_PATH);

    TransformationDescription.Tools.register(
        builder.build(), subsystem, ModelVersion.create(1, 0, 0));
  }
  static void buildTransformation(
      ModelVersion version, ResourceTransformationDescriptionBuilder parent) {
    ResourceTransformationDescriptionBuilder builder = parent.addChildResource(PATH);

    if (InfinispanModel.VERSION_3_0_0.requiresTransformation(version)) {
      builder
          .getAttributeBuilder()
          .setValueConverter(new DefaultValueAttributeConverter(ISOLATION), ISOLATION);
    }
  }
  static void buildTransformation(
      ModelVersion version, ResourceTransformationDescriptionBuilder parent) {
    ResourceTransformationDescriptionBuilder builder = parent.addChildResource(PATH);

    if (InfinispanModel.VERSION_1_4_0.requiresTransformation(version)) {
      builder
          .getAttributeBuilder()
          .addRejectCheck(
              RejectAttributeChecker.SIMPLE_EXPRESSIONS, CACHE, SOCKET_TIMEOUT, TCP_NO_DELAY);
    }

    StoreResourceDefinition.buildTransformation(version, builder);
  }
  static void buildTransformation(
      ModelVersion version, ResourceTransformationDescriptionBuilder parent) {
    ResourceTransformationDescriptionBuilder builder =
        InfinispanModel.VERSION_4_0_0.requiresTransformation(version)
            ? parent.addChildRedirection(PATH, LEGACY_PATH)
            : parent.addChildResource(PATH);

    if (InfinispanModel.VERSION_4_0_0.requiresTransformation(version)) {
      builder
          .getAttributeBuilder()
          .setValueConverter(
              new AttributeConverter.DefaultAttributeConverter() {
                @Override
                protected void convertAttribute(
                    PathAddress address,
                    String attributeName,
                    ModelNode attributeValue,
                    TransformationContext context) {
                  if (attributeValue.isDefined()) {
                    List<ModelNode> remoteServers = attributeValue.clone().asList();
                    ModelNode legacyListObject = new ModelNode();
                    for (ModelNode server : remoteServers) {
                      ModelNode legacyListItem = new ModelNode();
                      legacyListItem.get("outbound-socket-binding").set(server);
                      legacyListObject.add(legacyListItem);
                    }
                    attributeValue.set(legacyListObject);
                  }
                }
              },
              Attribute.SOCKET_BINDINGS.getDefinition());
    }

    if (InfinispanModel.VERSION_3_0_0.requiresTransformation(version)) {
      builder
          .addOperationTransformationOverride(ModelDescriptionConstants.ADD)
          .setCustomOperationTransformer(
              new SimpleOperationTransformer(new LegacyPropertyAddOperationTransformer()))
          .inheritResourceAttributeDefinitions();

      builder.setCustomResourceTransformer(new LegacyPropertyResourceTransformer());
    }

    StoreResourceDefinition.buildTransformation(version, builder);
  }
  static TransformationDescription buildTransformers(ModelVersion version) {
    ResourceTransformationDescriptionBuilder builder =
        TransformationDescriptionBuilder.Factory.createSubsystemInstance();

    if (JGroupsModel.VERSION_3_0_0.requiresTransformation(version)) {
      builder
          .getAttributeBuilder()
          .setDiscard(DiscardAttributeChecker.UNDEFINED, Attribute.DEFAULT_CHANNEL.getDefinition())
          .addRejectCheck(RejectAttributeChecker.DEFINED, Attribute.DEFAULT_CHANNEL.getDefinition())
          .addRejectCheck(RejectAttributeChecker.UNDEFINED, Attribute.DEFAULT_STACK.getDefinition())
          .end();

      builder.rejectChildResource(ChannelResourceDefinition.WILDCARD_PATH);
    } else {
      ChannelResourceDefinition.buildTransformation(version, builder);
    }

    StackResourceDefinition.buildTransformation(version, builder);

    return builder.build();
  }
 private static void internalRegisterTransformers1_3_AndBelow(
     ResourceTransformationDescriptionBuilder builder) {
   builder
       .getAttributeBuilder()
       .addRejectCheck(
           RejectAttributeChecker.SIMPLE_EXPRESSIONS,
           SystemPropertyResourceDefinition.VALUE,
           SystemPropertyResourceDefinition.BOOT_TIME)
       .setValueConverter(
           new AttributeConverter.DefaultAttributeConverter() {
             @Override
             protected void convertAttribute(
                 PathAddress address,
                 String attributeName,
                 ModelNode attributeValue,
                 TransformationContext context) {
               if (!attributeValue.isDefined()) {
                 attributeValue.set(true);
               }
             }
           },
           BOOT_TIME)
       .end()
       .addRawOperationTransformationOverride(
           UNDEFINE_ATTRIBUTE_OPERATION,
           new OperationTransformer() {
             @Override
             public TransformedOperation transformOperation(
                 TransformationContext context, PathAddress address, ModelNode operation)
                 throws OperationFailedException {
               if (operation.get(NAME).asString().equals(BOOT_TIME)) {
                 ModelNode op = operation.clone();
                 op.get(OP).set(WRITE_ATTRIBUTE_OPERATION);
                 op.get(VALUE).set(true);
                 return new TransformedOperation(op, OperationResultTransformer.ORIGINAL_RESULT);
               }
               return OperationTransformer.DEFAULT.transformOperation(context, address, operation);
             }
           });
 }
  static void registerTransformers111(ResourceTransformationDescriptionBuilder parentBuilder) {
    ResourceTransformationDescriptionBuilder builder =
        parentBuilder.addChildResource(PATH_XA_DATASOURCE);
    builder
        .getAttributeBuilder()
        .setDiscard(
            DiscardAttributeChecker.UNDEFINED,
            org.jboss.as.connector.subsystems.common.pool.Constants.INITIAL_POOL_SIZE,
            CONNECTION_LISTENER_CLASS,
            CONNECTION_LISTENER_PROPERTIES,
            URL_PROPERTY,
            org.jboss.as.connector.subsystems.common.pool.Constants.CAPACITY_INCREMENTER_CLASS,
            org.jboss.as.connector.subsystems.common.pool.Constants.CAPACITY_DECREMENTER_CLASS,
            org.jboss.as.connector.subsystems.common.pool.Constants.CAPACITY_INCREMENTER_PROPERTIES,
            org.jboss.as.connector.subsystems.common.pool.Constants.CAPACITY_DECREMENTER_PROPERTIES)
        .setDiscard(
            new DiscardAttributeChecker() {

              @Override
              public boolean isDiscardExpressions() {
                return false;
              }

              @Override
              public boolean isDiscardUndefined() {
                return true;
              }

              @Override
              public boolean isOperationParameterDiscardable(
                  PathAddress address,
                  String attributeName,
                  ModelNode attributeValue,
                  ModelNode operation,
                  TransformationContext context) {
                return false;
              }

              @Override
              public boolean isResourceAttributeDiscardable(
                  PathAddress address,
                  String attributeName,
                  ModelNode attributeValue,
                  TransformationContext context) {
                return true;
              }
            },
            ENABLED)
        .addRejectCheck(
            RejectAttributeChecker.DEFINED,
            org.jboss.as.connector.subsystems.common.pool.Constants.INITIAL_POOL_SIZE,
            CONNECTION_LISTENER_CLASS,
            CONNECTION_LISTENER_PROPERTIES,
            URL_PROPERTY,
            org.jboss.as.connector.subsystems.common.pool.Constants.CAPACITY_INCREMENTER_CLASS,
            org.jboss.as.connector.subsystems.common.pool.Constants.CAPACITY_DECREMENTER_CLASS,
            org.jboss.as.connector.subsystems.common.pool.Constants.CAPACITY_INCREMENTER_PROPERTIES,
            org.jboss.as.connector.subsystems.common.pool.Constants.CAPACITY_DECREMENTER_PROPERTIES)
        .end();
    builder
        .addOperationTransformationOverride(ModelDescriptionConstants.WRITE_ATTRIBUTE_OPERATION)
        .inheritResourceAttributeDefinitions()
        .setCustomOperationTransformer(ENABLE_TRANSFORMER)
        .end()
        .addOperationTransformationOverride(ModelDescriptionConstants.UNDEFINE_ATTRIBUTE_OPERATION)
        .inheritResourceAttributeDefinitions()
        .setCustomOperationTransformer(ENABLE_TRANSFORMER)
        .end();
  }
예제 #10
0
  private void registerTransformers(SubsystemRegistration subsystemRegistration) {
    ResourceTransformationDescriptionBuilder builder =
        TransformationDescriptionBuilder.Factory.createSubsystemInstance();
    ResourceTransformationDescriptionBuilder securityDomain =
        builder.addChildResource(SECURITY_DOMAIN_PATH);

    final ModulesToAttributeTransformer loginModule =
        new ModulesToAttributeTransformer(Constants.LOGIN_MODULE, Constants.LOGIN_MODULES);
    ResourceTransformationDescriptionBuilder child =
        securityDomain
            .addChildResource(PATH_CLASSIC_AUTHENTICATION)
            .setCustomResourceTransformer(loginModule)
            .addOperationTransformationOverride(ModelDescriptionConstants.ADD)
            .setCustomOperationTransformer(loginModule)
            .inheritResourceAttributeDefinitions()
            .end();
    child.discardChildResource(PathElement.pathElement(Constants.LOGIN_MODULE));

    final ModulesToAttributeTransformer policyModule =
        new ModulesToAttributeTransformer(Constants.POLICY_MODULE, Constants.POLICY_MODULES);

    child =
        securityDomain
            .addChildResource(PATH_AUTHORIZATION_CLASSIC)
            .setCustomResourceTransformer(policyModule)
            .addOperationTransformationOverride(ModelDescriptionConstants.ADD)
            .setCustomOperationTransformer(policyModule)
            .inheritResourceAttributeDefinitions()
            .end();
    child.discardChildResource(PathElement.pathElement(Constants.POLICY_MODULE));

    final ModulesToAttributeTransformer mappingModule =
        new ModulesToAttributeTransformer(Constants.MAPPING_MODULE, Constants.MAPPING_MODULES);

    child =
        securityDomain
            .addChildResource(PATH_MAPPING_CLASSIC)
            .setCustomResourceTransformer(mappingModule)
            .addOperationTransformationOverride(ModelDescriptionConstants.ADD)
            .setCustomOperationTransformer(mappingModule)
            .inheritResourceAttributeDefinitions()
            .end();
    child.discardChildResource(PathElement.pathElement(Constants.MAPPING_MODULE));

    final ModulesToAttributeTransformer providerModule =
        new ModulesToAttributeTransformer(Constants.PROVIDER_MODULE, Constants.PROVIDER_MODULES);

    child =
        securityDomain
            .addChildResource(PATH_AUDIT_CLASSIC)
            .setCustomResourceTransformer(providerModule)
            .addOperationTransformationOverride(ModelDescriptionConstants.ADD)
            .setCustomOperationTransformer(providerModule)
            .inheritResourceAttributeDefinitions()
            .end();
    child.discardChildResource(PathElement.pathElement(Constants.PROVIDER_MODULE));

    final ModulesToAttributeTransformer authModule =
        new ModulesToAttributeTransformer(Constants.AUTH_MODULE, Constants.AUTH_MODULES);

    ResourceTransformationDescriptionBuilder jaspiReg =
        securityDomain.addChildResource(PATH_JASPI_AUTH);
    jaspiReg
        .setCustomResourceTransformer(authModule)
        .addOperationTransformationOverride(ModelDescriptionConstants.ADD)
        .setCustomOperationTransformer(authModule)
        .inheritResourceAttributeDefinitions()
        .end();
    jaspiReg.discardChildResource(PathElement.pathElement(Constants.AUTH_MODULE));

    child =
        jaspiReg
            .addChildResource(PATH_LOGIN_MODULE_STACK)
            .setCustomResourceTransformer(loginModule)
            .addOperationTransformationOverride(ModelDescriptionConstants.ADD)
            .setCustomOperationTransformer(loginModule)
            .inheritResourceAttributeDefinitions()
            .end();
    child.discardChildResource(PathElement.pathElement(Constants.LOGIN_MODULE));

    // reject expressions
    securityDomain
        .getAttributeBuilder()
        .addRejectCheck(
            RejectAttributeChecker.SIMPLE_EXPRESSIONS, SecurityDomainResourceDefinition.CACHE_TYPE)
        .end();
    builder
        .addChildResource(VAULT_PATH)
        .getAttributeBuilder()
        .addRejectCheck(RejectAttributeChecker.SIMPLE_EXPRESSIONS, VaultResourceDefinition.CODE)
        .addRejectCheck(
            RejectAttributeChecker.SIMPLE_LIST_EXPRESSIONS, VaultResourceDefinition.OPTIONS)
        .end();
    builder
        .addChildResource(JSSE_PATH)
        .getAttributeBuilder()
        .addRejectCheck(
            new RejectAttributeChecker.ObjectFieldsRejectAttributeChecker(
                Collections.singletonMap(
                    JSSEResourceDefinition.ADDITIONAL_PROPERTIES.getName(),
                    RejectAttributeChecker.SIMPLE_EXPRESSIONS)),
            JSSEResourceDefinition.ADDITIONAL_PROPERTIES)
        .end();

    TransformationDescription.Tools.register(
        builder.build(), subsystemRegistration, ModelVersion.create(1, 1, 0));
  }
예제 #11
0
  private static void registerTransformers_1_2_0(final SubsystemRegistration subsystem) {

    final ResourceTransformationDescriptionBuilder subsystemRoot =
        TransformationDescriptionBuilder.Factory.createSubsystemInstance();
    ResourceTransformationDescriptionBuilder hornetqServer =
        subsystemRoot.addChildResource(PathElement.pathElement(HORNETQ_SERVER));
    hornetqServer
        .getAttributeBuilder()
        .setDiscard(
            new DiscardAttributeChecker() {
              @Override
              public boolean isDiscardExpressions() {
                return false;
              }

              @Override
              public boolean isDiscardUndefined() {
                return true;
              }

              @Override
              public boolean isOperationParameterDiscardable(
                  PathAddress address,
                  String attributeName,
                  ModelNode attributeValue,
                  ModelNode operation,
                  TransformationContext context) {

                // The 'clustered' attribute is not recognized on 1.4.0. It's only supported for
                // compatibility
                // with 1.3 or earlier servers, so we discard it for 1.4. For 1.4 servers, see if
                // the desired
                // value conflicts with the actual configuration, and if so log a transformation
                // warning
                // before discarding

                // the real clustered HornetQ state
                Set<String> clusterConnectionNames =
                    context
                        .readResource(PathAddress.EMPTY_ADDRESS)
                        .getChildrenNames(ClusterConnectionDefinition.PATH.getKey());
                boolean clustered = !clusterConnectionNames.isEmpty();
                // whether the user wants the server to be clustered
                // We use a short-cut vs AD.resolveModelValue to avoid having to hack in an
                // OperationContext
                // This is ok since the attribute doesn't support expressions
                // Treat 'undefined' as 'ignore this and match the actual config' instead of the
                // legacy default 'false'
                boolean wantsClustered = attributeValue.asBoolean(clustered);
                if (clustered && !wantsClustered) {
                  PathAddress serverAddress = PathAddress.pathAddress(operation.get(OP_ADDR));
                  String msg =
                      MessagingMessages.MESSAGES.canNotChangeClusteredAttribute(serverAddress);
                  context
                      .getLogger()
                      .logAttributeWarning(serverAddress, operation, msg, CLUSTERED.getName());
                }
                return true;
              }

              @Override
              public boolean isResourceAttributeDiscardable(
                  PathAddress address,
                  String attributeName,
                  ModelNode attributeValue,
                  TransformationContext context) {
                return true;
              }
            },
            CommonAttributes.CLUSTERED)
        .end();
    TransformationDescription.Tools.register(subsystemRoot.build(), subsystem, VERSION_1_2_0);
  }