Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * JBoss, Home of Professional Open Source.
   * Copyright 2011, Red Hat, Inc., 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.host.controller.descriptions;
 
 import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.CORE_SERVICE;
 import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.HOST_ENVIRONMENT;
 import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.NAME;
 
 import java.io.File;
 
A resource description that describes the host environment.

Author(s):
James R. Perkins
Kabir Khan
 
     public static final PathElement RESOURCE_PATH = PathElement.pathElement();
 
     private static final AttributeDefinition PROCESS_CONTROLLER_ADDRESS =
             createAttributeDefinition("process-controller-address"..);
     private static final AttributeDefinition PROCESS_CONTROLLER_PORT =
             createAttributeDefinition("process-controller-port"..);
     private static final AttributeDefinition HOST_CONTROLLER_ADDRESS =
     private static final AttributeDefinition HOST_CONTROLLER_PORT =
     private static final AttributeDefinition HOME_DIR = createAttributeDefinition("home-dir");
     private static final AttributeDefinition MODULES_DIR = createAttributeDefinition("modules-dir");
     private static final AttributeDefinition DOMAIN_BASE_DIR = createAttributeDefinition("domain-base-dir");
     private static final AttributeDefinition DOMAIN_CONFIG_DIR = createAttributeDefinition("domain-config-dir");
     private static final AttributeDefinition HOST_CONFIG_FILE = createAttributeDefinition("host-config-file");
     private static final AttributeDefinition DOMAIN_CONFIG_FILE = createAttributeDefinition("domain-config-file");
     private static final AttributeDefinition DOMAIN_CONTENT_DIR = createAttributeDefinition("domain-content-dir");
     private static final AttributeDefinition DOMAIN_DATA_DIR = createAttributeDefinition("domain-data-dir");
     private static final AttributeDefinition DOMAIN_LOG_DIR = createAttributeDefinition("domain-log-dir");
     private static final AttributeDefinition DOMAIN_SERVERS_DIR = createAttributeDefinition("domain-servers-dir");
     private static final AttributeDefinition DOMAIN_TEMP_DIR = createAttributeDefinition("domain-temp-dir");
     private static final AttributeDefinition DEFAULT_JVM = createAttributeDefinition("default-jvm");
     private static final AttributeDefinition IS_RESTART = createAttributeDefinition("is-restart".);
     private static final AttributeDefinition BACKUP_DOMAIN_FILES = createAttributeDefinition("backup-domain-files".);
     private static final AttributeDefinition USE_CACHED_DC = createAttributeDefinition("use-cached-dc".);
     private static final AttributeDefinition INITIAL_RUNNING_MODE = createAttributeDefinition("initial-running-mode");
     private static final AttributeDefinition QUALIFIED_HOST_NAME = createAttributeDefinition("qualified-host-name");
     private static final AttributeDefinition HOST_NAME = createAttributeDefinition("host-name");
 
     public static final AttributeDefinition[] HOST_ENV_ATTRIBUTES = {
         ,
         ,
         ,
         ,
         ,
         ,
         ,
         ,
         ,
         ,
         ,
         ,
         ,
         ,
         ,
        ,
        ,
        ,
        ,
        ,
        ,
        
    };
    private final HostEnvironmentReadHandler osh;

    
Creates a new description provider to describe the server environment.

Parameters:
environment the environment the resource is based on.
    private HostEnvironmentResourceDefinition(final HostControllerEnvironment environment) {
        super(, HostResolver.getResolver("host.env"));
         = new HostEnvironmentReadHandler(environment);
    }

    
A factory method for creating a new server environment resource description.

Parameters:
environment the environment the resource is based on.
Returns:
a new server environment resource description.
    public static HostEnvironmentResourceDefinition of(final HostControllerEnvironment environment) {
        return new HostEnvironmentResourceDefinition(environment);
    }
    private static AttributeDefinition createAttributeDefinition(String name) {
        return createAttributeDefinition(name.);
    }
    private static AttributeDefinition createAttributeDefinition(String nameModelType type) {
        return SimpleAttributeDefinitionBuilder.create(nametype).setFlags(..).build();
    }
    private static AttributeDefinition createAttributeDefinition(String nameModelType typeAccessConstraintDefinition... accessConstraints) {
        SimpleAttributeDefinitionBuilder builder = SimpleAttributeDefinitionBuilder.create(nametype).setFlags(..);
        if (accessConstraints != null) {
            for (AccessConstraintDefinition acd : accessConstraints) {
                builder = builder.addAccessConstraint(acd);
            }
        }
        return builder.build();
    }
    @Override
    public void registerAttributes(final ManagementResourceRegistration resourceRegistration) {
        for (AttributeDefinition attribute : ) {
            resourceRegistration.registerReadOnlyAttribute(attribute);
        }
    }
    private static class HostEnvironmentReadHandler implements OperationStepHandler {
        private final HostControllerEnvironment environment;
        public HostEnvironmentReadHandler(final HostControllerEnvironment environment) {
            this. = environment;
        }
        @Override
        @SuppressWarnings("deprecation")
        public void execute(final OperationContext contextfinal ModelNode operationthrows OperationFailedException {
            final ModelNode result = context.getResult();
            final String name = operation.require().asString();
            if (equals(name)) {
                set(result.getProcessControllerAddress());
            } else if (equals(name)) {
                set(result.getProcessControllerPort());
            } else if (equals(name)) {
                set(result.getHostControllerAddress());
            } else if (equals(name)) {
                set(result.getHostControllerPort());
            } else if (equals(name)) {
                set(result.getHomeDir());
            } else if (equals(name)) {
                set (result.getModulesDir());
            } else if (equals(name)) {
                set(result.getDomainBaseDir());
            } else if (equals(name)) {
                set(result.getDomainConfigurationDir());
            } else if (equals(name)) {
                set(result.getHostConfigurationFile());
            } else if (equals(name)) {
                set(result.getDomainConfigurationFile());
            } else if (equals(name)) {
                set(result.getDomainContentDir());
            } else if (equals(name)) {
                set(result.getDomainDataDir());
            } else if (equals(name)) {
                set(result.getDomainLogDir());
            } else if (equals(name)) {
                set(result.getDomainServersDir());
            } else if (equals(name)) {
                set(result.getDomainTempDir());
            } else if (equals(name)) {
                set(result.getDefaultJVM());
            } else if (equals(name)) {
                set(result.isRestart());
            } else if (equals(name)) {
                set(result.isBackupDomainFiles());
            } else if (equals(name)) {
                set(result.isUseCachedDc());
            } else if (equals(name)) {
                set(result.getInitialRunningMode().name());
            } else if (equals(name)) {
                set(result.getQualifiedHostName());
            } else if (equals(name)) {
                set(result.getHostName());
            }
            context.stepCompleted();
        }
        private void set(final ModelNode nodefinal int value) {
            node.set(value);
        }
        private void set(final ModelNode nodefinal boolean value) {
            node.set(value);
        }
        private void set(final ModelNode nodefinal String value) {
            if (value != null) {
                node.set(value);
            }
        }
        private void set(final ModelNode nodefinal InetAddress value) {
            if (value != null) {
                node.set(value.toString());
            }
        }
        private void set(final ModelNode nodefinal File value) {
            if (value != null) {
                node.set(value.getAbsolutePath());
            }
        }
        private void set(final ModelNode nodefinal ConfigurationFile value) {
            if (value != null) {
                set(nodevalue.getBootFile());
            }
        }
        private boolean equals(final String namefinal AttributeDefinition attribute) {
            return name.equals(attribute.getName());
        }
    }
New to GrepCode? Check out our FAQ X