Search in sources :

Example 96 with PathAddress

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

the class ModClusterSubsystemXMLReader_1_0 method readElement.

/**
     * {@inheritDoc}
     */
@Override
public void readElement(XMLExtendedStreamReader reader, List<ModelNode> list) throws XMLStreamException {
    ParseUtils.requireNoAttributes(reader);
    PathAddress address = PathAddress.pathAddress(ModClusterSubsystemResourceDefinition.PATH);
    final ModelNode subsystem = new ModelNode();
    subsystem.get(OP).set(ADD);
    subsystem.get(OP_ADDR).set(address.toModelNode());
    list.add(subsystem);
    // Reads it
    while (reader.hasNext() && reader.nextTag() != END_ELEMENT) {
        final Element element = Element.forName(reader.getLocalName());
        switch(element) {
            case MOD_CLUSTER_CONFIG:
                parseModClusterConfig(reader, list, address);
                break;
            default:
                {
                    throw unexpectedElement(reader);
                }
        }
    }
}
Also used : PathAddress(org.jboss.as.controller.PathAddress) PathElement(org.jboss.as.controller.PathElement) ParseUtils.unexpectedElement(org.jboss.as.controller.parsing.ParseUtils.unexpectedElement) ModelNode(org.jboss.dmr.ModelNode)

Example 97 with PathAddress

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

the class SecurityDomainAdd method performRuntime.

@Override
protected void performRuntime(OperationContext context, ModelNode operation, final ModelNode model) {
    PathAddress address = PathAddress.pathAddress(operation.get(OP_ADDR));
    final String securityDomain = address.getLastElement().getValue();
    // This needs to run after all child resources so that they can detect a fresh state
    context.addStep(new OperationStepHandler() {

        @Override
        public void execute(OperationContext context, ModelNode operation) throws OperationFailedException {
            final Resource resource = context.readResource(PathAddress.EMPTY_ADDRESS);
            launchServices(context, securityDomain, Resource.Tools.readModel(resource));
            // Rollback handled by the parent step
            context.completeStep(OperationContext.RollbackHandler.NOOP_ROLLBACK_HANDLER);
        }
    }, OperationContext.Stage.RUNTIME);
}
Also used : OperationContext(org.jboss.as.controller.OperationContext) OperationStepHandler(org.jboss.as.controller.OperationStepHandler) PathAddress(org.jboss.as.controller.PathAddress) OperationFailedException(org.jboss.as.controller.OperationFailedException) Resource(org.jboss.as.controller.registry.Resource) ModelNode(org.jboss.dmr.ModelNode)

Example 98 with PathAddress

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

the class SecuritySubsystemParser method parseAuthorization.

private void parseAuthorization(List<ModelNode> list, PathAddress parentAddress, XMLExtendedStreamReader reader) throws XMLStreamException {
    requireNoAttributes(reader);
    PathAddress address = parentAddress.append(AUTHORIZATION, CLASSIC);
    ModelNode op = Util.createAddOperation(address);
    list.add(op);
    while (reader.hasNext() && reader.nextTag() != END_ELEMENT) {
        final Element element = Element.forName(reader.getLocalName());
        switch(element) {
            case POLICY_MODULE:
                {
                    EnumSet<Attribute> required = EnumSet.of(Attribute.CODE, Attribute.FLAG);
                    EnumSet<Attribute> notAllowed = EnumSet.of(Attribute.TYPE, Attribute.LOGIN_MODULE_STACK_REF);
                    parseCommonModule(reader, address, POLICY_MODULE, required, notAllowed, list);
                    break;
                }
            default:
                {
                    throw unexpectedElement(reader);
                }
        }
    }
}
Also used : PathAddress(org.jboss.as.controller.PathAddress) PathElement(org.jboss.as.controller.PathElement) ParseUtils.unexpectedElement(org.jboss.as.controller.parsing.ParseUtils.unexpectedElement) EnumSet(java.util.EnumSet) ModelNode(org.jboss.dmr.ModelNode)

Example 99 with PathAddress

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

the class EEConcurrentManagementTestCase method testManagedScheduledExecutorServiceManagement.

@Test
public void testManagedScheduledExecutorServiceManagement() throws Exception {
    final PathAddress pathAddress = EE_SUBSYSTEM_PATH_ADDRESS.append(EESubsystemModel.MANAGED_SCHEDULED_EXECUTOR_SERVICE, RESOURCE_NAME);
    // add
    final ModelNode addOperation = Util.createAddOperation(pathAddress);
    final String jndiName = "java:jboss/ee/concurrency/scheduledexecutor/" + RESOURCE_NAME;
    addOperation.get(ManagedScheduledExecutorServiceResourceDefinition.JNDI_NAME).set(jndiName);
    addOperation.get(ManagedScheduledExecutorServiceResourceDefinition.CORE_THREADS).set(2);
    final ModelNode addResult = managementClient.getControllerClient().execute(addOperation);
    Assert.assertFalse(addResult.get(FAILURE_DESCRIPTION).toString(), addResult.get(FAILURE_DESCRIPTION).isDefined());
    try {
        // lookup
        Assert.assertNotNull(new InitialContext().lookup(jndiName));
    } finally {
        // remove
        final ModelNode removeOperation = Util.createRemoveOperation(pathAddress);
        removeOperation.get(OPERATION_HEADERS, ALLOW_RESOURCE_SERVICE_RESTART).set(true);
        final ModelNode removeResult = managementClient.getControllerClient().execute(removeOperation);
        Assert.assertFalse(removeResult.get(FAILURE_DESCRIPTION).toString(), removeResult.get(FAILURE_DESCRIPTION).isDefined());
        try {
            new InitialContext().lookup(jndiName);
            Assert.fail();
        } catch (NameNotFoundException e) {
        // expected
        }
    }
}
Also used : NameNotFoundException(javax.naming.NameNotFoundException) PathAddress(org.jboss.as.controller.PathAddress) ModelNode(org.jboss.dmr.ModelNode) InitialContext(javax.naming.InitialContext) Test(org.junit.Test)

Example 100 with PathAddress

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

the class EEConcurrentManagementTestCase method testManagedExecutorServiceManagement.

@Test
public void testManagedExecutorServiceManagement() throws Exception {
    final PathAddress pathAddress = EE_SUBSYSTEM_PATH_ADDRESS.append(EESubsystemModel.MANAGED_EXECUTOR_SERVICE, RESOURCE_NAME);
    // add
    final ModelNode addOperation = Util.createAddOperation(pathAddress);
    final String jndiName = "java:jboss/ee/concurrency/executor/" + RESOURCE_NAME;
    addOperation.get(ManagedExecutorServiceResourceDefinition.JNDI_NAME).set(jndiName);
    addOperation.get(ManagedExecutorServiceResourceDefinition.CORE_THREADS).set(2);
    final ModelNode addResult = managementClient.getControllerClient().execute(addOperation);
    Assert.assertFalse(addResult.get(FAILURE_DESCRIPTION).toString(), addResult.get(FAILURE_DESCRIPTION).isDefined());
    try {
        // lookup
        Assert.assertNotNull(new InitialContext().lookup(jndiName));
    } finally {
        // remove
        final ModelNode removeOperation = Util.createRemoveOperation(pathAddress);
        removeOperation.get(OPERATION_HEADERS, ALLOW_RESOURCE_SERVICE_RESTART).set(true);
        final ModelNode removeResult = managementClient.getControllerClient().execute(removeOperation);
        Assert.assertFalse(removeResult.get(FAILURE_DESCRIPTION).toString(), removeResult.get(FAILURE_DESCRIPTION).isDefined());
        try {
            new InitialContext().lookup(jndiName);
            Assert.fail();
        } catch (NameNotFoundException e) {
        // expected
        }
    }
}
Also used : NameNotFoundException(javax.naming.NameNotFoundException) PathAddress(org.jboss.as.controller.PathAddress) ModelNode(org.jboss.dmr.ModelNode) InitialContext(javax.naming.InitialContext) Test(org.junit.Test)

Aggregations

PathAddress (org.jboss.as.controller.PathAddress)473 ModelNode (org.jboss.dmr.ModelNode)345 PathElement (org.jboss.as.controller.PathElement)54 Resource (org.jboss.as.controller.registry.Resource)53 ServiceName (org.jboss.msc.service.ServiceName)53 OperationFailedException (org.jboss.as.controller.OperationFailedException)48 Test (org.junit.Test)36 ServiceTarget (org.jboss.msc.service.ServiceTarget)32 ParseUtils.unexpectedElement (org.jboss.as.controller.parsing.ParseUtils.unexpectedElement)29 OperationContext (org.jboss.as.controller.OperationContext)28 ResourceTransformationDescriptionBuilder (org.jboss.as.controller.transform.description.ResourceTransformationDescriptionBuilder)25 KernelServices (org.jboss.as.subsystem.test.KernelServices)24 ParseUtils.requireNoNamespaceAttribute (org.jboss.as.controller.parsing.ParseUtils.requireNoNamespaceAttribute)23 ParseUtils.unexpectedAttribute (org.jboss.as.controller.parsing.ParseUtils.unexpectedAttribute)23 Map (java.util.Map)22 ActiveMQServer (org.apache.activemq.artemis.core.server.ActiveMQServer)19 OperationStepHandler (org.jboss.as.controller.OperationStepHandler)19 ArrayList (java.util.ArrayList)18 TransformationContext (org.jboss.as.controller.transform.TransformationContext)17 FailedOperationTransformationConfig (org.jboss.as.model.test.FailedOperationTransformationConfig)15