Search in sources :

Example 16 with PathAddress

use of org.jboss.as.controller.PathAddress in project wildfly by wildfly.

the class LegacyConfigAdjuster640 method removeBV.

/**
     * WildFly 9 and later broke BV out from the ee subsystem, allowing it to be removed. If a later
     * DC/standalone server sees ee with a legacy xsd, it adds BV into the config, thus assuring that
     * a migrated config does not, perhaps not noticeably, lose existing behavior. But a 6.x slave
     * will not recognize the BV extension/subsystem, so it needs to be removed.
     */
private void removeBV(DomainClient client, PathAddress profileAddress, List<ModelNode> ops) throws IOException, MgmtOperationException {
    PathAddress bv = profileAddress.append(PathElement.pathElement(ModelDescriptionConstants.SUBSYSTEM, "bean-validation"));
    ops.add(Util.createRemoveOperation(bv));
    // If no other profiles still use this extension, we can remove it
    String ourProfile = profileAddress.getLastElement().getValue();
    ModelNode read = Util.createEmptyOperation("read-children-names", PathAddress.EMPTY_ADDRESS);
    read.get("child-type").set("profile");
    for (ModelNode profileMN : DomainTestUtils.executeForResult(read, client).asList()) {
        String profile = profileMN.asString();
        if (!ourProfile.equals(profile)) {
            read = Util.createEmptyOperation("read-children-names", PathAddress.pathAddress("profile", profile));
            read.get("child-type").set("subsystem");
            for (ModelNode sub : DomainTestUtils.executeForResult(read, client).asList()) {
                if ("bean-validation".equals(sub.asString())) {
                    // this profile still has a subsystem; don't remove extension yet
                    return;
                }
            }
        }
    }
    // If we got here, no profile has the bv subsystem so we can remove the extension
    ops.add(Util.createRemoveOperation(PathAddress.pathAddress("extension", "org.wildfly.extension.bean-validation")));
}
Also used : PathAddress(org.jboss.as.controller.PathAddress) ModelNode(org.jboss.dmr.ModelNode)

Example 17 with PathAddress

use of org.jboss.as.controller.PathAddress in project wildfly by wildfly.

the class DomainAdjuster700 method adjustUndertow.

private void adjustUndertow(PathAddress undertow, List<ModelNode> ops) {
    // EAP 7.0 and earlier required explicit SSL configuration. Wildfly 10.1 added support
    // for SSL by default, which automatically generates certs.
    // This could be removed if all hosts were configured to contain a security domain with SSL
    // enabled.
    final PathAddress httpsListener = undertow.append("server", "default-server").append("https-listener", "https");
    ops.add(Util.getEmptyOperation(ModelDescriptionConstants.REMOVE, httpsListener.toModelNode()));
    //This enables jndi, ejb and tx over http and did not exist in EAP 7.0
    PathAddress httpInvoker = undertow.append("server", "default-server").append("host", "default-host").append("setting", "http-invoker");
    ops.add(Util.getEmptyOperation(ModelDescriptionConstants.REMOVE, httpInvoker.toModelNode()));
}
Also used : PathAddress(org.jboss.as.controller.PathAddress)

Example 18 with PathAddress

use of org.jboss.as.controller.PathAddress in project wildfly by wildfly.

the class ServerManager method addSecurityRealm.

private void addSecurityRealm(ModelNode steps, String keyStoreFile, String password) {
    final PathAddress realmAddr = PathAddress.pathAddress().append(CORE_SERVICE, MANAGEMENT).append(SECURITY_REALM, "ssl-realm");
    ModelNode op = Util.createAddOperation(realmAddr);
    steps.add(op);
    // /core-service=management/security-realm=JBossTest/server-identity=ssl:add(keystore-path=server.keystore, keystore-password=123456)
    final ModelNode sslModuleNode = Util.createAddOperation(realmAddr.append(SERVER_IDENTITY, SSL));
    sslModuleNode.get("keystore-path").set(keyStoreFile);
    sslModuleNode.get(Constants.KEYSTORE_PASSWORD).set(password);
    sslModuleNode.get(OPERATION_HEADERS, ALLOW_RESOURCE_SERVICE_RESTART).set(true);
    steps.add(sslModuleNode);
}
Also used : PathAddress(org.jboss.as.controller.PathAddress) ModelNode(org.jboss.dmr.ModelNode)

Example 19 with PathAddress

use of org.jboss.as.controller.PathAddress in project wildfly by wildfly.

the class XTSExtension method registerTransformers1x.

private void registerTransformers1x(SubsystemRegistration subsystem) {
    ResourceTransformationDescriptionBuilder builder = TransformationDescriptionBuilder.Factory.createSubsystemInstance();
    builder.getAttributeBuilder().setDiscard(new DiscardAttributeChecker.DefaultDiscardAttributeChecker() {

        @Override
        protected boolean isValueDiscardable(PathAddress address, String attributeName, ModelNode attributeValue, TransformationContext context) {
            return attributeValue.isDefined() && attributeValue.equals(XTSSubsystemDefinition.HOST_NAME.getDefaultValue());
        }
    }, XTSSubsystemDefinition.HOST_NAME).setDiscard(new DiscardAttributeChecker.DiscardAttributeValueChecker(new ModelNode(false)), XTSSubsystemDefinition.DEFAULT_CONTEXT_PROPAGATION).addRejectCheck(RejectAttributeChecker.DEFINED, XTSSubsystemDefinition.HOST_NAME, XTSSubsystemDefinition.DEFAULT_CONTEXT_PROPAGATION).end();
    TransformationDescription.Tools.register(builder.build(), subsystem, ModelVersion.create(1, 1, 0));
}
Also used : PathAddress(org.jboss.as.controller.PathAddress) ResourceTransformationDescriptionBuilder(org.jboss.as.controller.transform.description.ResourceTransformationDescriptionBuilder) ModelNode(org.jboss.dmr.ModelNode) TransformationContext(org.jboss.as.controller.transform.TransformationContext) DiscardAttributeChecker(org.jboss.as.controller.transform.description.DiscardAttributeChecker)

Example 20 with PathAddress

use of org.jboss.as.controller.PathAddress in project wildfly by wildfly.

the class WeldExtension method registerTransformers.

private void registerTransformers(SubsystemRegistration subsystem) {
    ModelVersion version1_0_0 = ModelVersion.create(1, 0, 0);
    ModelVersion version3_0_0 = ModelVersion.create(3, 0, 0);
    ChainedTransformationDescriptionBuilder chainedBuilder = TransformationDescriptionBuilder.Factory.createChainedSubystemInstance(subsystem.getSubsystemVersion());
    // Differences between the current version and 3.0.0
    ResourceTransformationDescriptionBuilder builder300 = chainedBuilder.createBuilder(subsystem.getSubsystemVersion(), version3_0_0);
    builder300.getAttributeBuilder().setDiscard(DiscardAttributeChecker.UNDEFINED, WeldResourceDefinition.THREAD_POOL_SIZE_ATTRIBUTE).addRejectCheck(RejectAttributeChecker.DEFINED, WeldResourceDefinition.THREAD_POOL_SIZE_ATTRIBUTE).end();
    // Differences between 3.0.0 and 1.0.0
    ResourceTransformationDescriptionBuilder builder100 = chainedBuilder.createBuilder(version3_0_0, version1_0_0);
    builder100.getAttributeBuilder().setDiscard(new DiscardAttributeChecker.DiscardAttributeValueChecker(false, false, new ModelNode(true)), WeldResourceDefinition.NON_PORTABLE_MODE_ATTRIBUTE, WeldResourceDefinition.REQUIRE_BEAN_DESCRIPTOR_ATTRIBUTE).addRejectCheck(new RejectAttributeChecker.DefaultRejectAttributeChecker() {

        @Override
        public String getRejectionLogMessage(Map<String, ModelNode> attributes) {
            return WeldLogger.ROOT_LOGGER.rejectAttributesMustBeTrue(attributes.keySet());
        }

        @Override
        protected boolean rejectAttribute(PathAddress address, String attributeName, ModelNode attributeValue, TransformationContext context) {
            // This will not get called if it was discarded, so reject if it is undefined (default==false) or if defined and != 'true'
            return !attributeValue.isDefined() || !attributeValue.asString().equals("true");
        }
    }, WeldResourceDefinition.NON_PORTABLE_MODE_ATTRIBUTE, WeldResourceDefinition.REQUIRE_BEAN_DESCRIPTOR_ATTRIBUTE).setDiscard(new DiscardAttributeChecker.DiscardAttributeValueChecker(new ModelNode(false)), WeldResourceDefinition.DEVELOPMENT_MODE_ATTRIBUTE).addRejectCheck(RejectAttributeChecker.DEFINED, WeldResourceDefinition.DEVELOPMENT_MODE_ATTRIBUTE).end();
    chainedBuilder.buildAndRegister(subsystem, new ModelVersion[] { version1_0_0, version3_0_0 });
}
Also used : ChainedTransformationDescriptionBuilder(org.jboss.as.controller.transform.description.ChainedTransformationDescriptionBuilder) PathAddress(org.jboss.as.controller.PathAddress) ResourceTransformationDescriptionBuilder(org.jboss.as.controller.transform.description.ResourceTransformationDescriptionBuilder) ModelVersion(org.jboss.as.controller.ModelVersion) ModelNode(org.jboss.dmr.ModelNode) DiscardAttributeChecker(org.jboss.as.controller.transform.description.DiscardAttributeChecker) Map(java.util.Map) TransformationContext(org.jboss.as.controller.transform.TransformationContext)

Aggregations

PathAddress (org.jboss.as.controller.PathAddress)644 ModelNode (org.jboss.dmr.ModelNode)492 Resource (org.jboss.as.controller.registry.Resource)70 Test (org.junit.Test)66 PathElement (org.jboss.as.controller.PathElement)63 KernelServices (org.jboss.as.subsystem.test.KernelServices)51 ServiceName (org.jboss.msc.service.ServiceName)51 OperationFailedException (org.jboss.as.controller.OperationFailedException)43 ParseUtils.requireNoNamespaceAttribute (org.jboss.as.controller.parsing.ParseUtils.requireNoNamespaceAttribute)35 ParseUtils.unexpectedAttribute (org.jboss.as.controller.parsing.ParseUtils.unexpectedAttribute)35 FailedOperationTransformationConfig (org.jboss.as.model.test.FailedOperationTransformationConfig)34 KernelServicesBuilder (org.jboss.as.subsystem.test.KernelServicesBuilder)33 ServiceTarget (org.jboss.msc.service.ServiceTarget)32 OperationStepHandler (org.jboss.as.controller.OperationStepHandler)31 Map (java.util.Map)30 ParseUtils.unexpectedElement (org.jboss.as.controller.parsing.ParseUtils.unexpectedElement)29 IOException (java.io.IOException)28 ResourceTransformationDescriptionBuilder (org.jboss.as.controller.transform.description.ResourceTransformationDescriptionBuilder)26 ArrayList (java.util.ArrayList)25 OperationContext (org.jboss.as.controller.OperationContext)23