Package org.jboss.as.controller

Examples of org.jboss.as.controller.PathElement


                    break;
                }
            }
            if (!failed) {
                for (Map.Entry<PathElement, ModelNode> entry : childResources.entrySet()) {
                    PathElement path = entry.getKey();
                    ModelNode value = entry.getValue();
                    if (!value.has(FAILURE_DESCRIPTION)) {
                        ModelNode childTypeNode = sortedChildren.get(path.getKey());
                        if (childTypeNode == null) {
                            childTypeNode = new ModelNode();
                            sortedChildren.put(path.getKey(), childTypeNode);
                        }
                        childTypeNode.get(path.getValue()).set(value.get(RESULT));
                    } else if (!failed && value.hasDefined(FAILURE_DESCRIPTION)) {
                        context.getFailureDescription().set(value.get(FAILURE_DESCRIPTION));
                        failed = true;
                    }
                }
View Full Code Here


    public Resource navigate(PathAddress address) {
        int size = address.size();
        if (size == 0) {
            return this;
        }
        PathElement pe = address.getElement(0);
        Resource child = getChild(pe);
        if (child != null) {
            return size == 1 ? child : child.navigate(address.subAddress(1));
        } else {
            throw new NoSuchResourceException(pe);
View Full Code Here

    private ServiceName getComponentConfiguration(final PathAddress operationAddress) throws OperationFailedException {

        final List<PathElement> relativeAddress = new ArrayList<PathElement>();
        for (int i = operationAddress.size() - 1; i >= 0; i--) {
            PathElement pe = operationAddress.getElement(i);
            relativeAddress.add(0, pe);
            if (ModelDescriptionConstants.DEPLOYMENT.equals(pe.getKey())) {
                break;
            }
        }

        final PathAddress pa = PathAddress.pathAddress(relativeAddress);
View Full Code Here

    ModelNode jobExecutor = operations.get(1);
    PathAddress pathAddress = PathAddress.pathAddress(jobExecutor.get(ModelDescriptionConstants.OP_ADDR));
    assertEquals(2, pathAddress.size());

    PathElement element = pathAddress.getElement(0);
    assertEquals(ModelDescriptionConstants.SUBSYSTEM, element.getKey());
    assertEquals(ModelConstants.SUBSYSTEM_NAME, element.getValue());
    element = pathAddress.getElement(1);
    assertEquals(Element.JOB_EXECUTOR.getLocalName(), element.getKey());
    assertEquals(Attribute.DEFAULT.getLocalName(), element.getValue());

    assertEquals("job-executor-tp", jobExecutor.get(Element.THREAD_POOL_NAME.getLocalName()).asString());

    ModelNode jobAcquisition = operations.get(2);
    assertEquals("default", jobAcquisition.get(Attribute.NAME.getLocalName()).asString());
View Full Code Here

       // We are a handler for requests related to a jms-topic resource. Those reside on level below the hornetq-server
        // resources in the resource tree. So we could look for the hornetq-server in the 2nd to last element
        // in the PathAddress. But to be more generic and future-proof, we'll walk the tree looking
        String hornetQServerName = null;
        for (int i = pathAddress.size() - 1; i >=0; i--) {
            PathElement pe = pathAddress.getElement(i);
            if (CommonAttributes.HORNETQ_SERVER.equals(pe.getKey())) {
                hornetQServerName = pe.getValue();
                break;
            }
        }
      return JBOSS_MESSAGING.append(hornetQServerName);
   }
View Full Code Here

        final Resource resource = context.readResourceForUpdate(PathAddress.EMPTY_ADDRESS);
        final ModelNode subModel = resource.getModel();

        // validate the protocol type to be added
        ModelNode type = ProtocolResource.TYPE.validateOperation(operation);
        PathElement protocolRelativePath = PathElement.pathElement(ModelKeys.PROTOCOL, type.asString());

        // if child resource already exists, throw OFE
        if (resource.hasChild(protocolRelativePath)) {
            throw JGroupsMessages.MESSAGES.protocolAlreadyDefined(protocolRelativePath.toString());
        }

        // now get the created model
        Resource childResource = context.createResource(PathAddress.pathAddress(protocolRelativePath));
        final ModelNode protocol = childResource.getModel();

        // Process attributes
        for (final AttributeDefinition attribute : attributes) {
            // we use PROPERTIES only to allow the user to pass in a list of properties on store add commands
            // don't copy these into the model
            if (attribute.getName().equals(ModelKeys.PROPERTIES)) { continue; }

            attribute.validateAndSet(operation, protocol);
        }

        // get the current list of protocol names and add the new protocol
        // this list is used to maintain order
        ModelNode protocols = subModel.get(ModelKeys.PROTOCOLS);
        if (!protocols.isDefined()) {
            protocols.setEmptyList();
        }
        protocols.add(type);

        // Process type specific properties if required

        // The protocol parameters  <property name=>value</property>
        if (operation.hasDefined(ModelKeys.PROPERTIES)) {
            for (Property property : operation.get(ModelKeys.PROPERTIES).asPropertyList()) {
                // create a new property=name resource
                final Resource param = context.createResource(PathAddress.pathAddress(protocolRelativePath, PathElement.pathElement(ModelKeys.PROPERTY, property.getName())));
                final ModelNode value = property.getValue();
                if (!value.isDefined()) {
                    throw JGroupsMessages.MESSAGES.propertyNotDefined(property.getName(), protocolRelativePath.toString());
                }
                // set the value of the property
                PropertyResource.VALUE.validateAndSet(value, param.getModel());
            }
        }
View Full Code Here

        final Resource resource = context.readResourceForUpdate(PathAddress.EMPTY_ADDRESS);
        final ModelNode subModel = resource.getModel();

         // validate the protocol type to be added
        ModelNode type = ProtocolResource.TYPE.validateOperation(operation);
        PathElement protocolRelativePath = PathElement.pathElement(ModelKeys.PROTOCOL, type.asString());

        // if child resource already exists, throw OFE
        // TODO not sure if this works ex expected - it may only confirm a registered resource
        if (!resource.hasChild(protocolRelativePath))  {
            throw JGroupsMessages.MESSAGES.protocolNotDefined(protocolRelativePath.toString()) ;
        }

        // remove the resource and its children
        context.removeResource(PathAddress.pathAddress(protocolRelativePath));
View Full Code Here

    }

    @Override
    public void execute(final OperationContext context, final ModelNode operation) throws OperationFailedException {

        final PathElement transportRelativePath = PathElement.pathElement(ModelKeys.TRANSPORT, ModelKeys.TRANSPORT_NAME);
        final Resource resource = context.createResource(PathAddress.EMPTY_ADDRESS);
        final ModelNode subModel = resource.getModel();

        // Process attributes
        for(final AttributeDefinition attribute : attributes) {
            // don't process properties twice - we do them below
            if (attribute.getName().equals(ModelKeys.PROPERTIES))
                continue ;
            attribute.validateAndSet(operation, subModel);
        }

        // The transport config parameters  <property name=>value</property>
        if(operation.hasDefined(ModelKeys.PROPERTIES)) {
            for(Property property : operation.get(ModelKeys.PROPERTIES).asPropertyList()) {
                // create a new property=name resource
                final Resource param = context.createResource(PathAddress.pathAddress(PathElement.pathElement(ModelKeys.PROPERTY, property.getName())));
                final ModelNode value = property.getValue();
                if(!value.isDefined()) {
                    throw JGroupsMessages.MESSAGES.propertyNotDefined(property.getName(), transportRelativePath.toString());
                }
                // set the value of the property
                PropertyResource.VALUE.validateAndSet(value, param.getModel());
            }
        }
View Full Code Here

                    break;
                }
            }
            if (!failed) {
                for (Map.Entry<PathElement, ModelNode> entry : childResources.entrySet()) {
                    PathElement path = entry.getKey();
                    ModelNode value = entry.getValue();
                    if (!value.has(FAILURE_DESCRIPTION)) {
                        ModelNode childTypeNode = sortedChildren.get(path.getKey());
                        if (childTypeNode == null) {
                            childTypeNode = new ModelNode();
                            sortedChildren.put(path.getKey(), childTypeNode);
                        }
                        childTypeNode.get(path.getValue()).set(value.get(RESULT));
                    } else if (!failed && value.hasDefined(FAILURE_DESCRIPTION)) {
                        context.getFailureDescription().set(value.get(FAILURE_DESCRIPTION));
                        failed = true;
                    }
                }
View Full Code Here

                final ReadChildrenResourcesAssemblyHandler assemblyHandler = new ReadChildrenResourcesAssemblyHandler(resources);
                context.addStep(assemblyHandler, OperationContext.Stage.IMMEDIATE);

                final PathAddress address = PathAddress.pathAddress(operation.get(OP_ADDR));
                for (final String key : resource.getChildrenNames(childType)) {
                    final PathElement childPath =  PathElement.pathElement(childType, key);
                    final PathAddress childAddress = PathAddress.EMPTY_ADDRESS.append(PathElement.pathElement(childType, key));

                    final ModelNode readOp = new ModelNode();
                    readOp.get(OP).set(READ_RESOURCE_OPERATION);
                    readOp.get(OP_ADDR).set(PathAddress.pathAddress(address, childPath).toModelNode());
View Full Code Here

TOP

Related Classes of org.jboss.as.controller.PathElement

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.