Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
   *
   * Copyright (c) 1997-2012 Oracle and/or its affiliates. All rights reserved.
   *
   * The contents of this file are subject to the terms of either the GNU
   * General Public License Version 2 only ("GPL") or the Common Development
   * and Distribution License("CDDL") (collectively, the "License").  You
   * may not use this file except in compliance with the License.  You can
  * obtain a copy of the License at
  * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
  * or packager/legal/LICENSE.txt.  See the License for the specific
  * language governing permissions and limitations under the License.
  *
  * When distributing the software, include this License Header Notice in each
  * file and include the License file at packager/legal/LICENSE.txt.
  *
  * GPL Classpath Exception:
  * Oracle designates this particular file as subject to the "Classpath"
  * exception as provided by Oracle in the GPL Version 2 section of the License
  * file that accompanied this code.
  *
  * Modifications:
  * If applicable, add the following below the License Header, with the fields
  * enclosed by brackets [] replaced by your own identifying information:
  * "Portions Copyright [year] [name of copyright owner]"
  *
  * Contributor(s):
  * If you wish your version of this file to be governed by only the CDDL or
  * only the GPL Version 2, indicate your decision by adding "[Contributor]
  * elects to include this software in this distribution under the [CDDL or GPL
  * Version 2] license."  If you don't indicate a single choice of license, a
  * recipient has the option to distribute your version of this file under
  * either the CDDL, the GPL Version 2 or to extend the choice of license to
  * its licensees as provided above.  However, if you add GPL Version 2 code
  * and therefore, elected the GPL Version 2 license, then the option applies
  * only if the new code is made subject to such option by the copyright
  * holder.
  */
 
 package com.sun.enterprise.web;
 
 
 
 import java.util.List;
 
 public class ServerConfigLookup {
 
     private static final Logger _logger = .....;
 
     @LogMessageInfo(
             message = "AvailabilityService was not defined - check domain.xml",
             level = "FINEST")
     public static final String AVAILABILITY_SERVICE_NOT_DEFINED = "AS-WEB-00301";
 
     @LogMessageInfo(
             message = "WebContainerAvailability not defined - check domain.xml",
             level = "FINEST")
     public static final String WEB_CONTAINER_AVAILABILITY_NOT_DEFINED = "AS-WEB-00302";
 
     @LogMessageInfo(
             message = "globalAvailability = {0}",
             level = "FINEST")
     public static final String GLOBAL_AVAILABILITY"AS-WEB-00303";
 
     @LogMessageInfo(
             message = "webContainerAvailability = {0}",
             level = "FINEST")
     public static final String WEB_CONTAINER_AVAILABILITY = "AS-WEB-00304";
 
     @LogMessageInfo(
             message = "webModuleAvailability = {0}",
             level = "FINEST")
     public static final String WEB_MODULE_AVAILABILITY = "AS-WEB-00305";
 
     @LogMessageInfo(
             message = "SERVER.XML persistenceType= {0}",
             level = "FINEST")
     public static final String PERSISTENCE_TYPE = "AS-WEB-00306";
 
     @LogMessageInfo(
            message = "SERVER.XML persistenceType missing",
            level = "FINEST")
    public static final String PERSISTENCE_TYPE_MISSING = "AS-WEB-00307";
    private Config configBean;
    @Inject
    private ClassLoaderHierarchy clh;


    
Get the session manager bean from domain.xml return null if not defined or other problem
  
        if ( == null) {
            return null;
        }
        
        WebContainer webContainerBean
            = .getExtensionByType(WebContainer.class);
        if (webContainerBean == null) {
            return null;
        }
        
        SessionConfig sessionConfigBean = webContainerBean.getSessionConfig();
        if (sessionConfigBean == null) {
            return null;
        }
        
        return sessionConfigBean.getSessionManager();
    }    
    
    
Get the manager properties bean from domain.xml return null if not defined or other problem
  
        
        SessionManager smBean = getInstanceSessionManager();
        if (smBean == null) {
            return null;
        }
        return smBean.getManagerProperties();
    } 
    
    
Get the store properties bean from domain.xml return null if not defined or other problem
  
        
        SessionManager smBean = getInstanceSessionManager();
        if (smBean == null) {
            return null;
        }
        return smBean.getStoreProperties();
    } 

    
Get the session properties bean from server.xml return null if not defined or other problem
      
        if ( == null) {
            return null;
        }
        
        WebContainer webContainerBean
            = .getExtensionByType(WebContainer.class);
        if (webContainerBean == null) {
            return null;
        }
        
        SessionConfig sessionConfigBean = webContainerBean.getSessionConfig();
        if (sessionConfigBean == null) {
            return null;
        }
        
        return sessionConfigBean.getSessionProperties();
    }


    
Get the availability-service element from domain.xml. return null if not found
        return .getAvailabilityService();
    }

    
Get the availability-enabled from domain.xml. return false if not found
   
    public boolean getAvailabilityEnabledFromConfig() {
        AvailabilityService as = this.getAvailabilityService();
        if (as == null) {
            if (.isLoggable(.)) {
                .log(.);
            }
            return false;
        }        
        if (as.getAvailabilityEnabled() == null) {
            return false;
        } else {
            return toBoolean(as.getAvailabilityEnabled());
        }
    }

    
Geo the web-container-availability element from domain.xml. return null if not found
     
        return ((as != null)? as.getExtensionByType(WebContainerAvailability.class) : null);
    }
    
    
Get the String value of the property under web-container-availability element from domain.xml whose name matches propName return null if not found

Parameters:
propName
                String propName) {
        return getWebContainerAvailabilityPropertyString(propNamenull);
    }

    
Get the String value of the property under web-container-availability element from domain.xml whose name matches propName return defaultValue if not found

Parameters:
propName
    
                String propName,
                String defaultValue) {
        WebContainerAvailability wcAvailabilityBean = getWebContainerAvailability();
        if (wcAvailabilityBean == null) {
            return defaultValue;
        }
        List<Propertyprops = wcAvailabilityBean.getProperty();
        if (props == null) {
            return defaultValue;
        }
        for (Property prop : props) {
            String name = prop.getName();
            String value = prop.getValue();
            if (name.equalsIgnoreCase(propName)) {
                return value;
            }
        }
        return defaultValue;
    } 


    
Get the availability-enabled for the web container from domain.xml. return inherited global availability-enabled if not found
        boolean globalAvailabilityEnabled = getAvailabilityEnabledFromConfig();
        if (was == null) {
            if (.isLoggable(.)) {
            }
            return globalAvailabilityEnabled;
        }
        if (was.getAvailabilityEnabled() == null) {
            return globalAvailabilityEnabled;
        } else {
            return toBoolean(was.getAvailabilityEnabled());
        }
    }

    
Get the sso-failover-enabled boolean from domain.xml.
    public boolean isSsoFailoverEnabledFromConfig() {
        WebContainerAvailability webContainerAvailabilityBean = getWebContainerAvailability();
        if (webContainerAvailabilityBean == null) {
            return false;
        }
        if (webContainerAvailabilityBean.getSsoFailoverEnabled() == null) {
            return false;
        } else {
            return toBoolean(webContainerAvailabilityBean.getSsoFailoverEnabled());
        }
    }

    
Get the availability-enabled from domain.xml. This takes into account: global web-container-availability return false if not found
    public boolean calculateWebAvailabilityEnabledFromConfig() {
        // global availability from <availability-service> element
        boolean globalAvailability = getAvailabilityEnabledFromConfig();
        if (.isLoggable(.)) {
            .log(.globalAvailability);
        }
        // web container availability from <web-container-availability>
        // sub-element
        boolean webContainerAvailability =
        if (.isLoggable(.)) {
            .log(.webContainerAvailability);
        }
        return globalAvailability && webContainerAvailability;
    }

    
Get the availability-enabled from domain.xml. This takes into account: global web-container-availability web-module (if stand-alone) return false if not found
   
        boolean waEnabled = calculateWebAvailabilityEnabledFromConfig();
        boolean webModuleAvailability = false;
        if (dc != null) {
            DeployCommandParameters params = dc.getCommandParameters(DeployCommandParameters.class);
            if (params != null) {
                webModuleAvailability = params.availabilityenabled;
            }
        }
        if (.isLoggable(.)) {
            .log(.webModuleAvailability);
        }
        return waEnabled && webModuleAvailability;
    }
    public boolean getAsyncReplicationFromConfig(WebModule ctx) {
        boolean asyncReplication = true;
        if (dc != null) {
            DeployCommandParameters params = dc.getCommandParameters(DeployCommandParameters.class);
            if (params != null) {
                asyncReplication = params.asyncreplication;
            }
        }
        return asyncReplication;
    }

    
Get the persistenceType from domain.xml. return null if not found
        String persistenceTypeString = null;      
        PersistenceType persistenceType = null;
        WebContainerAvailability webContainerAvailabilityBean =
            getWebContainerAvailability();
        if (webContainerAvailabilityBean == null) {
            return null;
        }
        persistenceTypeString = webContainerAvailabilityBean.getPersistenceType();
        if (persistenceTypeString != null) {
            persistenceType = PersistenceType.parseType(persistenceTypeString);
        }
        if (persistenceType != null) {
            if (.isLoggable(.)) {
                .log(.persistenceType.getType());
            }
        } else {
            if (.isLoggable(.)) {
                .log(.);
            }
        }
        return persistenceType;
    }     
    
    
Get the persistenceFrequency from domain.xml. return null if not found
        WebContainerAvailability webContainerAvailabilityBean =
            getWebContainerAvailability();
        if (webContainerAvailabilityBean == null) {
            return null;
        }
        return webContainerAvailabilityBean.getPersistenceFrequency();      
    }
    
    
Get the persistenceScope from domain.xml. return null if not found
        WebContainerAvailability webContainerAvailabilityBean =
            getWebContainerAvailability();
        if (webContainerAvailabilityBean == null) {
            return null;
        }
        return webContainerAvailabilityBean.getPersistenceScope(); 
    }
    
    public boolean getDisableJreplicaFromConfig() {
        WebContainerAvailability webContainerAvailabilityBean = getWebContainerAvailability();
        if (webContainerAvailabilityBean == null) {
            return false;
        }
        return toBoolean(webContainerAvailabilityBean.getDisableJreplica());
    }

    
convert the input value to the appropriate Boolean value if input value is null, return null
     
    protected Boolean toBoolean(String value) {
        if (value.equalsIgnoreCase("true")
                || value.equalsIgnoreCase("yes")
                || value.equalsIgnoreCase("on")
                || value.equalsIgnoreCase("1")) {
            return .;
        }
        return .;
    }


    
Loads the requested class using the Common Classloader

Parameters:
className the name of the class to load
Returns:
the loaded class
    Class loadClass(String classNamethrows Exception {
        return .getCommonClassLoader().loadClass(className);
    }
New to GrepCode? Check out our FAQ X