Search in sources :

Example 56 with ResourceTransformationDescriptionBuilder

use of org.jboss.as.controller.transform.description.ResourceTransformationDescriptionBuilder in project wildfly by wildfly.

the class StackResourceDefinition method buildTransformation.

static void buildTransformation(ModelVersion version, ResourceTransformationDescriptionBuilder parent) {
    ResourceTransformationDescriptionBuilder builder = parent.addChildResource(WILDCARD_PATH);
    if (JGroupsModel.VERSION_3_0_0.requiresTransformation(version)) {
        // Create legacy "protocols" attributes, which lists protocols by name
        ResourceTransformer transformer = new ResourceTransformer() {

            @Override
            public void transformResource(ResourceTransformationContext context, PathAddress address, Resource resource) throws OperationFailedException {
                for (String name : resource.getChildrenNames(ProtocolResourceDefinition.WILDCARD_PATH.getKey())) {
                    resource.getModel().get(PROTOCOLS.getName()).add(name);
                }
                context.addTransformedResource(PathAddress.EMPTY_ADDRESS, resource).processChildren(resource);
            }
        };
        builder.setCustomResourceTransformer(transformer);
    }
    if (JGroupsModel.VERSION_2_0_0.requiresTransformation(version)) {
        builder.rejectChildResource(RelayResourceDefinition.PATH);
    } else {
        RelayResourceDefinition.buildTransformation(version, builder);
    }
    TransportResourceDefinition.buildTransformation(version, builder);
    ProtocolRegistration.buildTransformation(version, builder);
}
Also used : PathAddress(org.jboss.as.controller.PathAddress) Resource(org.jboss.as.controller.registry.Resource) ResourceTransformationDescriptionBuilder(org.jboss.as.controller.transform.description.ResourceTransformationDescriptionBuilder) ResourceTransformer(org.jboss.as.controller.transform.ResourceTransformer) ResourceTransformationContext(org.jboss.as.controller.transform.ResourceTransformationContext)

Example 57 with ResourceTransformationDescriptionBuilder

use of org.jboss.as.controller.transform.description.ResourceTransformationDescriptionBuilder in project wildfly by wildfly.

the class JGroupsSubsystemResourceDefinition method buildTransformers.

static TransformationDescription buildTransformers(ModelVersion version) {
    ResourceTransformationDescriptionBuilder builder = TransformationDescriptionBuilder.Factory.createSubsystemInstance();
    if (JGroupsModel.VERSION_3_0_0.requiresTransformation(version)) {
        builder.getAttributeBuilder().setDiscard(DiscardAttributeChecker.ALWAYS, Attribute.DEFAULT_CHANNEL.getDefinition()).end();
    }
    ChannelResourceDefinition.buildTransformation(version, builder);
    StackResourceDefinition.buildTransformation(version, builder);
    return builder.build();
}
Also used : ResourceTransformationDescriptionBuilder(org.jboss.as.controller.transform.description.ResourceTransformationDescriptionBuilder)

Example 58 with ResourceTransformationDescriptionBuilder

use of org.jboss.as.controller.transform.description.ResourceTransformationDescriptionBuilder in project wildfly by wildfly.

the class PropertyResourceDefinition method buildTransformation.

static void buildTransformation(ModelVersion version, ResourceTransformationDescriptionBuilder parent) {
    ResourceTransformationDescriptionBuilder builder = parent.addChildResource(WILDCARD_PATH);
    if (JGroupsModel.VERSION_3_0_0.requiresTransformation(version)) {
        builder.setCustomResourceTransformer(new SimpleResourceTransformer(LEGACY_ADDRESS_TRANSFORMER));
        builder.addOperationTransformationOverride(ModelDescriptionConstants.ADD).setCustomOperationTransformer(new SimpleAddOperationTransformer(LEGACY_ADDRESS_TRANSFORMER).addAttributes(new SimpleAttribute(VALUE))).inheritResourceAttributeDefinitions();
        builder.addOperationTransformationOverride(ModelDescriptionConstants.REMOVE).setCustomOperationTransformer(new SimpleRemoveOperationTransformer(LEGACY_ADDRESS_TRANSFORMER));
        builder.addOperationTransformationOverride(ModelDescriptionConstants.READ_ATTRIBUTE_OPERATION).setCustomOperationTransformer(new SimpleReadAttributeOperationTransformer(LEGACY_ADDRESS_TRANSFORMER));
        builder.addOperationTransformationOverride(ModelDescriptionConstants.WRITE_ATTRIBUTE_OPERATION).setCustomOperationTransformer(new SimpleWriteAttributeOperationTransformer(LEGACY_ADDRESS_TRANSFORMER));
        builder.addOperationTransformationOverride(ModelDescriptionConstants.UNDEFINE_ATTRIBUTE_OPERATION).setCustomOperationTransformer(new SimpleUndefineAttributeOperationTransformer(LEGACY_ADDRESS_TRANSFORMER));
        builder.addOperationTransformationOverride(ModelDescriptionConstants.DESCRIBE).setCustomOperationTransformer(new SimpleDescribeOperationTransformer(LEGACY_ADDRESS_TRANSFORMER));
    }
}
Also used : SimpleAddOperationTransformer(org.jboss.as.clustering.controller.transform.SimpleAddOperationTransformer) SimpleRemoveOperationTransformer(org.jboss.as.clustering.controller.transform.SimpleRemoveOperationTransformer) SimpleReadAttributeOperationTransformer(org.jboss.as.clustering.controller.transform.SimpleReadAttributeOperationTransformer) SimpleWriteAttributeOperationTransformer(org.jboss.as.clustering.controller.transform.SimpleWriteAttributeOperationTransformer) SimpleAttribute(org.jboss.as.clustering.controller.SimpleAttribute) SimpleUndefineAttributeOperationTransformer(org.jboss.as.clustering.controller.transform.SimpleUndefineAttributeOperationTransformer) ResourceTransformationDescriptionBuilder(org.jboss.as.controller.transform.description.ResourceTransformationDescriptionBuilder) SimpleDescribeOperationTransformer(org.jboss.as.clustering.controller.transform.SimpleDescribeOperationTransformer) SimpleResourceTransformer(org.jboss.as.clustering.controller.transform.SimpleResourceTransformer)

Example 59 with ResourceTransformationDescriptionBuilder

use of org.jboss.as.controller.transform.description.ResourceTransformationDescriptionBuilder in project wildfly by wildfly.

the class EeExtension method registerTransformers.

private void registerTransformers(SubsystemRegistration subsystem) {
    final ModelVersion v1_0_0 = ModelVersion.create(1, 0, 0);
    final ModelVersion v1_1_0 = ModelVersion.create(1, 1, 0);
    final ModelVersion v3_0_0 = ModelVersion.create(3, 0, 0);
    ChainedTransformationDescriptionBuilder chainedBuilder = TransformationDescriptionBuilder.Factory.createChainedSubystemInstance(subsystem.getSubsystemVersion());
    ResourceTransformationDescriptionBuilder builder_3_0 = chainedBuilder.createBuilder(subsystem.getSubsystemVersion(), v3_0_0);
    ManagedExecutorServiceResourceDefinition.INSTANCE.registerTransformers_4_0(builder_3_0);
    ManagedScheduledExecutorServiceResourceDefinition.INSTANCE.registerTransformers_4_0(builder_3_0);
    // 3.0.0 --> 1.1.0
    ResourceTransformationDescriptionBuilder builder11 = chainedBuilder.createBuilder(v3_0_0, v1_1_0);
    builder11.rejectChildResource(PathElement.pathElement(EESubsystemModel.CONTEXT_SERVICE));
    builder11.rejectChildResource(PathElement.pathElement(EESubsystemModel.MANAGED_THREAD_FACTORY));
    builder11.rejectChildResource(PathElement.pathElement(EESubsystemModel.MANAGED_EXECUTOR_SERVICE));
    builder11.rejectChildResource(PathElement.pathElement(EESubsystemModel.MANAGED_SCHEDULED_EXECUTOR_SERVICE));
    builder11.discardChildResource(EESubsystemModel.DEFAULT_BINDINGS_PATH);
    // 1.1.0 --> 1.0.0
    ResourceTransformationDescriptionBuilder builder = chainedBuilder.createBuilder(v1_1_0, v1_0_0);
    GlobalModulesRejecterConverter globalModulesRejecterConverter = new GlobalModulesRejecterConverter();
    builder.getAttributeBuilder().addRejectCheck(new JBossDescriptorPropertyReplacementRejectChecker(), EeSubsystemRootResource.JBOSS_DESCRIPTOR_PROPERTY_REPLACEMENT).addRejectCheck(globalModulesRejecterConverter, GlobalModulesDefinition.INSTANCE).setValueConverter(globalModulesRejecterConverter, GlobalModulesDefinition.INSTANCE).setDiscard(new DiscardAttributeChecker.DiscardAttributeValueChecker(new ModelNode(false)), EeSubsystemRootResource.ANNOTATION_PROPERTY_REPLACEMENT).addRejectCheck(RejectAttributeChecker.DEFINED, EeSubsystemRootResource.ANNOTATION_PROPERTY_REPLACEMENT);
    chainedBuilder.buildAndRegister(subsystem, new ModelVersion[] { v1_0_0, v1_1_0, v3_0_0 });
}
Also used : ChainedTransformationDescriptionBuilder(org.jboss.as.controller.transform.description.ChainedTransformationDescriptionBuilder) ResourceTransformationDescriptionBuilder(org.jboss.as.controller.transform.description.ResourceTransformationDescriptionBuilder) ModelVersion(org.jboss.as.controller.ModelVersion) ModelNode(org.jboss.dmr.ModelNode)

Example 60 with ResourceTransformationDescriptionBuilder

use of org.jboss.as.controller.transform.description.ResourceTransformationDescriptionBuilder in project wildfly by wildfly.

the class ManagedExecutorServiceResourceDefinition method registerTransformers_4_0.

void registerTransformers_4_0(final ResourceTransformationDescriptionBuilder builder) {
    final PathElement pathElement = getPathElement();
    final ResourceTransformationDescriptionBuilder resourceBuilder = builder.addChildResource(pathElement);
    resourceBuilder.getAttributeBuilder().addRejectCheck(RejectAttributeChecker.UNDEFINED, CORE_THREADS_AD).end();
}
Also used : PathElement(org.jboss.as.controller.PathElement) ResourceTransformationDescriptionBuilder(org.jboss.as.controller.transform.description.ResourceTransformationDescriptionBuilder)

Aggregations

ResourceTransformationDescriptionBuilder (org.jboss.as.controller.transform.description.ResourceTransformationDescriptionBuilder)93 ModelNode (org.jboss.dmr.ModelNode)46 PathAddress (org.jboss.as.controller.PathAddress)25 DiscardAttributeChecker (org.jboss.as.controller.transform.description.DiscardAttributeChecker)24 TransformationContext (org.jboss.as.controller.transform.TransformationContext)15 SimpleOperationTransformer (org.jboss.as.clustering.controller.transform.SimpleOperationTransformer)9 LegacyPropertyResourceTransformer (org.jboss.as.clustering.controller.transform.LegacyPropertyResourceTransformer)7 ModelVersion (org.jboss.as.controller.ModelVersion)7 Resource (org.jboss.as.controller.registry.Resource)7 ChainedTransformationDescriptionBuilder (org.jboss.as.controller.transform.description.ChainedTransformationDescriptionBuilder)7 ResourceTransformationContext (org.jboss.as.controller.transform.ResourceTransformationContext)6 ResourceTransformer (org.jboss.as.controller.transform.ResourceTransformer)6 AttributeConverter (org.jboss.as.controller.transform.description.AttributeConverter)6 Map (java.util.Map)4 LegacyPropertyAddOperationTransformer (org.jboss.as.clustering.controller.transform.LegacyPropertyAddOperationTransformer)4 OperationTransformer (org.jboss.as.clustering.controller.transform.OperationTransformer)4 OperationFailedException (org.jboss.as.controller.OperationFailedException)4 PathElement (org.jboss.as.controller.PathElement)4 RejectAttributeChecker (org.jboss.as.controller.transform.description.RejectAttributeChecker)4 LinkedList (java.util.LinkedList)2