Examples of ImmutableManagementResourceRegistration


Examples of org.jboss.as.controller.registry.ImmutableManagementResourceRegistration

    private CompositeOperationHandler() {
    }

    public void execute(final OperationContext context, final ModelNode operation) {
        ImmutableManagementResourceRegistration registry = context.getResourceRegistration();
        final List<ModelNode> list = operation.get(STEPS).asList();
        ModelNode responseMap = context.getResult().setEmptyObject();
        Map<String, OperationStepHandler> stepHandlerMap = new HashMap<String, OperationStepHandler>();
        final int size = list.size();
        // Validate all needed handlers are available.
        for (int i = 0; i < size; i++) {
            String stepName = "step-" + (i+1);
            // This makes the result steps appear in the correct order
            responseMap.get(stepName);
            final ModelNode subOperation = list.get(i);
            PathAddress stepAddress = PathAddress.pathAddress(subOperation.get(OP_ADDR));
            String stepOpName = subOperation.require(OP).asString();
            OperationStepHandler stepHandler = registry.getOperationHandler(stepAddress, stepOpName);
            if (stepHandler == null) {
                context.getFailureDescription().set(MESSAGES.noHandler(stepOpName, stepAddress));
                context.completeStep();
                return;
            }
View Full Code Here

Examples of org.jboss.as.controller.registry.ImmutableManagementResourceRegistration

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

            validator.validate(operation);
            final String childType = operation.require(CHILD_TYPE).asString();
            final Resource resource = context.readResource(PathAddress.EMPTY_ADDRESS, false);
            ImmutableManagementResourceRegistration registry = context.getResourceRegistration();
            Map<String, Set<String>> childAddresses = getChildAddresses(registry, resource, childType);
            Set<String> childNames = childAddresses.get(childType);
            if (childNames == null) {
                throw new OperationFailedException(new ModelNode().set(MESSAGES.unknownChildType(childType)));
            }
View Full Code Here

Examples of org.jboss.as.controller.registry.ImmutableManagementResourceRegistration

            final String childType = operation.require(CHILD_TYPE).asString();

            final Map<PathElement, ModelNode> resources = new HashMap<PathElement, ModelNode>();

            final Resource resource = context.readResource(PathAddress.EMPTY_ADDRESS, false);
            final ImmutableManagementResourceRegistration registry = context.getResourceRegistration();
            Map<String, Set<String>> childAddresses = getChildAddresses(registry, resource, childType);
            Set<String> childNames = childAddresses.get(childType);
            if (childNames == null) {
                throw new OperationFailedException(new ModelNode().set(MESSAGES.unknownChildType(childType)));
            }
View Full Code Here

Examples of org.jboss.as.controller.registry.ImmutableManagementResourceRegistration

            }
        }


        ProxyOperationAddressTranslator translator = null;
        ImmutableManagementResourceRegistration proxyReg = null;
        PathAddress proxyAddr = PathAddress.EMPTY_ADDRESS;
        for (PathElement element : addr) {
            proxyAddr = proxyAddr.append(element);
            ImmutableManagementResourceRegistration reg = context.getResourceRegistration().getSubModel(proxyAddr);
            if (reg.isRemote()) {
                translator = element.getKey().equals(SERVER) ? ProxyOperationAddressTranslator.SERVER : ProxyOperationAddressTranslator.HOST;
                proxyReg = reg;
                break;
            }
        }
View Full Code Here

Examples of org.jboss.as.controller.registry.ImmutableManagementResourceRegistration

    }

    void execute(OperationContext context, ModelNode operation) throws OperationFailedException {

        // Determine routing
        ImmutableManagementResourceRegistration opRegistry = context.getResourceRegistration();
        OperationRouting routing = OperationRouting.determineRouting(operation, localHostControllerInfo, opRegistry);

        if (!localHostControllerInfo.isMasterDomainController()
                && !routing.isLocalOnly(localHostControllerInfo.getLocalHostName())) {
            // We cannot handle this ourselves
View Full Code Here

Examples of org.jboss.as.controller.registry.ImmutableManagementResourceRegistration

        if (HOST_CONTROLLER_LOGGER.isTraceEnabled()) {
            HOST_CONTROLLER_LOGGER.trace("Executing direct");
        }
        final String operationName =  operation.require(OP).asString();
        OperationStepHandler stepHandler = null;
        final ImmutableManagementResourceRegistration registration = context.getResourceRegistration();
        if (registration != null) {
            stepHandler = registration.getOperationHandler(PathAddress.EMPTY_ADDRESS, operationName);
        }
        if(stepHandler != null) {
            context.addStep(stepHandler, OperationContext.Stage.MODEL);
        } else {
            context.getFailureDescription().set(MESSAGES.noHandlerForOperation(operationName, PathAddress.pathAddress(operation.get(OP_ADDR))));
View Full Code Here

Examples of org.jboss.as.controller.registry.ImmutableManagementResourceRegistration

            final Iterator<PathElement> iterator = current.iterator();
            if (iterator.hasNext()) {
                final PathElement element = iterator.next();
                if (element.isMultiTarget()) {
                    final String childType = element.getKey().equals("*") ? null : element.getKey();
                    final ImmutableManagementResourceRegistration registration = context.getResourceRegistration().getSubModel(base);
                    if (registration.isRemote() || registration.isRuntimeOnly()) {
                        // At least for proxies it should use the proxy operation handler
                        throw new IllegalStateException();
                    }
                    final Map<String, Set<String>> resolved = getChildAddresses(registration, resource, childType);
                    for (Map.Entry<String, Set<String>> entry : resolved.entrySet()) {
View Full Code Here

Examples of org.jboss.as.controller.registry.ImmutableManagementResourceRegistration

            // in reverse order of how they should execute, as that is the way adding a Stage.IMMEDIATE step works

            // Last to execute is the handler that assembles the overall response from the pieces created by all the other steps
            final ReadResourceAssemblyHandler assemblyHandler = new ReadResourceAssemblyHandler(directAttributes, metrics, otherAttributes, directChildren, childResources);
            context.addStep(assemblyHandler, queryRuntime ? OperationContext.Stage.VERIFY : OperationContext.Stage.IMMEDIATE, queryRuntime);
            final ImmutableManagementResourceRegistration registry = context.getResourceRegistration();

            // Get the model for this resource.
            final Resource resource = nullSafeReadResource(context, registry);
            final Map<String, Set<String>> childrenByType = registry != null ? getChildAddresses(registry, resource, null) : Collections.<String, Set<String>>emptyMap();
            final ModelNode model = resource.getModel();

            if (model.isDefined()) {
                // Store direct attributes first
                for (String key : model.keys()) {
                    // In case someone put some garbage in it
                    if (!childrenByType.containsKey(key)) {
                        directAttributes.put(key, model.get(key));
                    }
                }
                if (defaults) {
                    //get the model description
                    final DescriptionProvider descriptionProvider = registry.getModelDescription(PathAddress.EMPTY_ADDRESS);
                    final Locale locale = getLocale(operation);
                    final ModelNode nodeDescription = descriptionProvider.getModelDescription(locale);

                    if (nodeDescription.isDefined() && nodeDescription.hasDefined(ATTRIBUTES)) {
                        for (String key : nodeDescription.get(ATTRIBUTES).keys()) {
                            if ((!childrenByType.containsKey(key)) &&
                                    (!directAttributes.containsKey(key) || !directAttributes.get(key).isDefined()) &&
                                    nodeDescription.get(ATTRIBUTES).hasDefined(key) &&
                                    nodeDescription.get(ATTRIBUTES, key).hasDefined(DEFAULT)) {
                                directAttributes.put(key, nodeDescription.get(ATTRIBUTES, key, DEFAULT));
                            }
                        }
                    }
                }
            }


            // Next, process child resources
            for (Map.Entry<String, Set<String>> entry : childrenByType.entrySet()) {
                String childType = entry.getKey();
                Set<String> children = entry.getValue();
                if (children.isEmpty()) {
                    // Just treat it like an undefined attribute
                    directAttributes.put(childType, new ModelNode());
                } else {
                    for (String child : children) {
                        boolean storeDirect = !recursive;
                        if (recursive) {
                            PathElement childPE = PathElement.pathElement(childType, child);
                            PathAddress relativeAddr = PathAddress.pathAddress(childPE);
                            ImmutableManagementResourceRegistration childReg = registry.getSubModel(relativeAddr);
                            if (childReg == null) {
                                throw new OperationFailedException(new ModelNode().set(MESSAGES.noChildRegistry(childType, child)));
                            }
                            // Decide if we want to invoke on this child resource
                            boolean proxy = childReg.isRemote();
                            boolean runtimeResource = childReg.isRuntimeOnly();
                            if (!runtimeResource || (queryRuntime && !proxy|| (proxies && proxy)) {
                                final int newDepth = recursiveDepth > 0 ? recursiveDepth - 1 : 0;
                                // Add a step to read the child resource
                                ModelNode rrOp = new ModelNode();
                                rrOp.get(OP).set(opName);
                                rrOp.get(OP_ADDR).set(PathAddress.pathAddress(address, childPE).toModelNode());
                                rrOp.get(RECURSIVE).set(operation.get(RECURSIVE));
                                rrOp.get(RECURSIVE_DEPTH).set(newDepth);
                                rrOp.get(PROXIES).set(proxies);
                                rrOp.get(INCLUDE_RUNTIME).set(queryRuntime);
                                ModelNode rrRsp = new ModelNode();
                                childResources.put(childPE, rrRsp);

                                OperationStepHandler rrHandler = childReg.getOperationHandler(PathAddress.EMPTY_ADDRESS, opName);
                                context.addStep(rrRsp, rrOp, rrHandler, OperationContext.Stage.IMMEDIATE);
                            } else {
                                storeDirect = true;
                            }
                        }
View Full Code Here

Examples of org.jboss.as.controller.registry.ImmutableManagementResourceRegistration

    }

    void addSteps(final OperationContext context, final ModelNode operation, final ModelNode response, final boolean recordResponse) throws OperationFailedException {

        final PathAddress originalAddress = PathAddress.pathAddress(operation.get(OP_ADDR));
        final ImmutableManagementResourceRegistration originalRegistration = context.getResourceRegistration();
        if (originalRegistration == null) {
            String operationName = operation.require(OP).asString();
            throw new OperationFailedException(new ModelNode().set(MESSAGES.noHandlerForOperation(operationName, originalAddress)));
        }
View Full Code Here

Examples of org.jboss.as.controller.registry.ImmutableManagementResourceRegistration

        String opName = operation.require(ModelDescriptionConstants.OP).asString();
        PathAddress unaliasedAddress = getUnaliasedAddress(operation);
        ModelNode unaliasedOp = operation.clone();
        unaliasedOp.get(ModelDescriptionConstants.OP_ADDR).set(unaliasedAddress.toModelNode());

        ImmutableManagementResourceRegistration resourceRegistration = context.getRootResourceRegistration();
        OperationStepHandler handler = resourceRegistration.getOperationHandler(unaliasedAddress, opName);

        context.addStep(unaliasedOp, handler, OperationContext.Stage.IMMEDIATE);

        context.completeStep(OperationContext.RollbackHandler.NOOP_ROLLBACK_HANDLER);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.