Search in sources :

Example 76 with ResourceTransformationDescriptionBuilder

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

the class IIOPRootDefinition method registerTransformers_1_0_0.

private static void registerTransformers_1_0_0(SubsystemRegistration subsystemRegistration) {
    final ResourceTransformationDescriptionBuilder builder = TransformationDescriptionBuilder.Factory.createSubsystemInstance();
    TransformationDescription.Tools.register(builder.build(), subsystemRegistration, VERSION_1);
}
Also used : ResourceTransformationDescriptionBuilder(org.jboss.as.controller.transform.description.ResourceTransformationDescriptionBuilder)

Example 77 with ResourceTransformationDescriptionBuilder

use of org.jboss.as.controller.transform.description.ResourceTransformationDescriptionBuilder 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)

Example 78 with ResourceTransformationDescriptionBuilder

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

the class BackupsResourceDefinition method buildTransformation.

static void buildTransformation(ModelVersion version, ResourceTransformationDescriptionBuilder parent) {
    PathAddressTransformer addressTransformer = new PathAddressTransformer() {

        @Override
        public PathAddress transform(PathElement current, Builder builder) {
            return builder.next();
        }
    };
    ResourceTransformationDescriptionBuilder builder = InfinispanModel.VERSION_4_0_0.requiresTransformation(version) ? parent.addChildRedirection(PATH, addressTransformer) : parent.addChildResource(PATH);
    BackupResourceDefinition.buildTransformation(version, builder);
}
Also used : PathElement(org.jboss.as.controller.PathElement) ResourceTransformationDescriptionBuilder(org.jboss.as.controller.transform.description.ResourceTransformationDescriptionBuilder) ResourceTransformationDescriptionBuilder(org.jboss.as.controller.transform.description.ResourceTransformationDescriptionBuilder) PathAddressTransformer(org.jboss.as.controller.transform.PathAddressTransformer)

Example 79 with ResourceTransformationDescriptionBuilder

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

the class BinaryKeyedJDBCStoreResourceDefinition 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.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.getName()).set(binaryTableModel);
                }
                final ModelNode properties = model.remove(StoreResourceDefinition.Attribute.PROPERTIES.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);
}
Also used : PathAddress(org.jboss.as.controller.PathAddress) Resource(org.jboss.as.controller.registry.Resource) OperationFailedException(org.jboss.as.controller.OperationFailedException) ResourceTransformationDescriptionBuilder(org.jboss.as.controller.transform.description.ResourceTransformationDescriptionBuilder) LegacyPropertyResourceTransformer(org.jboss.as.clustering.controller.transform.LegacyPropertyResourceTransformer) ResourceTransformer(org.jboss.as.controller.transform.ResourceTransformer) ModelNode(org.jboss.dmr.ModelNode) ResourceTransformationContext(org.jboss.as.controller.transform.ResourceTransformationContext)

Example 80 with ResourceTransformationDescriptionBuilder

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

the class CacheContainerResourceDefinition method buildTransformation.

static void buildTransformation(ModelVersion version, ResourceTransformationDescriptionBuilder parent) {
    ResourceTransformationDescriptionBuilder builder = parent.addChildResource(WILDCARD_PATH);
    if (InfinispanModel.VERSION_4_0_0.requiresTransformation(version)) {
        builder.discardChildResource(NoTransportResourceDefinition.PATH);
        EnumSet.allOf(ThreadPoolResourceDefinition.class).forEach(pool -> builder.addChildResource(pool.getPathElement(), pool.getDiscardPolicy()));
        EnumSet.allOf(ScheduledThreadPoolResourceDefinition.class).forEach(pool -> builder.addChildResource(pool.getPathElement(), pool.getDiscardPolicy()));
    } else {
        NoTransportResourceDefinition.buildTransformation(version, builder);
        EnumSet.allOf(ThreadPoolResourceDefinition.class).forEach(pool -> pool.buildTransformation(version, parent));
        EnumSet.allOf(ScheduledThreadPoolResourceDefinition.class).forEach(pool -> pool.buildTransformation(version, parent));
    }
    if (InfinispanModel.VERSION_3_0_0.requiresTransformation(version)) {
        OperationTransformer addAliasTransformer = new OperationTransformer() {

            @Override
            public ModelNode transformOperation(ModelNode operation) {
                String attributeName = Operations.getAttributeName(operation);
                if (Attribute.ALIASES.getName().equals(attributeName)) {
                    ModelNode value = Operations.getAttributeValue(operation);
                    PathAddress address = Operations.getPathAddress(operation);
                    ModelNode transformedOperation = Util.createOperation(ALIAS_ADD, address);
                    transformedOperation.get(ALIAS.getName()).set(value);
                    return transformedOperation;
                }
                return operation;
            }
        };
        builder.addRawOperationTransformationOverride(ListOperations.LIST_ADD_DEFINITION.getName(), new SimpleOperationTransformer(addAliasTransformer));
        OperationTransformer removeAliasTransformer = new OperationTransformer() {

            @Override
            public ModelNode transformOperation(ModelNode operation) {
                String attributeName = Operations.getAttributeName(operation);
                if (Attribute.ALIASES.getName().equals(attributeName)) {
                    ModelNode value = Operations.getAttributeValue(operation);
                    PathAddress address = Operations.getPathAddress(operation);
                    ModelNode transformedOperation = Util.createOperation(ALIAS_REMOVE, address);
                    transformedOperation.get(ALIAS.getName()).set(value);
                    return transformedOperation;
                }
                return operation;
            }
        };
        builder.addRawOperationTransformationOverride(ListOperations.LIST_REMOVE_DEFINITION.getName(), new SimpleOperationTransformer(removeAliasTransformer));
    }
    if (InfinispanModel.VERSION_1_5_0.requiresTransformation(version)) {
        builder.getAttributeBuilder().setDiscard(new DiscardAttributeChecker.DiscardAttributeValueChecker(false, false, new ModelNode(true)), Attribute.STATISTICS_ENABLED.getDefinition()).addRejectCheck(RejectAttributeChecker.UNDEFINED, Attribute.STATISTICS_ENABLED.getDefinition()).addRejectCheck(RejectAttributeChecker.SIMPLE_EXPRESSIONS, Attribute.STATISTICS_ENABLED.getDefinition()).addRejectCheck(new RejectAttributeChecker.SimpleRejectAttributeChecker(new ModelNode(false)), Attribute.STATISTICS_ENABLED.getDefinition());
    }
    JGroupsTransportResourceDefinition.buildTransformation(version, builder);
    DistributedCacheResourceDefinition.buildTransformation(version, builder);
    ReplicatedCacheResourceDefinition.buildTransformation(version, builder);
    InvalidationCacheResourceDefinition.buildTransformation(version, builder);
    LocalCacheResourceDefinition.buildTransformation(version, builder);
}
Also used : OperationTransformer(org.jboss.as.clustering.controller.transform.OperationTransformer) SimpleOperationTransformer(org.jboss.as.clustering.controller.transform.SimpleOperationTransformer) PathAddress(org.jboss.as.controller.PathAddress) ResourceTransformationDescriptionBuilder(org.jboss.as.controller.transform.description.ResourceTransformationDescriptionBuilder) SimpleOperationTransformer(org.jboss.as.clustering.controller.transform.SimpleOperationTransformer) ModelNode(org.jboss.dmr.ModelNode) RejectAttributeChecker(org.jboss.as.controller.transform.description.RejectAttributeChecker)

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