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);
  }
  static void buildTransformation(
      ModelVersion version, ResourceTransformationDescriptionBuilder builder) {

    StateTransferResourceDefinition.buildTransformation(version, builder);

    if (InfinispanModel.VERSION_4_0_0.requiresTransformation(version)) {
      builder.addChildResource(
          PartitionHandlingResourceDefinition.PATH, new RequiredChildResourceDiscardPolicy());
    } else {
      PartitionHandlingResourceDefinition.buildTransformation(version, builder);
    }

    if (InfinispanModel.VERSION_2_0_0.requiresTransformation(version)) {
      final ResourceTransformationDescriptionBuilder backupsBuilder =
          builder.addChildResource(
              BackupsResourceDefinition.PATH, new RequiredChildResourceDiscardPolicy());
      backupsBuilder.rejectChildResource(BackupResourceDefinition.WILDCARD_PATH);

      builder.addChildResource(
          BackupForResourceDefinition.PATH, new RequiredChildResourceDiscardPolicy());
    } else {
      BackupsResourceDefinition.buildTransformation(version, builder);
      BackupForResourceDefinition.buildTransformation(version, builder);
    }

    ClusteredCacheResourceDefinition.buildTransformation(version, builder);
  }
Example #3
0
 private static TransformationDescription get1_2_0_1_3_0Description() {
   ResourceTransformationDescriptionBuilder builder =
       ResourceTransformationDescriptionBuilder.Factory.createSubsystemInstance();
   builder.rejectChildResource(HttpConnectorResource.PATH);
   protocolTransform(
       builder
           .addChildResource(RemoteOutboundConnectionResourceDefinition.ADDRESS)
           .getAttributeBuilder());
   return builder.build();
 }
  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);
  }
Example #6
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);

    RemoteSiteResourceDefinition.buildTransformation(version, builder);
    PropertyResourceDefinition.buildTransformation(version, builder);
  }
 @Override
 protected void registerResourceTransformers(
     final KnownModelVersion modelVersion,
     final ResourceTransformationDescriptionBuilder resourceBuilder,
     final ResourceTransformationDescriptionBuilder loggingProfileBuilder) {
   switch (modelVersion) {
     case VERSION_2_0_0:
       {
         resourceBuilder.rejectChildResource(PERIODIC_SIZE_ROTATING_HANDLER_PATH);
         if (loggingProfileBuilder != null) {
           loggingProfileBuilder.rejectChildResource(PERIODIC_SIZE_ROTATING_HANDLER_PATH);
         }
         break;
       }
   }
 }
 public static void registerTransformers1_0(
     ResourceTransformationDescriptionBuilder parent, String type) {
   parent
       .addChildResource(PathElement.pathElement(type))
       .getAttributeBuilder()
       .addRejectCheck(
           KeepAliveTimeAttributeDefinition.TRANSFORMATION_CHECKER,
           PoolAttributeDefinitions.KEEPALIVE_TIME);
 }
 static void registerTransformers300(ResourceTransformationDescriptionBuilder parentBuilder) {
   ResourceTransformationDescriptionBuilder builder =
       parentBuilder.addChildResource(PATH_DISTRIBUTED_WORK_MANAGER);
   builder
       .addOperationTransformationOverride("add")
       .inheritResourceAttributeDefinitions()
       .setCustomOperationTransformer(
           new OperationTransformer() {
             @Override
             public TransformedOperation transformOperation(
                 TransformationContext context, PathAddress address, ModelNode operation)
                 throws OperationFailedException {
               ModelNode copy = operation.clone();
               copy.add("transport-jgroups-cluster").set(address.getLastElement().toString());
               return new TransformedOperation(copy, TransformedOperation.ORIGINAL_RESULT);
             }
           })
       .end();
 }
  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.setCustomResourceTransformer(
          new ResourceTransformer() {
            @Override
            public void transformResource(
                ResourceTransformationContext context, PathAddress address, Resource resource)
                throws OperationFailedException {
              final ModelNode model = resource.getModel();

              final ModelNode binaryTableModel =
                  Resource.Tools.readModel(
                      resource.removeChild(BinaryTableResourceDefinition.PATH));
              if (binaryTableModel != null && binaryTableModel.isDefined()) {
                model
                    .get(DeprecatedAttribute.TABLE.getDefinition().getName())
                    .set(binaryTableModel);
              }

              final ModelNode properties =
                  model.remove(
                      StoreResourceDefinition.Attribute.PROPERTIES.getDefinition().getName());
              final ResourceTransformationContext childContext =
                  context.addTransformedResource(PathAddress.EMPTY_ADDRESS, resource);

              LegacyPropertyResourceTransformer.transformPropertiesToChildrenResources(
                  properties, address, childContext);

              context.processChildren(resource);
            }
          });
    }

    BinaryTableResourceDefinition.buildTransformation(version, builder);

    JDBCStoreResourceDefinition.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();
  }
  /**
   * Add the transformers for the async handler.
   *
   * @param subsystemBuilder the default subsystem builder
   * @param loggingProfileBuilder the logging profile builder
   * @return the builder created for the resource
   */
  static ResourceTransformationDescriptionBuilder addTransformers(
      final ResourceTransformationDescriptionBuilder subsystemBuilder,
      final ResourceTransformationDescriptionBuilder loggingProfileBuilder) {
    // Register the logger resource
    final ResourceTransformationDescriptionBuilder child =
        subsystemBuilder
            .addChildResource(ASYNC_HANDLER_PATH)
            .getAttributeBuilder()
            .addRejectCheck(
                RejectAttributeChecker.SIMPLE_EXPRESSIONS, QUEUE_LENGTH, OVERFLOW_ACTION)
            .end()
            .addOperationTransformationOverride(ADD_HANDLER_OPERATION_NAME)
            .setCustomOperationTransformer(LoggingOperationTransformer.INSTANCE)
            .end()
            .addOperationTransformationOverride(REMOVE_HANDLER_OPERATION_NAME)
            .setCustomOperationTransformer(LoggingOperationTransformer.INSTANCE)
            .end();

    // Reject logging profile resources
    loggingProfileBuilder.rejectChildResource(ASYNC_HANDLER_PATH);

    return registerTransformers(child);
  }
 static void registerTransformers110(ResourceTransformationDescriptionBuilder parentBuilder) {
   parentBuilder
       .addChildResource(PATH_DATASOURCE)
       .getAttributeBuilder()
       .setDiscard(
           DiscardAttributeChecker.UNDEFINED,
           org.jboss.as.connector.subsystems.common.pool.Constants.INITIAL_POOL_SIZE,
           URL_DELIMITER,
           CONNECTION_LISTENER_CLASS,
           CONNECTION_LISTENER_PROPERTIES,
           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(DiscardAttributeChecker.ALWAYS, ENABLED)
       .addRejectCheck(RejectAttributeChecker.SIMPLE_EXPRESSIONS, DATASOURCE_PROPERTIES_ATTRIBUTES)
       .addRejectCheck(RejectAttributeChecker.SIMPLE_EXPRESSIONS, DATASOURCE_PROPERTIES_ATTRIBUTES)
       .end();
 }
 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 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);
  }
  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);
  }
 static void registerTransformers1_3_AndBelow(ResourceTransformationDescriptionBuilder parent) {
   ResourceTransformationDescriptionBuilder builder =
       parent.addChildResource(SystemPropertyResourceDefinition.PATH);
   internalRegisterTransformers1_3_AndBelow(builder);
 }
  static void buildTransformation(
      ModelVersion version, ResourceTransformationDescriptionBuilder parent) {
    ResourceTransformationDescriptionBuilder builder = parent.addChildResource(PATH);

    JDBCStoreResourceDefinition.buildTransformation(version, builder);
  }
  static void buildTransformation(
      ModelVersion version, ResourceTransformationDescriptionBuilder parent) {
    ResourceTransformationDescriptionBuilder builder = parent.addChildResource(WILDCARD_PATH);

    SharedStateCacheResourceDefinition.buildTransformation(version, builder);
  }
 public void registerTransformers_2_0(ResourceTransformationDescriptionBuilder builder) {
   builder.addOperationTransformationOverride(NamingSubsystemModel.REBIND).setReject();
 }
  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();
  }
  private static void registerTransformers_1_1_0(final SubsystemRegistration subsystem) {

    final ResourceTransformationDescriptionBuilder subsystemRoot =
        TransformationDescriptionBuilder.Factory.createSubsystemInstance();

    // discard JMS bridge resources added in 1.2.0
    subsystemRoot.rejectChildResource(JMSBridgeDefinition.PATH);
    // discard runtime resources
    subsystemRoot.rejectChildResource(CoreAddressDefinition.PATH);
    subsystemRoot.rejectChildResource(PathElement.pathElement(RUNTIME_QUEUE));

    ResourceTransformationDescriptionBuilder hornetqServer =
        subsystemRoot
            .addChildResource(PathElement.pathElement(HORNETQ_SERVER))
            .getAttributeBuilder()
            .addRejectCheck(
                SIMPLE_EXPRESSIONS,
                HornetQServerResourceDefinition.ATTRIBUTES_WITH_EXPRESSION_ALLOWED_IN_1_2_0)
            .addRejectCheck(DEFINED, HornetQServerResourceDefinition.ATTRIBUTES_ADDED_IN_1_2_0)
            .setDiscard(UNDEFINED, HornetQServerResourceDefinition.ATTRIBUTES_ADDED_IN_1_2_0)
            .setValueConverter(
                AttributeConverter.Factory.createHardCoded(ID_CACHE_SIZE.getDefaultValue(), true),
                ID_CACHE_SIZE)
            .end();

    for (String path : MessagingPathHandlers.PATHS.keySet()) {
      hornetqServer
          .addChildResource(PathElement.pathElement(PATH, path))
          .getAttributeBuilder()
          .addRejectCheck(SIMPLE_EXPRESSIONS, PATH)
          .end();
    }

    for (String path :
        new String[] {CommonAttributes.IN_VM_ACCEPTOR, CommonAttributes.IN_VM_CONNECTOR}) {
      final ResourceTransformationDescriptionBuilder transport =
          hornetqServer
              .addChildResource(PathElement.pathElement(path))
              .getAttributeBuilder()
              .addRejectCheck(
                  SIMPLE_EXPRESSIONS,
                  InVMTransportDefinition.ATTRIBUTES_WITH_EXPRESSION_ALLOWED_IN_1_2_0)
              .end()
              .addOperationTransformationOverride(ADD)
              .inheritResourceAttributeDefinitions()
              .addRejectCheck(
                  SIMPLE_EXPRESSIONS,
                  CommonAttributes.PARAM) // additional attribute to the ADD operation
              .end();
      transport
          .addChildResource(TransportParamDefinition.PATH)
          .getAttributeBuilder()
          .addRejectCheck(
              SIMPLE_EXPRESSIONS,
              TransportParamDefinition.ATTRIBUTES_WITH_EXPRESSION_ALLOWED_IN_1_2_0)
          .end();
    }

    for (String path :
        new String[] {
          CommonAttributes.REMOTE_ACCEPTOR,
          CommonAttributes.REMOTE_CONNECTOR,
          CommonAttributes.ACCEPTOR,
          CommonAttributes.CONNECTOR
        }) {
      final ResourceTransformationDescriptionBuilder transport =
          hornetqServer
              .addChildResource(PathElement.pathElement(path))
              .addOperationTransformationOverride(ADD)
              .inheritResourceAttributeDefinitions()
              .addRejectCheck(
                  SIMPLE_EXPRESSIONS,
                  CommonAttributes.PARAM) // additional attribute to the ADD operation
              .end();
      transport
          .addChildResource(TransportParamDefinition.PATH)
          .getAttributeBuilder()
          .addRejectCheck(
              SIMPLE_EXPRESSIONS,
              TransportParamDefinition.ATTRIBUTES_WITH_EXPRESSION_ALLOWED_IN_1_2_0)
          .end();
    }

    hornetqServer
        .addChildResource(BroadcastGroupDefinition.PATH)
        .getAttributeBuilder()
        .setDiscard(UNDEFINED, BroadcastGroupDefinition.ATTRIBUTES_ADDED_IN_1_2_0)
        .addRejectCheck(DEFINED, BroadcastGroupDefinition.ATTRIBUTES_ADDED_IN_1_2_0)
        .addRejectCheck(
            SIMPLE_EXPRESSIONS,
            BroadcastGroupDefinition.ATTRIBUTES_WITH_EXPRESSION_ALLOWED_IN_1_2_0)
        .end();

    hornetqServer
        .addChildResource(DiscoveryGroupDefinition.PATH)
        .getAttributeBuilder()
        .setDiscard(UNDEFINED, DiscoveryGroupDefinition.ATTRIBUTES_ADDED_IN_1_2_0)
        .addRejectCheck(DEFINED, DiscoveryGroupDefinition.ATTRIBUTES_ADDED_IN_1_2_0)
        .addRejectCheck(
            SIMPLE_EXPRESSIONS,
            DiscoveryGroupDefinition.ATTRIBUTES_WITH_EXPRESSION_ALLOWED_IN_1_2_0)
        .end();

    hornetqServer
        .addChildResource(DivertDefinition.PATH)
        .getAttributeBuilder()
        .addRejectCheck(
            SIMPLE_EXPRESSIONS, DivertDefinition.ATTRIBUTES_WITH_EXPRESSION_ALLOWED_IN_1_2_0)
        .end();

    hornetqServer
        .addChildResource(QueueDefinition.PATH)
        .getAttributeBuilder()
        .addRejectCheck(
            SIMPLE_EXPRESSIONS, QueueDefinition.ATTRIBUTES_WITH_EXPRESSION_ALLOWED_IN_1_2_0)
        .end();

    hornetqServer
        .addChildResource(BridgeDefinition.PATH)
        .getAttributeBuilder()
        .addRejectCheck(
            SIMPLE_EXPRESSIONS, BridgeDefinition.ATTRIBUTES_WITH_EXPRESSION_ALLOWED_IN_1_2_0)
        .end();

    hornetqServer
        .addChildResource(ClusterConnectionDefinition.PATH)
        .getAttributeBuilder()
        .setDiscard(UNDEFINED, ClusterConnectionDefinition.ATTRIBUTES_ADDED_IN_1_2_0)
        .addRejectCheck(DEFINED, ClusterConnectionDefinition.ATTRIBUTES_ADDED_IN_1_2_0)
        .addRejectCheck(
            SIMPLE_EXPRESSIONS,
            ClusterConnectionDefinition.ATTRIBUTES_WITH_EXPRESSION_ALLOWED_IN_1_2_0)
        .end();

    hornetqServer
        .addChildResource(GroupingHandlerDefinition.PATH)
        .getAttributeBuilder()
        .addRejectCheck(
            SIMPLE_EXPRESSIONS,
            GroupingHandlerDefinition.ATTRIBUTES_WITH_EXPRESSION_ALLOWED_IN_1_2_0)
        .end();

    hornetqServer
        .addChildResource(AddressSettingDefinition.PATH)
        .getAttributeBuilder()
        .addRejectCheck(
            SIMPLE_EXPRESSIONS,
            AddressSettingDefinition.ATTRIBUTES_WITH_EXPRESSION_ALLOWED_IN_1_2_0)
        .end();

    ResourceTransformationDescriptionBuilder connectorService =
        hornetqServer.addChildResource(ConnectorServiceDefinition.PATH);

    connectorService
        .addChildResource(ConnectorServiceParamDefinition.PATH)
        .getAttributeBuilder()
        .addRejectCheck(
            SIMPLE_EXPRESSIONS,
            ConnectorServiceParamDefinition.ATTRIBUTES_WITH_EXPRESSION_ALLOWED_IN_1_2_0)
        .end();

    hornetqServer
        .addChildResource(ConnectionFactoryDefinition.PATH)
        .getAttributeBuilder()
        .setDiscard(UNDEFINED, ConnectionFactoryDefinition.ATTRIBUTES_ADDED_IN_1_2_0)
        .addRejectCheck(DEFINED, ConnectionFactoryDefinition.ATTRIBUTES_ADDED_IN_1_2_0)
        .addRejectCheck(
            SIMPLE_EXPRESSIONS,
            ConnectionFactoryDefinition.ATTRIBUTES_WITH_EXPRESSION_ALLOWED_IN_1_2_0)
        .end();

    hornetqServer
        .addChildResource(PooledConnectionFactoryDefinition.PATH)
        .getAttributeBuilder()
        .setDiscard(UNDEFINED, PooledConnectionFactoryDefinition.ATTRIBUTES_ADDED_IN_1_2_0)
        .addRejectCheck(DEFINED, PooledConnectionFactoryDefinition.ATTRIBUTES_ADDED_IN_1_2_0)
        .addRejectCheck(
            SIMPLE_EXPRESSIONS,
            PooledConnectionFactoryDefinition.ATTRIBUTES_WITH_EXPRESSION_ALLOWED_IN_1_2_0)
        .setValueConverter(
            AttributeConverter.Factory.createHardCoded(
                Pooled.RECONNECT_ATTEMPTS.getDefaultValue(), true),
            Pooled.RECONNECT_ATTEMPTS)
        .end();

    hornetqServer
        .addChildResource(JMSQueueDefinition.PATH)
        .getAttributeBuilder()
        .addRejectCheck(
            SIMPLE_EXPRESSIONS, JMSQueueDefinition.ATTRIBUTES_WITH_EXPRESSION_ALLOWED_IN_1_2_0)
        .end();

    hornetqServer
        .addChildResource(JMSTopicDefinition.PATH)
        .getAttributeBuilder()
        .addRejectCheck(
            SIMPLE_EXPRESSIONS, JMSTopicDefinition.ATTRIBUTES_WITH_EXPRESSION_ALLOWED_IN_1_2_0)
        .end();

    TransformationDescription.Tools.register(subsystemRoot.build(), subsystem, VERSION_1_1_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));
  }
Example #25
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);
  }