Search in sources :

Example 1 with LegacyPropertyResourceTransformer

use of org.jboss.as.clustering.controller.transform.LegacyPropertyResourceTransformer in project wildfly by wildfly.

the class FileStoreResourceDefinition method buildTransformation.

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_3_0_0.requiresTransformation(version)) {
        builder.addOperationTransformationOverride(ModelDescriptionConstants.ADD).setCustomOperationTransformer(new SimpleOperationTransformer(new LegacyPropertyAddOperationTransformer())).inheritResourceAttributeDefinitions();
        builder.setCustomResourceTransformer(new LegacyPropertyResourceTransformer());
    }
    StoreResourceDefinition.buildTransformation(version, builder);
}
Also used : LegacyPropertyResourceTransformer(org.jboss.as.clustering.controller.transform.LegacyPropertyResourceTransformer) LegacyPropertyAddOperationTransformer(org.jboss.as.clustering.controller.transform.LegacyPropertyAddOperationTransformer) ResourceTransformationDescriptionBuilder(org.jboss.as.controller.transform.description.ResourceTransformationDescriptionBuilder) SimpleOperationTransformer(org.jboss.as.clustering.controller.transform.SimpleOperationTransformer)

Example 2 with LegacyPropertyResourceTransformer

use of org.jboss.as.clustering.controller.transform.LegacyPropertyResourceTransformer in project wildfly by wildfly.

the class RemoteStoreResourceDefinition method buildTransformation.

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);
}
Also used : AttributeConverter(org.jboss.as.controller.transform.description.AttributeConverter) LegacyPropertyResourceTransformer(org.jboss.as.clustering.controller.transform.LegacyPropertyResourceTransformer) LegacyPropertyAddOperationTransformer(org.jboss.as.clustering.controller.transform.LegacyPropertyAddOperationTransformer) PathAddress(org.jboss.as.controller.PathAddress) ResourceTransformationDescriptionBuilder(org.jboss.as.controller.transform.description.ResourceTransformationDescriptionBuilder) SimpleOperationTransformer(org.jboss.as.clustering.controller.transform.SimpleOperationTransformer) List(java.util.List) ModelNode(org.jboss.dmr.ModelNode) TransformationContext(org.jboss.as.controller.transform.TransformationContext)

Example 3 with LegacyPropertyResourceTransformer

use of org.jboss.as.clustering.controller.transform.LegacyPropertyResourceTransformer in project wildfly by wildfly.

the class TransportResourceDefinition method buildTransformation.

static void buildTransformation(ModelVersion version, ResourceTransformationDescriptionBuilder parent) {
    ResourceTransformationDescriptionBuilder builder = parent.addChildResource(WILDCARD_PATH);
    AbstractProtocolResourceDefinition.addTransformations(version, builder);
    if (JGroupsModel.VERSION_3_0_0.requiresTransformation(version)) {
        builder.getAttributeBuilder().setValueConverter(new DefaultValueAttributeConverter(Attribute.SHARED.getDefinition()), Attribute.SHARED.getDefinition());
        builder.setCustomResourceTransformer(new ResourceTransformer() {

            @Override
            public void transformResource(ResourceTransformationContext context, PathAddress address, Resource resource) throws OperationFailedException {
                new LegacyPropertyResourceTransformer().transformResource(context, LEGACY_ADDRESS_TRANSFORMER.transform(address), resource);
            }
        });
        builder.addOperationTransformationOverride(ModelDescriptionConstants.ADD).setCustomOperationTransformer(new SimpleOperationTransformer(new org.jboss.as.clustering.controller.transform.OperationTransformer() {

            @Override
            public ModelNode transformOperation(final ModelNode operation) {
                operation.get(ModelDescriptionConstants.OP_ADDR).set(LEGACY_ADDRESS_TRANSFORMER.transform(Operations.getPathAddress(operation)).toModelNode());
                return new LegacyPropertyAddOperationTransformer().transformOperation(operation);
            }
        })).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.DESCRIBE).setCustomOperationTransformer(new SimpleDescribeOperationTransformer(LEGACY_ADDRESS_TRANSFORMER));
        List<OperationTransformer> getOpTransformerChain = new LinkedList<>();
        getOpTransformerChain.add(new SimplePathOperationTransformer(LEGACY_ADDRESS_TRANSFORMER));
        getOpTransformerChain.add(new SimpleOperationTransformer(new LegacyPropertyMapGetOperationTransformer()));
        ChainedOperationTransformer getOpChainedTransformer = new ChainedOperationTransformer(getOpTransformerChain, false);
        builder.addRawOperationTransformationOverride(MapOperations.MAP_GET_DEFINITION.getName(), getOpChainedTransformer);
        List<OperationTransformer> writeOpTransformerChain = new LinkedList<>();
        writeOpTransformerChain.add(new SimplePathOperationTransformer(LEGACY_ADDRESS_TRANSFORMER));
        writeOpTransformerChain.add(new LegacyPropertyWriteOperationTransformer());
        ChainedOperationTransformer writeOpChainedTransformer = new ChainedOperationTransformer(writeOpTransformerChain, false);
        for (String opName : Operations.getAllWriteAttributeOperationNames()) {
            builder.addOperationTransformationOverride(opName).inheritResourceAttributeDefinitions().setCustomOperationTransformer(writeOpChainedTransformer);
        }
        // Reject thread pool configuration, discard if undefined, support EAP 6.x slaves using deprecated attributes
        builder.addChildResource(ThreadPoolResourceDefinition.WILDCARD_PATH, RequiredChildResourceDiscardPolicy.REJECT_AND_WARN);
    } else {
        EnumSet.allOf(ThreadPoolResourceDefinition.class).forEach(p -> p.buildTransformation(version, parent));
    }
}
Also used : SimpleRemoveOperationTransformer(org.jboss.as.clustering.controller.transform.SimpleRemoveOperationTransformer) LegacyPropertyMapGetOperationTransformer(org.jboss.as.clustering.controller.transform.LegacyPropertyMapGetOperationTransformer) LegacyPropertyWriteOperationTransformer(org.jboss.as.clustering.controller.transform.LegacyPropertyWriteOperationTransformer) LegacyPropertyResourceTransformer(org.jboss.as.clustering.controller.transform.LegacyPropertyResourceTransformer) LegacyPropertyAddOperationTransformer(org.jboss.as.clustering.controller.transform.LegacyPropertyAddOperationTransformer) SimpleReadAttributeOperationTransformer(org.jboss.as.clustering.controller.transform.SimpleReadAttributeOperationTransformer) SimplePathOperationTransformer(org.jboss.as.clustering.controller.transform.SimplePathOperationTransformer) OperationTransformer(org.jboss.as.controller.transform.OperationTransformer) SimpleDescribeOperationTransformer(org.jboss.as.clustering.controller.transform.SimpleDescribeOperationTransformer) LegacyPropertyAddOperationTransformer(org.jboss.as.clustering.controller.transform.LegacyPropertyAddOperationTransformer) ChainedOperationTransformer(org.jboss.as.clustering.controller.transform.ChainedOperationTransformer) LegacyPropertyWriteOperationTransformer(org.jboss.as.clustering.controller.transform.LegacyPropertyWriteOperationTransformer) SimpleRemoveOperationTransformer(org.jboss.as.clustering.controller.transform.SimpleRemoveOperationTransformer) LegacyPropertyMapGetOperationTransformer(org.jboss.as.clustering.controller.transform.LegacyPropertyMapGetOperationTransformer) SimpleOperationTransformer(org.jboss.as.clustering.controller.transform.SimpleOperationTransformer) SimplePathOperationTransformer(org.jboss.as.clustering.controller.transform.SimplePathOperationTransformer) SimpleReadAttributeOperationTransformer(org.jboss.as.clustering.controller.transform.SimpleReadAttributeOperationTransformer) Resource(org.jboss.as.controller.registry.Resource) OperationFailedException(org.jboss.as.controller.OperationFailedException) SimpleDescribeOperationTransformer(org.jboss.as.clustering.controller.transform.SimpleDescribeOperationTransformer) ResourceTransformationContext(org.jboss.as.controller.transform.ResourceTransformationContext) LinkedList(java.util.LinkedList) ChainedOperationTransformer(org.jboss.as.clustering.controller.transform.ChainedOperationTransformer) PathAddress(org.jboss.as.controller.PathAddress) ResourceTransformationDescriptionBuilder(org.jboss.as.controller.transform.description.ResourceTransformationDescriptionBuilder) DefaultValueAttributeConverter(org.jboss.as.controller.transform.description.AttributeConverter.DefaultValueAttributeConverter) SimpleOperationTransformer(org.jboss.as.clustering.controller.transform.SimpleOperationTransformer) ResourceTransformer(org.jboss.as.controller.transform.ResourceTransformer) LegacyPropertyResourceTransformer(org.jboss.as.clustering.controller.transform.LegacyPropertyResourceTransformer) ModelNode(org.jboss.dmr.ModelNode)

Example 4 with LegacyPropertyResourceTransformer

use of org.jboss.as.clustering.controller.transform.LegacyPropertyResourceTransformer in project wildfly by wildfly.

the class ProtocolResourceDefinition method addTransformations.

static void addTransformations(ModelVersion version, ResourceTransformationDescriptionBuilder builder) {
    AbstractProtocolResourceDefinition.addTransformations(version, builder);
    if (JGroupsModel.VERSION_4_1_0.requiresTransformation(version)) {
        // See WFLY-6782, add-index parameter was missing from add operation definition
        builder.getAttributeBuilder().addRejectCheck(RejectAttributeChecker.DEFINED, ModelDescriptionConstants.ADD_INDEX);
    }
    if (JGroupsModel.VERSION_3_0_0.requiresTransformation(version)) {
        // Translate /subsystem=jgroups/stack=*/protocol=*:add() -> /subsystem=jgroups/stack=*:add-protocol()
        OperationTransformer addTransformer = new OperationTransformer() {

            @Override
            public ModelNode transformOperation(ModelNode operation) {
                PathAddress address = Operations.getPathAddress(operation);
                PathAddress stackAddress = address.subAddress(0, address.size() - 1);
                ModelNode addProtocolOp = operation.clone();
                addProtocolOp.get(ModelDescriptionConstants.OP_ADDR).set(stackAddress.toModelNode());
                addProtocolOp.get(ModelDescriptionConstants.OP).set("add-protocol");
                addProtocolOp = new LegacyPropertyAddOperationTransformer().transformOperation(addProtocolOp);
                return addProtocolOp;
            }
        };
        builder.addOperationTransformationOverride(ModelDescriptionConstants.ADD).setCustomOperationTransformer(new SimpleOperationTransformer(addTransformer)).inheritResourceAttributeDefinitions();
        // Translate /subsystem=jgroups/stack=*/protocol=*:remove() -> /subsystem=jgroups/stack=*:remove-protocol()
        OperationTransformer removeTransformer = new OperationTransformer() {

            @SuppressWarnings("deprecation")
            @Override
            public ModelNode transformOperation(ModelNode operation) {
                PathAddress address = Operations.getPathAddress(operation);
                String protocol = address.getLastElement().getValue();
                PathAddress stackAddress = address.subAddress(0, address.size() - 1);
                ModelNode legacyOperation = Util.createOperation("remove-protocol", stackAddress);
                legacyOperation.get(AbstractProtocolResourceDefinition.DeprecatedAttribute.TYPE.getName()).set(protocol);
                return legacyOperation;
            }
        };
        builder.addOperationTransformationOverride(ModelDescriptionConstants.REMOVE).setCustomOperationTransformer(new SimpleOperationTransformer(removeTransformer));
        builder.setCustomResourceTransformer(new LegacyPropertyResourceTransformer());
    }
}
Also used : LegacyPropertyResourceTransformer(org.jboss.as.clustering.controller.transform.LegacyPropertyResourceTransformer) LegacyPropertyAddOperationTransformer(org.jboss.as.clustering.controller.transform.LegacyPropertyAddOperationTransformer) SimpleOperationTransformer(org.jboss.as.clustering.controller.transform.SimpleOperationTransformer) OperationTransformer(org.jboss.as.clustering.controller.transform.OperationTransformer) LegacyPropertyAddOperationTransformer(org.jboss.as.clustering.controller.transform.LegacyPropertyAddOperationTransformer) PathAddress(org.jboss.as.controller.PathAddress) SimpleOperationTransformer(org.jboss.as.clustering.controller.transform.SimpleOperationTransformer) ModelNode(org.jboss.dmr.ModelNode)

Example 5 with LegacyPropertyResourceTransformer

use of org.jboss.as.clustering.controller.transform.LegacyPropertyResourceTransformer in project wildfly by wildfly.

the class CustomStoreResourceDefinition method buildTransformation.

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_3_0_0.requiresTransformation(version)) {
        builder.addOperationTransformationOverride(ModelDescriptionConstants.ADD).setCustomOperationTransformer(new SimpleOperationTransformer(new LegacyPropertyAddOperationTransformer())).inheritResourceAttributeDefinitions();
        builder.setCustomResourceTransformer(new LegacyPropertyResourceTransformer());
    }
    StoreResourceDefinition.buildTransformation(version, builder);
}
Also used : LegacyPropertyResourceTransformer(org.jboss.as.clustering.controller.transform.LegacyPropertyResourceTransformer) LegacyPropertyAddOperationTransformer(org.jboss.as.clustering.controller.transform.LegacyPropertyAddOperationTransformer) ResourceTransformationDescriptionBuilder(org.jboss.as.controller.transform.description.ResourceTransformationDescriptionBuilder) SimpleOperationTransformer(org.jboss.as.clustering.controller.transform.SimpleOperationTransformer)

Aggregations

LegacyPropertyAddOperationTransformer (org.jboss.as.clustering.controller.transform.LegacyPropertyAddOperationTransformer)5 LegacyPropertyResourceTransformer (org.jboss.as.clustering.controller.transform.LegacyPropertyResourceTransformer)5 SimpleOperationTransformer (org.jboss.as.clustering.controller.transform.SimpleOperationTransformer)5 ResourceTransformationDescriptionBuilder (org.jboss.as.controller.transform.description.ResourceTransformationDescriptionBuilder)4 PathAddress (org.jboss.as.controller.PathAddress)3 ModelNode (org.jboss.dmr.ModelNode)3 LinkedList (java.util.LinkedList)1 List (java.util.List)1 ChainedOperationTransformer (org.jboss.as.clustering.controller.transform.ChainedOperationTransformer)1 LegacyPropertyMapGetOperationTransformer (org.jboss.as.clustering.controller.transform.LegacyPropertyMapGetOperationTransformer)1 LegacyPropertyWriteOperationTransformer (org.jboss.as.clustering.controller.transform.LegacyPropertyWriteOperationTransformer)1 OperationTransformer (org.jboss.as.clustering.controller.transform.OperationTransformer)1 SimpleDescribeOperationTransformer (org.jboss.as.clustering.controller.transform.SimpleDescribeOperationTransformer)1 SimplePathOperationTransformer (org.jboss.as.clustering.controller.transform.SimplePathOperationTransformer)1 SimpleReadAttributeOperationTransformer (org.jboss.as.clustering.controller.transform.SimpleReadAttributeOperationTransformer)1 SimpleRemoveOperationTransformer (org.jboss.as.clustering.controller.transform.SimpleRemoveOperationTransformer)1 OperationFailedException (org.jboss.as.controller.OperationFailedException)1 Resource (org.jboss.as.controller.registry.Resource)1 OperationTransformer (org.jboss.as.controller.transform.OperationTransformer)1 ResourceTransformationContext (org.jboss.as.controller.transform.ResourceTransformationContext)1