Пример #1
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 ChainedTransformationDescriptionBuilder buildTransformerChain(
      ModelVersion currentVersion) {
    ChainedTransformationDescriptionBuilder chainedBuilder =
        TransformationDescriptionBuilder.Factory.createChainedInstance(
            SystemPropertyResourceDefinition.PATH, currentVersion);

    ResourceTransformationDescriptionBuilder builder =
        chainedBuilder.createBuilder(currentVersion, DomainTransformers.VERSION_1_3);
    internalRegisterTransformers1_3_AndBelow(builder);

    return chainedBuilder;
  }
  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();
  }
Пример #4
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));
  }
Пример #5
0
  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);
  }
Пример #6
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);
  }