Search in sources :

Example 41 with PathAddress

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

the class WebSubsystemTestCase method checkUndefinedCipherSuite.

private void checkUndefinedCipherSuite(KernelServices services, ModelVersion version) throws Exception {
    final ModelNode success = new ModelNode();
    success.get(ModelDescriptionConstants.OUTCOME).set(ModelDescriptionConstants.SUCCESS);
    success.get(ModelDescriptionConstants.RESULT);
    success.protect();
    PathAddress addr = PathAddress.pathAddress(PathElement.pathElement(SUBSYSTEM, getMainSubsystemName()), PathElement.pathElement("connector", "https"), PathElement.pathElement("configuration", "ssl"));
    ModelNode op = Util.createOperation(WRITE_ATTRIBUTE_OPERATION, addr);
    op.get(NAME).set("cipher-suite");
    op.get(VALUE).set(new ModelNode());
    TransformedOperation transOp = services.transformOperation(version, op);
    Assert.assertTrue(transOp.rejectOperation(success));
    op.get(VALUE).set("SSL_RSA_WITH_3DES_EDE_CBC_SHA");
    transOp = services.transformOperation(version, op);
    Assert.assertFalse(transOp.rejectOperation(success));
}
Also used : TransformedOperation(org.jboss.as.controller.transform.OperationTransformer.TransformedOperation) PathAddress(org.jboss.as.controller.PathAddress) ModelNode(org.jboss.dmr.ModelNode)

Example 42 with PathAddress

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

the class BroadcastGroupAdd method performRuntime.

@Override
protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException {
    ServiceRegistry registry = context.getServiceRegistry(false);
    final ServiceName serviceName = MessagingServices.getActiveMQServiceName(PathAddress.pathAddress(operation.get(ModelDescriptionConstants.OP_ADDR)));
    ServiceController<?> service = registry.getService(serviceName);
    if (service != null) {
        context.reloadRequired();
    } else {
        final PathAddress address = PathAddress.pathAddress(operation.require(OP_ADDR));
        final String name = address.getLastElement().getValue();
        final ServiceTarget target = context.getServiceTarget();
        if (model.hasDefined(JGROUPS_CHANNEL.getName())) {
        // nothing to do, in that case, the clustering.jgroups subsystem will have setup the stack
        } else if (model.hasDefined(RemoteTransportDefinition.SOCKET_BINDING.getName())) {
            final GroupBindingService bindingService = new GroupBindingService();
            target.addService(GroupBindingService.getBroadcastBaseServiceName(serviceName).append(name), bindingService).addDependency(SocketBinding.JBOSS_BINDING_NAME.append(model.get(SOCKET_BINDING).asString()), SocketBinding.class, bindingService.getBindingRef()).install();
        }
    }
}
Also used : ServiceName(org.jboss.msc.service.ServiceName) PathAddress(org.jboss.as.controller.PathAddress) ServiceTarget(org.jboss.msc.service.ServiceTarget) ServiceRegistry(org.jboss.msc.service.ServiceRegistry)

Example 43 with PathAddress

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

the class DiscoveryGroupAdd method performRuntime.

@Override
protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException {
    final PathAddress address = PathAddress.pathAddress(operation.require(OP_ADDR));
    final String name = address.getLastElement().getValue();
    ServiceRegistry registry = context.getServiceRegistry(false);
    final ServiceName serviceName = MessagingServices.getActiveMQServiceName(PathAddress.pathAddress(operation.get(ModelDescriptionConstants.OP_ADDR)));
    ServiceController<?> service = registry.getService(serviceName);
    if (service != null) {
        context.reloadRequired();
    } else {
        final ServiceTarget target = context.getServiceTarget();
        if (model.hasDefined(JGROUPS_CHANNEL.getName())) {
        // nothing to do, in that case, the clustering.jgroups subsystem will have setup the stack
        } else if (model.hasDefined(RemoteTransportDefinition.SOCKET_BINDING.getName())) {
            final GroupBindingService bindingService = new GroupBindingService();
            target.addService(GroupBindingService.getDiscoveryBaseServiceName(serviceName).append(name), bindingService).addDependency(SocketBinding.JBOSS_BINDING_NAME.append(model.get(SOCKET_BINDING).asString()), SocketBinding.class, bindingService.getBindingRef()).install();
        }
    }
}
Also used : ServiceName(org.jboss.msc.service.ServiceName) PathAddress(org.jboss.as.controller.PathAddress) ServiceTarget(org.jboss.msc.service.ServiceTarget) ServiceRegistry(org.jboss.msc.service.ServiceRegistry)

Example 44 with PathAddress

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

the class MailSubsystem20TestCase method testOperations.

@Test
public void testOperations() throws Exception {
    KernelServicesBuilder builder = createKernelServicesBuilder(new MailSubsystem10TestCase.Initializer()).setSubsystemXml(getSubsystemXml());
    KernelServices mainServices = builder.build();
    if (!mainServices.isSuccessfulBoot()) {
        Assert.fail(mainServices.getBootError().toString());
    }
    PathAddress sessionAddress = PathAddress.pathAddress(MailExtension.SUBSYSTEM_PATH, PathElement.pathElement(MailExtension.MAIL_SESSION_PATH.getKey(), "defaultMail"));
    ModelNode result;
    ModelNode removeServerOp = Util.createRemoveOperation(sessionAddress.append("server", "imap"));
    removeServerOp.get(OPERATION_HEADERS).get(ALLOW_RESOURCE_SERVICE_RESTART).set(true);
    result = mainServices.executeOperation(removeServerOp);
    checkResult(result);
    ModelNode addServerOp = Util.createAddOperation(sessionAddress.append("server", "imap"));
    addServerOp.get(OPERATION_HEADERS).get(ALLOW_RESOURCE_SERVICE_RESTART).set(true);
    addServerOp.get("outbound-socket-binding-ref").set("mail-imap");
    addServerOp.get("username").set("user");
    addServerOp.get("password").set("pswd");
    result = mainServices.executeOperation(addServerOp);
    checkResult(result);
    //to make sure noting is left behind
    checkResult(mainServices.executeOperation(removeServerOp));
    checkResult(mainServices.executeOperation(addServerOp));
    ModelNode writeOp = Util.createEmptyOperation(WRITE_ATTRIBUTE_OPERATION, sessionAddress);
    writeOp.get(OPERATION_HEADERS).get(ALLOW_RESOURCE_SERVICE_RESTART).set(true);
    writeOp.get("name").set("debug");
    writeOp.get("value").set(false);
    result = mainServices.executeOperation(writeOp);
    checkResult(result);
    ServiceController<?> javaMailService = mainServices.getContainer().getService(MailSessionAdd.MAIL_SESSION_SERVICE_NAME.append("defaultMail"));
    javaMailService.setMode(ServiceController.Mode.ACTIVE);
    Session session = (Session) javaMailService.getValue();
    Assert.assertNotNull("session should not be null", session);
    Properties properties = session.getProperties();
    Assert.assertNotNull("smtp host should be set", properties.getProperty("mail.smtp.host"));
    Assert.assertNotNull("imap host should be set", properties.getProperty("mail.imap.host"));
    PathAddress nonExisting = PathAddress.pathAddress(MailExtension.SUBSYSTEM_PATH, PathElement.pathElement(MailExtension.MAIL_SESSION_PATH.getKey(), "non-existing-session"));
    ModelNode addSession = Util.createAddOperation(nonExisting);
    addSession.get("jndi-name").set("java:/bah");
    checkResult(mainServices.executeOperation(addSession));
    removeServerOp = Util.createRemoveOperation(nonExisting.append("server", "imap"));
    //removeServerOp.get(OPERATION_HEADERS).get(ALLOW_RESOURCE_SERVICE_RESTART).set(true);
    result = mainServices.executeOperation(removeServerOp);
    checkForFailure(result);
}
Also used : PathAddress(org.jboss.as.controller.PathAddress) KernelServices(org.jboss.as.subsystem.test.KernelServices) ModelNode(org.jboss.dmr.ModelNode) Properties(java.util.Properties) KernelServicesBuilder(org.jboss.as.subsystem.test.KernelServicesBuilder) Session(javax.mail.Session) AbstractSubsystemBaseTest(org.jboss.as.subsystem.test.AbstractSubsystemBaseTest) Test(org.junit.Test)

Example 45 with PathAddress

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

the class ModClusterConfigResourceDefinition method buildTransformation.

public static void buildTransformation(ModelVersion version, ResourceTransformationDescriptionBuilder parent) {
    ResourceTransformationDescriptionBuilder builder = parent.addChildResource(PATH);
    if (ModClusterModel.VERSION_4_1_0.requiresTransformation(version)) {
        builder.getAttributeBuilder().setDiscard(DiscardAttributeChecker.UNDEFINED, SSL_CONTEXT).addRejectCheck(RejectAttributeChecker.DEFINED, SSL_CONTEXT).end();
    }
    if (ModClusterModel.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()) {
                    // Workaround legacy slaves not accepting null/empty values
                    // JBAS014704: '' is an invalid value for parameter excluded-contexts. Values must have a minimum length of 1 characters
                    attributeValue.set(" ");
                }
            }
        }, EXCLUDED_CONTEXTS).end();
    }
    if (ModClusterModel.VERSION_3_0_0.requiresTransformation(version)) {
        builder.getAttributeBuilder().setDiscard(new DiscardAttributeChecker.DiscardAttributeValueChecker(STATUS_INTERVAL.getDefaultValue()), STATUS_INTERVAL).addRejectCheck(new RejectAttributeChecker.SimpleAcceptAttributeChecker(STATUS_INTERVAL.getDefaultValue()), STATUS_INTERVAL).setDiscard(DiscardAttributeChecker.UNDEFINED, PROXIES).addRejectCheck(RejectAttributeChecker.DEFINED, PROXIES).end();
    }
    if (ModClusterModel.VERSION_1_5_0.requiresTransformation(version)) {
        builder.getAttributeBuilder().addRejectCheck(SessionDrainingStrategyChecker.INSTANCE, SESSION_DRAINING_STRATEGY).setDiscard(SessionDrainingStrategyChecker.INSTANCE, SESSION_DRAINING_STRATEGY).end();
    }
    DynamicLoadProviderDefinition.buildTransformation(version, builder);
    ModClusterSSLResourceDefinition.buildTransformation(version, builder);
}
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)

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