All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.jboss.as.clustering.controller.DefaultSubsystemDescribeHandler Maven / Gradle / Ivy

Go to download

The code in this module is not explicitly related to clustering, but rather contains resuable code used by clustering modules and any modules that integrate with clustering.

There is a newer version: 34.0.0.Final
Show newest version
/*
 * Copyright The WildFly Authors
 * SPDX-License-Identifier: Apache-2.0
 */

package org.jboss.as.clustering.controller;

import java.util.Optional;

import org.jboss.as.controller.PathAddress;
import org.jboss.as.controller.PathElement;
import org.jboss.as.controller.operations.common.GenericSubsystemDescribeHandler;
import org.jboss.as.controller.operations.common.OrderedChildTypesAttachment;
import org.jboss.as.controller.registry.ImmutableManagementResourceRegistration;
import org.jboss.as.controller.registry.ManagementResourceRegistration;
import org.jboss.as.controller.registry.Resource;
import org.jboss.dmr.ModelNode;

/**
 * Custom subsystem describe operation handler that works with override models.
 * Workaround for WFCORE-2286.
 * @author Paul Ferraro
 */
public class DefaultSubsystemDescribeHandler extends GenericSubsystemDescribeHandler implements ManagementRegistrar {

    @Override
    protected void describe(OrderedChildTypesAttachment orderedChildTypesAttachment, Resource resource, ModelNode addressModel, ModelNode result, ImmutableManagementResourceRegistration registration) {
        if (resource == null || registration.isRemote() || registration.isRuntimeOnly() || resource.isProxy() || resource.isRuntime() || registration.isAlias()) return;
        result.add(createAddOperation(orderedChildTypesAttachment, addressModel, resource, registration.getChildAddresses(PathAddress.EMPTY_ADDRESS)));
        PathAddress address = PathAddress.pathAddress(addressModel);
        for (String type : resource.getChildTypes()) {
            for (Resource.ResourceEntry entry : resource.getChildren(type)) {
                PathElement path = entry.getPathElement();
                ImmutableManagementResourceRegistration childRegistration = Optional.ofNullable(registration.getSubModel(PathAddress.pathAddress(path))).orElse(registration.getSubModel(PathAddress.pathAddress(PathElement.pathElement(path.getKey()))));
                PathAddress childAddress = address.append(path);
                this.describe(orderedChildTypesAttachment, entry, childAddress.toModelNode(), result, childRegistration);
            }
        }
    }

    @Override
    public void register(ManagementResourceRegistration registration) {
        registration.registerOperationHandler(GenericSubsystemDescribeHandler.DEFINITION, this);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy