Package org.jboss.as.controller.transform

Examples of org.jboss.as.controller.transform.TransformersSubRegistration


        final ModelVersion version110 = ModelVersion.create(1, 1, 0);
        final RejectExpressionValuesTransformer TRANSFORMER = new RejectExpressionValuesTransformer(PropertyResource.VALUE,
                TransportResource.PROPERTIES, ProtocolResource.PROPERTIES, TransportResource.SHARED);

        final TransformersSubRegistration registration = subsystem.registerModelTransformers(version110, ResourceTransformer.DEFAULT);
        final TransformersSubRegistration stack = registration.registerSubResource(StackResource.STACK_PATH);

        // reject expressions for transport properties, for the add and write-attribute op
        final TransformersSubRegistration transport = stack.registerSubResource(TransportResource.TRANSPORT_PATH, (ResourceTransformer)TRANSFORMER) ;
        transport.registerOperationTransformer(ADD, TRANSFORMER);
        transport.registerOperationTransformer(WRITE_ATTRIBUTE_OPERATION, TRANSFORMER.getWriteAttributeTransformer());
        final TransformersSubRegistration transport_property = transport.registerSubResource(PropertyResource.PROPERTY_PATH) ;
        transport_property.registerOperationTransformer(ADD, TRANSFORMER);
        transport_property.registerOperationTransformer(WRITE_ATTRIBUTE_OPERATION, TRANSFORMER.getWriteAttributeTransformer());

        // reject expressions for transport properties, for the add and write-attribute op
        final TransformersSubRegistration protocol = stack.registerSubResource(ProtocolResource.PROTOCOL_PATH, (ResourceTransformer)TRANSFORMER) ;
        protocol.registerOperationTransformer(ADD, TRANSFORMER);
        final TransformersSubRegistration protocol_property = protocol.registerSubResource(PropertyResource.PROPERTY_PATH) ;
        protocol_property.registerOperationTransformer(ADD, TRANSFORMER);
        protocol_property.registerOperationTransformer(WRITE_ATTRIBUTE_OPERATION, TRANSFORMER.getWriteAttributeTransformer());

    }
View Full Code Here


         * @param description the transformation description.
         * @param parent the parent registration
         * @return the created sub registration
         */
        public static TransformersSubRegistration register(final TransformationDescription description, TransformersSubRegistration parent) {
            final TransformersSubRegistration registration =
                    parent.registerSubResource(
                            description.getPath(),
                            description.getPathAddressTransformer(),
                            description.getResourceTransformer(),
                            description.getOperationTransformer(),
                            description.isInherited());
            for (final Map.Entry<String, OperationTransformer> entry : description.getOperationTransformers().entrySet()) {
                registration.registerOperationTransformer(entry.getKey(), entry.getValue());
            }
            registration.discardOperations(description.getDiscardedOperations().toArray(new String[description.getDiscardedOperations().size()]));
            for (final TransformationDescription child : description.getChildren()) {
                register(child, registration);
            }
            return registration;
        }
View Full Code Here

         * @param registration the subsystem registrations
         * @param range the model version range the transformation applies to
         * @return the create sub registration
         */
        public static TransformersSubRegistration register(TransformationDescription description, SubsystemRegistration registration, ModelVersionRange range) {
            final TransformersSubRegistration subRegistration = registration.registerModelTransformers(range, description.getResourceTransformer(), description.getOperationTransformer());
            for (final Map.Entry<String, OperationTransformer> entry : description.getOperationTransformers().entrySet()) {
                subRegistration.registerOperationTransformer(entry.getKey(), entry.getValue());
            }
            for (final TransformationDescription child : description.getChildren()) {
                register(child, subRegistration);
            }
            subRegistration.discardOperations(description.getDiscardedOperations().toArray(new String[description.getDiscardedOperations().size()]));
            return subRegistration;
        }
View Full Code Here

        registerTransformers_1_1_0(subsystem);
    }

    private void registerTransformers_1_1_0(SubsystemRegistration registration) {

        final TransformersSubRegistration transformers = registration.registerModelTransformers(ModelVersion.create(1, 1, 0), ResourceTransformer.DEFAULT);

        TransformersSubRegistration connectors = transformers.registerSubResource(CONNECTOR_PATH);
        connectors.registerOperationTransformer(ADD, new OperationTransformer() {
            @Override
            public TransformedOperation transformOperation(final TransformationContext context, final PathAddress address, final ModelNode operation)
                    throws OperationFailedException {

                //Don't error on the way out, it might be ignored on the slave
                final boolean hasDefinedVirtualServer = operation.hasDefined(Constants.VIRTUAL_SERVER);
                return new TransformedOperation(operation, new OperationResultTransformer() {

                    @Override
                    public ModelNode transformResult(ModelNode result) {
                        if (!hasDefinedVirtualServer) {
                            return result;
                        }
                        if (result.get(OUTCOME).asString().equals(FAILED)) {
                            result.get(FAILURE_DESCRIPTION).set(WebMessages.MESSAGES.transformationVersion_1_1_0_JBPAPP_9314());
                        }
                        return result;
                    }
                });
            }
        });
        connectors.registerOperationTransformer(WRITE_ATTRIBUTE_OPERATION, new OperationTransformer() {

            @Override
            public TransformedOperation transformOperation(final TransformationContext context, final PathAddress address, final ModelNode operation)
                    throws OperationFailedException {
View Full Code Here

        return op;
    }

    private void registerTransformers1_0_0(SubsystemRegistration registration) {
        // Register the transformers
        final TransformersSubRegistration transformers = registration.registerModelTransformers(ModelVersion.create(1, 0, 0), new ResourceTransformer() {
            @Override
            public void transformResource(ResourceTransformationContext context, PathAddress address, Resource resource) throws OperationFailedException {
                ModelNode model = resource.getModel();

                //The existance of the expose-model=>resolved child is translated into the show-model=>true attribute
                Resource exposeResolvedResource = resource.getChild(PathElement.pathElement(CommonAttributes.EXPOSE_MODEL, CommonAttributes.RESOLVED));
                boolean showModel = false;
                if (exposeResolvedResource != null) {
                     showModel = model.isDefined();
                }
                model.get(CommonAttributes.SHOW_MODEL).set(showModel);
                ResourceTransformationContext childContext = context.addTransformedResource(PathAddress.EMPTY_ADDRESS, resource);

                //Process all the child resources skipping the expose-model=>* children
                for (String type :resource.getChildTypes()) {
                    if (!type.equals(CommonAttributes.EXPOSE_MODEL)) {
                        for (ResourceEntry child : resource.getChildren(type)) {
                            childContext.processChild(child.getPathElement(), child);
                        }
                    }
                }
            }
        });


        TransformersSubRegistration expressions = transformers.registerSubResource(ExposeModelResourceExpression.INSTANCE.getPathElement());

        expressions.discardOperations(ADD, REMOVE, WRITE_ATTRIBUTE_OPERATION, READ_ATTRIBUTE_OPERATION);

        TransformersSubRegistration resolved = transformers.registerSubResource(ExposeModelResourceResolved.INSTANCE.getPathElement());
        resolved.discardOperations(WRITE_ATTRIBUTE_OPERATION);
        resolved.registerOperationTransformer(ADD, new AbstractOperationTransformer() {
            @Override
            protected ModelNode transform(TransformationContext context, PathAddress address, ModelNode operation) {
                ModelNode node = new ModelNode();
                node.get(OP).set(WRITE_ATTRIBUTE_OPERATION);
                node.get(OP_ADDR).set(address.subAddress(0, address.size() - 1).toModelNode());
                node.get(NAME).set(CommonAttributes.SHOW_MODEL);
                node.get(VALUE).set(true);
                return node;
            }
        });

        resolved.registerOperationTransformer(REMOVE, new AbstractOperationTransformer() {
            @Override
            protected ModelNode transform(TransformationContext context, PathAddress address, ModelNode operation) {
                ModelNode node = new ModelNode();
                node.get(OP).set(WRITE_ATTRIBUTE_OPERATION);
                node.get(OP_ADDR).set(address.subAddress(0, address.size() - 1).toModelNode());
                node.get(NAME).set(CommonAttributes.SHOW_MODEL);
                node.get(VALUE).set(false);
                return node;
            }
        });
        resolved.registerOperationTransformer(READ_ATTRIBUTE_OPERATION, new OperationTransformer() {

            @Override
            public TransformedOperation transformOperation(final TransformationContext context, final PathAddress address, final ModelNode operation) {
                return new TransformedOperation(null, new OperationResultTransformer() {
                    @Override
                    public ModelNode transformResult(ModelNode result) {
                        if (operation.get(NAME).asString().equals(CommonAttributes.DOMAIN_NAME)) {
                            result.get(RESULT).set(CommonAttributes.DEFAULT_RESOLVED_DOMAIN);
                        }
                        result.get(OUTCOME).set(SUCCESS);
                        result.get(RESULT);
                        return result;
                    }
                });
            }
        });

        RejectExpressionValuesTransformer rejectTransformer = new RejectExpressionValuesTransformer(RemotingConnectorResource.USE_MANAGEMENT_ENDPOINT);
        TransformersSubRegistration remoting = transformers.registerSubResource(RemotingConnectorResource.REMOTE_CONNECTOR_CONFIG_PATH,
                (ResourceTransformer) rejectTransformer);
        remoting.registerOperationTransformer(ADD, rejectTransformer);
        remoting.registerOperationTransformer(WRITE_ATTRIBUTE_OPERATION, rejectTransformer.getWriteAttributeTransformer());
    }
View Full Code Here

* @author <a href="http://jmesnil.net">Jeff Mesnil</a> (c) 2012 Red Hat, inc
*/
public class PropertyResourceTransformers {

    static TransformersSubRegistration registerTransformers(TransformersSubRegistration parent) {
        TransformersSubRegistration property = parent.registerSubResource(PropertyResource.PATH);
        RejectExpressionValuesTransformer rejectPropertyExpression = new RejectExpressionValuesTransformer(PropertyResource.VALUE);
        property.registerOperationTransformer(ADD, rejectPropertyExpression);
        property.registerOperationTransformer(WRITE_ATTRIBUTE_OPERATION, rejectPropertyExpression.getWriteAttributeTransformer());

        return property;
    }
View Full Code Here

* @author <a href="http://jmesnil.net">Jeff Mesnil</a> (c) 2012 Red Hat, inc
*/
public class SaslPolicyResourceTransformers {

    static TransformersSubRegistration registerTransformers(TransformersSubRegistration parent) {
        TransformersSubRegistration policy = parent.registerSubResource(SASL_POLICY_CONFIG_PATH);
        RejectExpressionValuesTransformer rejectExpression = new RejectExpressionValuesTransformer(FORWARD_SECRECY,
                NO_ACTIVE, NO_ANONYMOUS, NO_DICTIONARY, NO_PLAIN_TEXT, PASS_CREDENTIALS);
        policy.registerOperationTransformer(ADD, rejectExpression);
        policy.registerOperationTransformer(WRITE_ATTRIBUTE_OPERATION, rejectExpression.getWriteAttributeTransformer());

        return policy;
    }
View Full Code Here

* @author <a href="http://jmesnil.net">Jeff Mesnil</a> (c) 2012 Red Hat, inc
*/
public class SaslResourceTransformers {

    static TransformersSubRegistration registerTransformers(TransformersSubRegistration parent) {
        TransformersSubRegistration sasl = parent.registerSubResource(SASL_CONFIG_PATH);
        RejectExpressionValuesTransformer rejectPropertyExpression = new RejectExpressionValuesTransformer(SERVER_AUTH_ATTRIBUTE, REUSE_SESSION_ATTRIBUTE);
        sasl.registerOperationTransformer(ADD, rejectPropertyExpression);
        sasl.registerOperationTransformer(WRITE_ATTRIBUTE_OPERATION, rejectPropertyExpression.getWriteAttributeTransformer());

        SaslPolicyResourceTransformers.registerTransformers(sasl);
        PropertyResourceTransformers.registerTransformers(sasl);

        return sasl;
View Full Code Here

    }

    private void registerTransformers_1_1(SubsystemRegistration registration) {

        RejectExpressionValuesTransformer rejectExpression = new RejectExpressionValuesTransformer(RemotingSubsystemRootResource.ATTRIBUTES);
        final TransformersSubRegistration subsystem = registration.registerModelTransformers(VERSION_1_1, rejectExpression);
        subsystem.registerOperationTransformer(ADD, rejectExpression);
        subsystem.registerOperationTransformer(WRITE_ATTRIBUTE_OPERATION, rejectExpression.getWriteAttributeTransformer());

        TransformersSubRegistration connector = subsystem.registerSubResource(ConnectorResource.PATH);
        PropertyResourceTransformers.registerTransformers(connector);
        SaslResourceTransformers.registerTransformers(connector);

        TransformersSubRegistration remoteOutboundConnection = subsystem.registerSubResource(RemoteOutboundConnectionResourceDefinition.ADDRESS);
        RejectExpressionValuesTransformer rejectUserNameExpression = new RejectExpressionValuesTransformer(RemoteOutboundConnectionResourceDefinition.USERNAME);
        remoteOutboundConnection.registerOperationTransformer(ADD, rejectUserNameExpression);
        remoteOutboundConnection.registerOperationTransformer(WRITE_ATTRIBUTE_OPERATION, rejectUserNameExpression.getWriteAttributeTransformer());

        PropertyResourceTransformers.registerTransformers(remoteOutboundConnection);

        TransformersSubRegistration localOutboundConnection = subsystem.registerSubResource(LocalOutboundConnectionResourceDefinition.ADDRESS);
        PropertyResourceTransformers.registerTransformers(localOutboundConnection);

        TransformersSubRegistration outboundConnection = subsystem.registerSubResource(GenericOutboundConnectionResourceDefinition.ADDRESS);
        PropertyResourceTransformers.registerTransformers(outboundConnection);
    }
View Full Code Here

        initializeDomainRegistry(registry, VERSION_1_3);
        initializeDomainRegistry(registry, VERSION_1_4);
    }

    private static void initializeDomainRegistry(TransformerRegistry registry, ModelVersion modelVersion) {
        TransformersSubRegistration domain = registry.getDomainRegistration(modelVersion);
        if (modelVersion == VERSION_1_2 || modelVersion == VERSION_1_3) {
            // Discard all operations to the newly introduced jsf extension
            domain.registerSubResource(JSF_EXTENSION, IGNORED_EXTENSIONS);

            JSFSubsystemTransformers.registerTransformers120(registry, domain);
            PathsTransformers.registerTransformers120(domain);
            DeploymentTransformers.registerTransformers120(domain);
            SystemPropertyTransformers.registerTransformers120(domain);
            SocketBindingGroupTransformers.registerTransformers120(domain);
            ServerGroupTransformers.registerTransformers120(domain);

            //Add the domain interface and path name. This is from a read attribute handler but in < 1.4.0 it existed in the model
            domain.registerSubResource(PathElement.pathElement(INTERFACE), AddNameFromAddressResourceTransformer.INSTANCE);
            domain.registerSubResource(PathElement.pathElement(PATH), AddNameFromAddressResourceTransformer.INSTANCE);

        } else if (modelVersion == VERSION_1_4) {
            //TODO not sure if these should be handled here for 1.4.0 or if it is better in the tests?
            //Add the domain interface name. This is currently from a read attribute handler but in < 1.4.0 it existed in the model
            domain.registerSubResource(PathElement.pathElement(INTERFACE), AddNameFromAddressResourceTransformer.INSTANCE);
            domain.registerSubResource(PathElement.pathElement(PATH), AddNameFromAddressResourceTransformer.INSTANCE);
        }
    }
View Full Code Here

TOP

Related Classes of org.jboss.as.controller.transform.TransformersSubRegistration

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.