Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
  * JBoss, Home of Professional Open Source.
  * Copyright 2011, Red Hat Middleware LLC, and individual contributors
  * as indicated by the @author tags. See the copyright.txt file in the
  * distribution for a full listing of individual contributors.
  *
  * This is free software; you can redistribute it and/or modify it
  * under the terms of the GNU Lesser General Public License as
  * published by the Free Software Foundation; either version 2.1 of
 * the License, or (at your option) any later version.
 *
 * This software is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this software; if not, write to the Free
 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
 */
 package org.jboss.as.domain.controller.resources;
 
 import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.CONCURRENT_GROUPS;
 import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.DOMAIN;
 import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.IN_SERIES;
 import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.MANAGEMENT_CLIENT_CONTENT;
 import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.MAX_FAILED_SERVERS;
 import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.MAX_FAILURE_PERCENTAGE;
 import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.ROLLBACK_ACROSS_GROUPS;
 import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.ROLLING_TO_SERVERS;
 import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.ROLLOUT_PLAN;
 import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.ROLLOUT_PLANS;
 import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.SERVER_GROUP;
 import static org.jboss.as.domain.controller.DomainControllerMessages.MESSAGES;
 
 import java.util.List;
 import java.util.Set;
 
org.jboss.as.controller.ResourceDefinition for the root resource in the domain-wide model.

Author(s):
Kabir Khan
    private static final ParameterValidator NOT_NULL_STRING_LENGTH_ONE_VALIDATOR = new StringLengthValidator(1, falsefalse);
    public static final AttributeDefinition NAMESPACES = new SimpleMapAttributeDefinition.Builder(
            .build()
        )
        .build();
        )
        .build();
    public static final SimpleAttributeDefinition NAME = SimpleAttributeDefinitionBuilder.create(..true)
        .setValidator(new StringLengthValidator(1, true))
        .setDefaultValue(new ModelNode("Unnamed Domain"))
        .build();
    public static final SimpleAttributeDefinition RELEASE_VERSION = SimpleAttributeDefinitionBuilder.create(..false)
        .build();
    public static final SimpleAttributeDefinition RELEASE_CODENAME = SimpleAttributeDefinitionBuilder.create(..false)
        .build();
    public static final SimpleAttributeDefinition PRODUCT_NAME = SimpleAttributeDefinitionBuilder.create(..true)
        .build();
    public static final SimpleAttributeDefinition PRODUCT_VERSION = SimpleAttributeDefinitionBuilder.create(..true)
        .build();
    public static final SimpleAttributeDefinition MANAGEMENT_MAJOR_VERSION = SimpleAttributeDefinitionBuilder.create(..false)
        .setValidator(new IntRangeValidator(1))
        .build();
    public static final SimpleAttributeDefinition MANAGEMENT_MINOR_VERSION = SimpleAttributeDefinitionBuilder.create(..false)
        .setValidator(new IntRangeValidator(0))
        .build();
    public static final SimpleAttributeDefinition MANAGEMENT_MICRO_VERSION = SimpleAttributeDefinitionBuilder.create(..false)
        .setValidator(new IntRangeValidator(0))
        .build();
    public static final SimpleAttributeDefinition PROCESS_TYPE = SimpleAttributeDefinitionBuilder.create(..)
            .setStorageRuntime()
            .build();
    public static final SimpleAttributeDefinition LAUNCH_TYPE = SimpleAttributeDefinitionBuilder.create(..)
            .setValidator(new EnumValidator<LaunchType>(LaunchType.classfalsefalse))
            .setStorageRuntime()
            .build();
    public static final SimpleAttributeDefinition LOCAL_HOST_NAME = SimpleAttributeDefinitionBuilder.create(..true)
            .setStorageRuntime()
            .build();
    private final DomainController domainController;
    private final HostControllerEnvironment environment;
    private final ContentRepository contentRepo;
    private final HostFileRepository fileRepository;
    private final boolean isMaster;
    private final ExtensionRegistry extensionRegistry;
    private final PathManagerService pathManager;
    public DomainRootDefinition(
            final DomainController domainController,
            final HostControllerEnvironment environment,
            final ExtensibleConfigurationPersister configurationPersisterfinal ContentRepository contentRepo,
            final HostFileRepository fileRepositoryfinal boolean isMaster,
            final LocalHostControllerInfo hostControllerInfo,
            final ExtensionRegistry extensionRegistryfinal IgnoredDomainResourceRegistry ignoredDomainResourceRegistry,
            final PathManagerService pathManager,
            final DomainControllerRuntimeIgnoreTransformationRegistry runtimeIgnoreTransformationRegistry,
            final DelegatingConfigurableAuthorizer authorizer) {
        super(null, DomainResolver.getResolver(false));
        this. = domainController;
        this. = isMaster;
        this. = environment;
        this. = hostControllerInfo;
        this. = configurationPersister;
        this. = contentRepo;
        this. = fileRepository;
        this. = extensionRegistry;
        this. = ignoredDomainResourceRegistry;
        this. = pathManager;
        this. = runtimeIgnoreTransformationRegistry;
        this. = authorizer;
    }
    @Override
    public void registerAttributes(ManagementResourceRegistration resourceRegistration) {
        super.registerAttributes(resourceRegistration);
        resourceRegistration.registerReadWriteAttribute(nullnew ModelOnlyWriteAttributeHandler());
        resourceRegistration.registerReadOnlyAttribute(null);
        resourceRegistration.registerReadOnlyAttribute(null);
        resourceRegistration.registerReadOnlyAttribute(null);
        resourceRegistration.registerReadOnlyAttribute(null);
        resourceRegistration.registerReadOnlyAttribute(null);
        resourceRegistration.registerReadOnlyAttribute(null);
        resourceRegistration.registerReadOnlyAttribute(null);
    }
    @Override
    public void registerOperations(ManagementResourceRegistration resourceRegistration) {
        super.registerOperations(resourceRegistration);
        // Other root resource operations
        resourceRegistration.registerOperationHandler(.xmh);
        if () {
            DeploymentUploadURLHandler.registerMaster(resourceRegistration);
            DeploymentUploadStreamAttachmentHandler.registerMaster(resourceRegistration);
            DeploymentUploadBytesHandler.registerMaster(resourceRegistration);
            SnapshotDeleteHandler snapshotDelete = new SnapshotDeleteHandler();
            resourceRegistration.registerOperationHandler(.snapshotDelete);
            SnapshotListHandler snapshotList = new SnapshotListHandler();
            resourceRegistration.registerOperationHandler(.snapshotList);
            SnapshotTakeHandler snapshotTake = new SnapshotTakeHandler();
            resourceRegistration.registerOperationHandler(.snapshotTake);
            final SubsystemDescriptionDump dumper = new SubsystemDescriptionDump();
            resourceRegistration.registerOperationHandler(.dumper);
        } else {
            DeploymentUploadURLHandler.registerSlave(resourceRegistration);
            DeploymentUploadStreamAttachmentHandler.registerSlave(resourceRegistration);
            DeploymentUploadBytesHandler.registerSlave(resourceRegistration);
            resourceRegistration.registerOperationHandler(.aexh);
            resourceRegistration.registerOperationHandler(.armdmh);
            resourceRegistration.registerOperationHandler(.amdmrh);
        }
        DomainServerLifecycleHandlers.registerDomainHandlers(resourceRegistration);
    }
    @Override
    public void registerChildren(ManagementResourceRegistration resourceRegistration) {
        super.registerChildren(resourceRegistration);
        resourceRegistration.registerSubModel(SystemPropertyResourceDefinition.createForDomainOrHost(.));
        resourceRegistration.registerSubModel(new InterfaceDefinition(
                .,
                .,
                false
        ));
        resourceRegistration.registerSubModel(CoreManagementResourceDefinition.forDomain());
        resourceRegistration.registerSubModel(new ProfileResourceDefinition());
        resourceRegistration.registerSubModel(PathResourceDefinition.createNamed());
        resourceRegistration.registerSubModel(DomainDeploymentResourceDefinition.createForDomainRoot());
        resourceRegistration.registerSubModel(new DeploymentOverlayDefinition(null));
        //TODO socket-binding-group currently lives in controller and the child RDs live in domain so they currently need passing in from here
        resourceRegistration.registerSubModel(new SocketBindingGroupResourceDefinition(
                                                    .,
                                                    .,
                                                    true,
                                                    .,
                                                    .,
                                                    .));
        //TODO perhaps all these desriptions and the validator log messages should be moved into management-client-content?
        resourceRegistration.registerSubModel(
                PathElement.pathElement(), new RolloutPlanValidator(), DomainResolver.getResolver(), DomainResolver.getResolver()));
        // Extensions
        resourceRegistration.registerSubModel(new ExtensionResourceDefinition(truefalse, !));
        // Initialize the domain transformers
    }
    public void initialize(ManagementResourceRegistration resourceRegistration) {
        registerAttributes(resourceRegistration);
        registerOperations(resourceRegistration);
        registerChildren(resourceRegistration);
    }
    public static class RolloutPlanValidator extends AbstractParameterValidator {
        @Override
        public void validateParameter(String parameterNameModelNode planthrows OperationFailedException {
            if(plan == null) {
                throw new OperationFailedException(.nullVar("plan").getLocalizedMessage());
            }
            if(!plan.hasDefined()) {
                throw new OperationFailedException(.requiredChildIsMissing(plan.toString()));
            }
            ModelNode rolloutPlan1 = plan.get();
            final Set<Stringkeys;
            try {
                keys = rolloutPlan1.keys();
            } catch (IllegalArgumentException e) {
                throw new OperationFailedException(.requiredChildIsMissing(plan.toString()));
            }
            if(!keys.contains()) {
                throw new OperationFailedException(.requiredChildIsMissing(plan.toString()));
            }
            if(keys.size() > 2 || keys.size() == 2 && !keys.contains()) {
                throw new OperationFailedException(.unrecognizedChildren( + ", " + plan.toString()));
            }
            final ModelNode inSeries = rolloutPlan1.get();
            if(!inSeries.isDefined()) {
                throw new OperationFailedException(.requiredChildIsMissing(plan.toString()));
            }
            final List<ModelNodegroups = inSeries.asList();
            if(groups.isEmpty()) {
                throw new OperationFailedException(.inSeriesIsMissingGroups(plan.toString()));
            }
            for(ModelNode group : groups) {
                if(group.hasDefined()) {
                    final ModelNode serverGroup = group.get();
                    final Set<StringgroupKeys;
                    try {
                        groupKeys = serverGroup.keys();
                    } catch(IllegalArgumentException e) {
                        throw new OperationFailedException(.serverGroupExpectsSingleChild(plan.toString()));
                    }
                    if(groupKeys.size() != 1) {
                        throw new OperationFailedException(.serverGroupExpectsSingleChild(plan.toString()));
                    }
                    validateInSeriesServerGroup(serverGroup.asProperty().getValue());
                } else if(group.hasDefined()) {
                    final ModelNode concurrent = group.get();
                    for(ModelNode childconcurrent.asList()) {
                        validateInSeriesServerGroup(child.asProperty().getValue());
                    }
                } else {
                    throw new OperationFailedException(.unexpectedInSeriesGroup(plan.toString()));
                }
            }
        }
        public static void validateInSeriesServerGroup(ModelNode serverGroupthrows OperationFailedException {
            if(serverGroup.isDefined()) {
                try {
                    final Set<StringspecKeys = serverGroup.keys();
                    if(!.containsAll(specKeys)) {
                        throw new OperationFailedException(.unrecognizedChildren(.toString(), specKeys.toString()));
                    }
                } catch(IllegalArgumentException e) {// ignore?
                }
            }
        }
    }
New to GrepCode? Check out our FAQ X