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.io.File;
 import java.util.*;
 
 
 import org.w3c.dom.*;


Standard implementation of a virtual server (aka virtual host) in the iPlanet Application Server.
 
 
 public class VirtualServer extends StandardHost 
         implements org.glassfish.embeddable.web.VirtualServer {
 
     private static final String STATE = "state";
     private static final String SSO_MAX_IDLE ="sso-max-inactive-seconds";
     private static final String SSO_REAP_INTERVAL ="sso-reap-interval-seconds";
     private static final String SSO_COOKIE_SECURE ="sso-cookie-secure";
     private static final String DISABLED = "disabled";
     private static final String OFF = "off";
     private static final String ON = "on";

    
The logger to use for logging this virtual server
 
     private static final Logger DEFAULT_LOGGER = .;

    
The resource bundle containing the message strings for _logger.
 
     protected static final ResourceBundle rb = .getResourceBundle();
 
     @LogMessageInfo(
             message = "The web module {0} has been designated as the default-web-module for virtual server {1}",
             level = "FINE")
     public static final String VS_DEFAULT_WEB_MODULE = "AS-WEB-00100";
 
     @LogMessageInfo(
             message = "Error looking up the configuration information of the default-web-module {0} for virtual server {1}",
             level = "SEVERE",
             cause = "The web module specified is either not found or disabled or does not specify this virtual server, " +
                     "or there was an error loading its deployment descriptors",
             action = "Verify if the virtual server's default web module is valid")
     public static final String VS_DEFAULT_WEB_MODULE_NOT_FOUND = "AS-WEB-00101";
 
     @LogMessageInfo(
             message = "The default-web-module {0} is either disabled or does not specify virtual server {1}",
             level = "SEVERE",
             cause = "The default web module is disabled or does not specify virtual server",
             action = "Verify if the default web module is enabled and specify virtual server")
     public static final String VS_DEFAULT_WEB_MODULE_DISABLED = "AS-WEB-00102";
 
     @LogMessageInfo(
             message = "Virtual server {0} has invalid authentication realm {1}",
             level = "SEVERE",
             cause = "The realm {1} could not be found",
             action = "Verify if the realm {1} exits for virtual server {0}")
     public static final String INVALID_AUTH_REALM = "AS-WEB-00103";
 
     @LogMessageInfo(
             message = "Invalid sso-cookie-secure configuration {0} for virtual server {1}",
             level = "INFO")
     public static final String INVALID_SSO_COOKIE_SECURE = "AS-WEB-00104";
 
     @LogMessageInfo(
             message = "Realm {0} is not an instance of {1}, and will be ignored",
             level = "SEVERE",
             cause = "The realm {0} is either NULL or is not an instance of {1}",
             action = "Verify if the realm {0} is an instance of {1}")
     public static final String IGNORE_INVALID_REALM = "AS-WEB-00105";
 
     @LogMessageInfo(
             message = "Virtual server {0} has a property with missing name or value",
             level = "WARNING")
     public static final String NULL_VIRTUAL_SERVER_PROPERTY = "AS-WEB-00106";
 
     @LogMessageInfo(
             message = "Invalid redirect property value {0} for virtual server {1}: More than one {2} component",
             level = "WARNING")
     public static final String REDIRECT_MULTIPLE_ELEMENT = "AS-WEB-00107";
 
     @LogMessageInfo(
             message = "Invalid redirect property value {0} for virtual server {1}: Missing url or url-prefix component",
             level = "WARNING")
     public static final String REDIRECT_MISSING_URL_OR_URL_PREFIX = "AS-WEB-00108";
 
     @LogMessageInfo(
             message = "Invalid redirect property value {0} for virtual server {1}: Both url and url-prefix specified",
             level = "WARNING")
 
     public static final String REDIRECT_BOTH_URL_AND_URL_PREFIX = "AS-WEB-00109";
 
     @LogMessageInfo(
             message = "Invalid redirect property value {0} for virtual server {1}: escape must be equal to yes or no",
             level = "WARNING")
     public static final String REDIRECT_INVALID_ESCAPE = "AS-WEB-00110";
 
     @LogMessageInfo(
             message = "Invalid send-error property value {0} for virtual server {1}: More than one {2} component",
             level = "WARNING")
     public static final String SEND_ERROR_MULTIPLE_ELEMENT = "AS-WEB-00111";
 
     @LogMessageInfo(
             message = "Invalid send-error property value {0} for virtual server {1}: Missing path component",
             level = "WARNING")
     public static final String SEND_ERROR_MISSING_PATH = "AS-WEB-00112";
 
     @LogMessageInfo(
             message = "Unable to add listener of type {0} to virtual server {1}",
             level = "SEVERE",
             cause = "The listener is not an instance of ContainerListener or LifecycleListener",
             action = "Verify if the listener type is supported")
     public static final String INVALID_LISTENER = "AS-WEB-00113";
 
     @LogMessageInfo(
             message = " Unable to load extension class {0} from web module {1}",
             level = "SEVERE",
             cause = "An exception occurred loading extension class",
             action = "Check the exception for the error")
     public static final String UNABLE_TO_LOAD_EXTENSION = "AS-WEB-00114";
 
     @LogMessageInfo(
             message = "Object of type classname {0} not an instance of Valve or GlassFishValve",
             level = "WARNING")
     public static final String NOT_A_VALVE = "AS-WEB-00115";
 
     @LogMessageInfo(
             message = "Error adding HttpProbes. NetworkListener {0}'s HttpCodecFilter is {1}",
             level = "SEVERE",
             cause = "HttpCodecFilter is either NULL or empty",
             action = "Verify the NetworkListener is valid")
     public static final String CODE_FILTERS_NULL = "AS-WEB-00116";
 
     @LogMessageInfo(
             message = "Error adding HttpProbes",
             level = "SEVERE",
             cause = "An exception occurred adding HttpProbes",
             action = "Check the exception for the error")
     public static final String ADD_HTTP_PROBES_ERROR = "AS-WEB-00117";
 
     @LogMessageInfo(
             message = "Disabling Single Sign On (SSO) for virtual server {0} as configured",
             level = "FINE")
     public static final String DISABLE_SSO"AS-WEB-00118";
 
     @LogMessageInfo(
             message = "Enabling Single Sign On (SSO) for virtual server {0} as configured",
             level = "FINE")
     public static final String ENABLE_SSO = "AS-WEB-00119";
 
     @LogMessageInfo(
             message = "SSO entry max idle time set to {0} for virtual server {1}",
             level = "FINE")
     public static final String SSO_MAX_INACTIVE_SET"AS-WEB-00120";
 
     @LogMessageInfo(
             message = "SSO expire thread interval set to {0} for virtual server {1}",
             level = "FINE")
     public static final String SSO_REAP_INTERVAL_SET = "AS-WEB-00121";
 
     @LogMessageInfo(
             message = "Allowing access to {0} from {1}",
             level = "FINE")
     public static final String ALLOW_ACCESS = "AS-WEB-00122";
 
     @LogMessageInfo(
             message = "Denying access to {0} from {1}",
             level = "FINE")
     public static final String DENY_ACCESS = "AS-WEB-00123";
 
     @LogMessageInfo(
             message = "Virtual server {0} enabled context {1}",
             level = "FINE")
     public static final String VS_ENABLED_CONTEXT = "AS-WEB-00124";
 
     @LogMessageInfo(
             message = "Unable to delete {0}",
             level = "WARNING")
     public static final String UNABLE_TO_DELETE = "AS-WEB-00125";
 
     @LogMessageInfo(
             message = "Unable to reconfigure access log valve",
             level = "SEVERE",
             cause = "An exception occurred during access log valve reconfiguration",
             action = "Check the exception for error")
     public static final String UNABLE_RECONFIGURE_ACCESS_LOG = "AS-WEB-00126";
 
     @LogMessageInfo(
             message = "Virtual server {0} added context {1}",
             level = "FINE")
     public static final String VS_ADDED_CONTEXT = "AS-WEB-00127";
 
     @LogMessageInfo(
             message = "Application {0} is not found",
             level = "SEVERE",
             cause = "The deployed application is not found",
             action = "Check if the application is valid")
     public static final String APP_NOT_FOUND = "AS-WEB-00128";
 
     @LogMessageInfo(
             message = "Cannot create context for undeployment",
             level = "SEVERE",
             cause = "An IOException occurred during undeployment",
             action = "Check the exception for error")
     public static final String REMOVE_CONTEXT_ERROR = "AS-WEB-00129";
 
     @LogMessageInfo(
             message = "Successfully removed context {0}",
             level = "FINE")
     public static final String REMOVED_CONTEXT = "AS-WEB-00130";
 
     @LogMessageInfo(
             message = "Modifying web.xml {0}",
             level = "FINE")
     public static final String MODIFYING_WEB_XML = "AS-WEB-00131";
 
     @LogMessageInfo(
             message = "Error adding HttpProbes. NetworkListener {0}'s GrizzlyProxy is NULL",
             level = "SEVERE",
             cause = "GrizzlyProxy is NULL",
             action = "Verify the NetworkListener is valid")
     public static final String PROXY_NULL = "AS-WEB-00132";
 
 
     // ------------------------------------------------------------ Constructor
 
    
Default constructor that simply gets a handle to the web container subsystem's logger.
 
     public VirtualServer() {
          = ;
          = new VirtualServerPipeline(this);
          = new PEAccessLogValve();
         .setContainer(this);
     }
 
     // ----------------------------------------------------- Instance Variables
 
     /*
      * The custom pipeline of this VirtualServer, which implements the
      * following virtual server features:
      *
      * - state (disabled/off)
      * - redirects
      */
 
     /*
      * The original (standard) pipeline of this VirtualServer.
      *
      * Only one (custom or original) pipeline may be active at any given time.
      * Any updates (such as adding or removing valves) to the currently
      * active pipeline are propagated to the other.
      */
     private Pipeline origPipeline;

    
The id of this virtual server as specified in the configuration.
 
     private String _id = null;

    
The logger to use for logging this virtual server
 
     protected Logger _logger = ;

    
The descriptive information about this implementation.
 
     private static final String _info =
         "com.sun.enterprise.web.VirtualServer/1.0";

    
The config bean associated with this VirtualServer
 
The mime mapping associated with this VirtualServer
 
     private MimeMap mimeMap;
 
     /*
      * Indicates whether symbolic links from this virtual server's docroot
      * are followed. This setting is inherited by all web modules deployed on
      * this virtual server, unless overridden by a web modules allowLinking
      * property in sun-web.xml.
      */
     private boolean allowLinking = false;
 
     private String[] cacheControls;
 
     private ClassLoaderHierarchy clh;
 
     private Domain domain;
 
     private ServiceLocator services;
 
     // Is this virtual server active?
     private boolean isActive;
 
     private String authRealmName;
 
     /*
      * The accesslog valve of this VirtualServer.
      *
      * This valve is activated, that is, added to this virtual server's
      * pipeline, only when access logging has been enabled. When acess logging
      * has been disabled, this valve is removed from this virtual server's
      * pipeline.
      */
     private PEAccessLogValve accessLogValve;
 
     // The value of the ssoCookieSecure property
     private String ssoCookieSecure = null;
 
     private boolean ssoCookieHttpOnly = false;
 
     private String defaultContextPath = null;
 
     private ServerContext serverContext;
 
     private Config serverConfig;
 
     private GrizzlyService grizzlyService;
 
     private WebContainer webContainer;
 
     private boolean ssoFailoverEnabled = false;
 
     private volatile FileLoggerHandler fileLoggerHandler = null;
 
     private volatile FileLoggerHandlerFactory fileLoggerHandlerFactory = null;
 
     private Deployment deployment = null;
 
     private ArchiveFactory factory = null;
 
     private ActionReport report = null;
 
     private HttpProbeImpl httpProbe = null;
 
     // ------------------------------------------------------------- Properties
 
    
Return the virtual server identifier.
 
     public String getID() {
         return ;
     }

    
Set the virtual server identifier string.

Parameters:
id New identifier for this virtual server
 
     public void setID(String id) {
          = id;
     }

    
Sets the state of this virtual server.

Parameters:
isActive true if this virtual server is active, false otherwise
 
     public void setIsActive(boolean isActive) {
         this. = isActive;
         if (isActive) {
             .setIsDisabled(false);
             .setIsOff(false);
             if ( ==  && !.hasRedirects()) {
                 // Restore original pipeline
                 setPipeline();
             }
         }
     }
    
    
Gets the value of the allowLinking property of this virtual server.

Returns:
true if symbolic links from this virtual server's docroot (as well as symbolic links from archives of web modules deployed on this virtual server) are followed, false otherwise
 
     public boolean getAllowLinking() {
         return ;
     }

    
Sets the allowLinking property of this virtual server, which determines whether symblic links from this virtual server's docroot are followed. This property is inherited by all web modules deployed on this virtual server, unless overridden by the allowLinking property in a web module's sun-web.xml.

Parameters:
allowLinking Value of allowLinking property
 
     public void setAllowLinking(boolean allowLinking) {
         this. = allowLinking;
     }

    
Gets the config bean associated with this VirtualServer.
 
         return ;
     }

    
Sets the config bean for this VirtualServer
 
     public void setBean(
             com.sun.enterprise.config.serverbeans.VirtualServer vsBean){
         this. = vsBean;
     }

    
Gets the mime map associated with this VirtualServer.
 
     public MimeMap getMimeMap(){
         return ;
     }

    
Sets the mime map for this VirtualServer
 
     public void setMimeMap(MimeMap mimeMap){
         this. = mimeMap;
     }

    
Gets the Cache-Control configuration of this VirtualServer.

Returns:
Cache-Control configuration of this VirtualServer, or null if no such configuration exists for this VirtualServer
 
     public String[] getCacheControls() {
         return ;
     }

    
Sets the Cache-Control configuration for this VirtualServer

Parameters:
cacheControls Cache-Control configuration settings for this VirtualServer
 
     public void setCacheControls(String[] cacheControls) {
         this. = cacheControls;
     }
 
     public void setServices(ServiceLocator services) {
         this. = services;
     }
 
     public String getInfo() {
         return ;
     }
 
     public void setDefaultContextPath(String defaultContextPath) {
         this. = defaultContextPath;
     }
 
     public void setFileLoggerHandlerFactory(FileLoggerHandlerFactory factory) {
          = factory;
     }
 
     public void setClassLoaderHierarchy(ClassLoaderHierarchy clh) {
         this. = clh;
     }
 
     public void setDomain(Domain domain) {
         this. = domain;
     }
 
     @Override
     public Container findChild(String contextRoot) {
         if ( != null && "/".equals(contextRoot)) {
             return super.findChild();
         } else {
             return super.findChild(contextRoot);
         }
     }
 
 
     // --------------------------------------------------------- Public Methods
 
    
Configures the Secure attribute of the given SSO cookie.

Parameters:
ssoCookie the SSO cookie to be configured
hreq the HttpServletRequest that has initiated the SSO session
 
     @Override
     public void configureSingleSignOnCookieSecure(Cookie ssoCookie,
                                                   HttpServletRequest hreq) {
         super.configureSingleSignOnCookieSecure(ssoCookiehreq);
         if ( != null &&
                 !.equals(.)) {
             ssoCookie.setSecure(Boolean.parseBoolean());
         }
     }
 
     @Override
     public void configureSingleSignOnCookieHttpOnly(Cookie ssoCookie) {
         ssoCookie.setHttpOnly();
     }
 
 
     // ------------------------------------------------------ Lifecycle Methods
 
    
Adds the given valve to the currently active pipeline, keeping the pipeline that is not currently active in sync.
 
     public synchronized void addValve(GlassFishValve valve) {
         super.addValve(valve);
         if ( == ) {
             .addValve(valve);
         } else {
             .addValve(valve);
         }
     }


    
Adds the given Tomcat-style valve to the currently active pipeline, keeping the pipeline that is not currently active in sync.
 
     public synchronized void addValve(Valve valve) {
         super.addValve(valve);
         if ( == ) {
             .addValve(valve);
         } else {
             .addValve(valve);
         }
     }


    
Removes the given valve from the currently active pipeline, keeping the valve that is not currently active in sync.
 
     public synchronized void removeValve(GlassFishValve valve) {
         super.removeValve(valve);
         if ( == ) {
             .removeValve(valve);
         } else {
             .removeValve(valve);
         }
     }
     
     	if ( == nullreturn null;
     	return .getService(ConfigBeansUtilities.class);
     }
 
     // ------------------------------------------------------ Protected Methods
 
    
Gets the context root of the web module that the user/configuration has designated as the default-web-module for this virtual server. The default-web-module for a virtual server is specified via the 'default-web-module' attribute of the 'virtual-server' element in server.xml. This is an optional attribute and if the configuration does not specify another web module (standalone or part of a j2ee-application) that is configured at a context-root="", then a default web module will be created and loaded. The value for this attribute is either "${standalone-web-module-name}" or "${j2ee-app-name}:${web-module-uri}".

Returns:
null if the default-web-module has not been specified or if the web module specified either could not be found or is disabled or does not specify this virtual server (if it specifies a value for the virtual-servers attribute) or if there was an error loading its deployment descriptors.
 
     protected String getDefaultContextPath(Domain domain,
             ApplicationRegistry appRegistry) {
 
         String contextRoot = null;
         String wmID = getDefaultWebModuleID();
 
         if (wmID != null) {
             // Check if the default-web-module is part of a
             // j2ee-application
             Applications appsBean = domain.getApplications();
             WebModuleConfig wmInfo = findWebModuleInJ2eeApp(appsBeanwmID,
                                                             appRegistry);
             if (wmInfo == null) {
             	ConfigBeansUtilities cbu = getConfigBeansUtilities();
             	if (cbu == null) {
             		contextRoot = null;
             	}
             	else {
                     contextRoot = cbu.getContextRoot(wmID);
             	}
             } else {
                 contextRoot = wmInfo.getContextPath();
             }
 
             if (contextRoot == null) {
                 Object[] params = { wmIDgetID() };
                 .log(.params);
             }
         }
 
         return contextRoot;
     }
 
     protected WebModuleConfig getDefaultWebModule(Domain domain,
             WebArchivist webArchivistApplicationRegistry appRegistry) {
 
         WebModuleConfig wmInfo = null;
 
         String wmID = getDefaultWebModuleID();
         if (wmID != null) {
             // Check if the default-web-module is part of a
             // j2ee-application
             Applications appsBean = domain.getApplications();
             wmInfo = findWebModuleInJ2eeApp(appsBeanwmIDappRegistry);
             if (wmInfo == null) {
             	ConfigBeansUtilities cbu = getConfigBeansUtilities();
             	String contextRoot = null;
             	String location = null;
             	if (cbu != null) {
             		contextRoot = cbu.getContextRoot(wmID);
             		location = cbu.getLocation(wmID);
             	}
             	
                 if (contextRoot!=null && location != null) {
                     File docroot = new File(location);
                     WebBundleDescriptorImpl wbd = webArchivist.getDefaultWebXmlBundleDescriptor();
                     wmInfo = new WebModuleConfig();
                     wbd.setName(.);
                     wbd.setContextRoot(contextRoot);
                     wmInfo.setLocation(docroot);
                     wmInfo.setDescriptor(wbd);
                     wmInfo.setParentLoader(EmbeddedWebContainer.class.getClassLoader());
                     WebappClassLoader cloader = AccessController.doPrivileged(new PrivilegedAction<WebappClassLoader>() {
                         @Override
                         public WebappClassLoader run() {
                             return new WebappClassLoader(EmbeddedWebContainer.class.getClassLoader());
                         }
                     });
                     wmInfo.setAppClassLoader(cloader);
                 }
             }
 
             if (wmInfo == null) {
                 .log(.new Object[] {wmIDgetID()});
             }
         }
 
         return wmInfo;
     }


    
If a default web module has not yet been configured and added to this virtual server's list of web modules then return the configuration information needed in order to create a default web module for this virtual server. This method should be invoked only after all the standalone modules and the modules within j2ee-application elements have been added to this virtual server's list of modules (only then will one know whether the user has already configured a default web module or not).
 
             WebArchivist webArchivist) {
 
         WebModuleConfig wmInfo = null;
 
         // Add a default context only if one hasn't already been loaded
         // and then too only if docroot is not null
         //
         String docroot = getAppBase();
         if (getDefaultWebModuleID() == null && findChild("") == null
                 && docroot != null) {
 
             WebBundleDescriptorImpl wbd =
                 webArchivist.getDefaultWebXmlBundleDescriptor();
             wmInfo = new WebModuleConfig();
             wbd.setModuleID(.);
             wbd.setContextRoot("");
             wmInfo.setLocation(new File(docroot));
             wmInfo.setDescriptor(wbd);
             wmInfo.setParentLoader(
                 .getCommonClassLoader());
             WebappClassLoader loader = AccessController.doPrivileged(new PrivilegedAction<WebappClassLoader>() {
                 @Override
                 public WebappClassLoader run() {
                     return new WebappClassLoader(.getCommonClassLoader());
                 }
             });
             loader.start();            
             wmInfo.setAppClassLoader(loader);
             if ( wbd.getApplication() == null ) {
                 Application application = Application.createApplication();
                 application.setVirtual(true);
                 application.setName(.);
                 wbd.setApplication(application);
             }
         }
 
         return wmInfo;
 
     }

    
Returns the id of the default web module for this virtual server as specified in the 'default-web-module' attribute of the 'virtual-server' element.
 
     protected String getDefaultWebModuleID() {
         String wmID = .getDefaultWebModule();
         if ("".equals(wmID)) {
             wmID = null;
         }
         if (wmID != null && .isLoggable(.)) {
             Object[] params = { wmID };
             .log(.params);
         }
 
         return wmID;
     }

    
Finds and returns information about a web module embedded within a J2EE application, which is identified by a string of the form a:b or a#b, where a is the name of the J2EE application and b is the name of the embedded web module.

Returns:
null if id does not identify a web module embedded within a J2EE application.
 
     protected WebModuleConfig findWebModuleInJ2eeApp(Applications appsBean,
             String idApplicationRegistry appRegistry) {
 
         WebModuleConfig wmInfo = null;
 
         // Check for ':' separator
         int separatorIndex = id.indexOf(.);
         if (separatorIndex == -1) {
             // Check for '#' separator
             separatorIndex = id.indexOf('#');
         }
         if (separatorIndex != -1) {
             String appID = id.substring(0, separatorIndex);
             String moduleID = id.substring(separatorIndex + 1);
 
             com.sun.enterprise.config.serverbeans.Application appBean =
                 appsBean.getModule(
                 com.sun.enterprise.config.serverbeans.Application.classappID);
 
             if ((appBean != null) && Boolean.valueOf(appBean.getEnabled())) {
                 String location = appBean.getLocation();
                 String moduleDir = DeploymentUtils.getRelativeEmbeddedModulePath(
                                                             locationmoduleID);
 
                 ApplicationInfo appInfo = appRegistry.get(appID);
                 Application app = null;
                 if (appInfo != null) {
                     app = appInfo.getMetaData(Application.class);
                 } else {
                     // XXX ApplicaionInfo is NULL after restart
                     Object[] params = { idgetID() };
                     .log(.,
                             params);
                     return wmInfo;
                 }
 
                 WebBundleDescriptorImpl wbd = app.getModuleByTypeAndUri(WebBundleDescriptorImpl.classmoduleID);
                 String webUri = wbd.getModuleDescriptor().getArchiveUri();
                 String contextRoot = wbd.getModuleDescriptor().getContextRoot();
                 if (moduleID.equals(webUri)) {
                     StringBuilder dir = new StringBuilder(location);
                     dir.append(.);
                     dir.append(moduleDir);
                     File docroot = new File(dir.toString());
                     wmInfo = new WebModuleConfig();
                     wbd.setName(moduleID);
                     wbd.setContextRoot(contextRoot);
                     wmInfo.setDescriptor(wbd);
                     wmInfo.setLocation(docroot);
                     wmInfo.setParentLoader(EmbeddedWebContainer.class.getClassLoader());
                     WebappClassLoader cloader = AccessController.doPrivileged(new PrivilegedAction<WebappClassLoader>() {
                         @Override
                         public WebappClassLoader run() {
                             return new WebappClassLoader(EmbeddedWebContainer.class.getClassLoader());
                         }
                     });
                     wmInfo.setAppClassLoader(cloader);
 
                 }
             } else {
                 Object[] params = { idgetID() };
                 .log(.,
                             params);
             }
         }
 
         return wmInfo;
     }

    
Virtual servers are maintained in the reference contained in Server element. First, we need to find the server and then get the virtual server from the correct reference

Parameters:
appName Name of the app to get vs
Returns:
virtual servers as a string (separated by space or comma) private String getVirtualServers(String appName) { String ret = null; Server server = Globals.getDefaultHabitat().forContract(Server.class).get(); for (ApplicationRef appRef : server.getApplicationRef()) { if (appRef.getRef().equals(appName)) { return appRef.getVirtualServers(); } } return ret; }
 


    
Delete all aliases.
 
     public void clearAliases(){
          = new String[0];
     }
 
     private void setIsDisabled(boolean isDisabled) {
         .setIsDisabled(isDisabled);
         .setIsOff(false);
         if (isDisabled &&  != ) {
             // Enable custom pipeline
             setPipeline();
         }
     }
 
     private void setIsOff(boolean isOff) {
         .setIsOff(isOff);
         .setIsDisabled(false);
        if (isOff &&  != ) {
            // Enable custom pipeline
            setPipeline();
        }
    }
    private void close(FileLoggerHandler handler) {
        if (handler != null && !handler.isAssociated()) {
            if ( != null) {
                // should always be here
                .removeHandler(handler.getLogFile());
            }
            handler.flush();
            handler.close();
        }
    }
    private void setLogger(Logger newLoggerString logLevel) {
         = newLogger;
        // wrap into a cataline logger
        CatalinaLogger catalinaLogger = new CatalinaLogger(newLogger);
        catalinaLogger.setLevel(logLevel);
        setLogger(catalinaLogger);
    }

    

Returns:
The properties of this virtual server
        return .getProperty();
    }

    
Configures this virtual server.
    public void configure(
                    String vsID,
                    com.sun.enterprise.config.serverbeans.VirtualServer vsBean,
                    String vsDocroot,
                    String vsLogFile,
                    MimeMap vsMimeMap,
                    String logServiceFile,
                    String logLevel) {
        setDebug();
        setAppBase(vsDocroot);
        setName(vsID);
        setID(vsID);
        setBean(vsBean);
        setMimeMap(vsMimeMap);
        String defaultContextXmlLocation = .;
        String defaultWebXmlLocation = .;
        //Begin EE: 4920692 Make the default-web.xml be relocatable
        Property prop = vsBean.getProperty("default-web-xml");
        if (prop != null) {
            defaultWebXmlLocation = prop.getValue();
        }
        //End EE: 4920692 Make the default-web.xml be relocatable
        // allowLinking
        boolean allowLinking = false;
        prop = vsBean.getProperty("allowLinking");
        if (prop != null) {
            allowLinking = Boolean.parseBoolean(prop.getValue());
        }
        setAllowLinking(allowLinking);
        prop = vsBean.getProperty("contextXmlDefault");
        if (prop != null) {
            defaultContextXmlLocation = prop.getValue();
        }
        setDefaultWebXmlLocation(defaultWebXmlLocation);
        setDefaultContextXmlLocation(defaultContextXmlLocation);
        // Set vs state
        String state = vsBean.getState();
        if (state == null) {
            state = ;
        }
        if (.equalsIgnoreCase(state)) {
            setIsActive(false);
        } else {
            setIsActive(Boolean.parseBoolean(state));
        }
        setLogFile(vsLogFilelogLevellogServiceFile);
    }

    
Configures the valve_ and listener_ properties of this VirtualServer.
    protected void configureCatalinaProperties(){
        List<Propertyprops = .getProperty();
        if (props == null) {
            return;
        }
        for (Property prop : props) {
            String propName = prop.getName();
            String propValue = prop.getValue();
            if (propName == null || propValue == null) {
                .log(.,
                        ,
                        getName());
            }
            if (propName != null) {
                if (propName.startsWith("valve_")) {
                    addValve(propValue);
                } else if (propName.startsWith("listener_")) {
                    addListener(propValue);
                } else if (propName.equals("securePagesWithPragma")){
                    setSecurePagesWithPragma(Boolean.valueOf(propValue));
                }
            }
        }
    }
    /*
     * Configures this virtual server with the specified log file.
     *
     * @param logFile The value of the virtual server's log-file attribute in
     * the domain.xml
     */
    synchronized void setLogFile(String logFileString logLevelString logServiceFile) {

        
catalina file logger code String logPrefix = logFile; String logDir = null; String logSuffix = null; if (logPrefix == null || logPrefix.equals("")) { return; } int index = logPrefix.lastIndexOf(File.separatorChar); if (index != -1) { logDir = logPrefix.substring(0, index); logPrefix = logPrefix.substring(index+1); } index = logPrefix.indexOf('.'); if (index != -1) { logSuffix = logPrefix.substring(index); logPrefix = logPrefix.substring(0, index); } logPrefix += "_"; FileLogger contextLogger = new FileLogger(); if (logDir != null) { contextLogger.setDirectory(logDir); } contextLogger.setPrefix(logPrefix); if (logSuffix != null) { contextLogger.setSuffix(logSuffix); } contextLogger.setTimestamp(true); contextLogger.setLevel(logLevel);
        
        /*
         * Configure separate logger for this virtual server only if
         * 'log-file' attribute of this <virtual-server> and 'file'
         * attribute of <log-service> are different (See 6189219).
         */
        boolean noCustomLog =
            (logFile == null || logFile.equals(logServiceFile));
        if (( == null && noCustomLog) ||
                ( != null && logFile != null &&
                logFile.equals(.getLogFile()))) {
            return;
        }
        Logger newLogger = null;
        FileLoggerHandler oldHandler = ;
        //remove old handler
        if (oldHandler != null) {
            .removeHandler(oldHandler);
        }
        if (noCustomLog) {
             = null;
            newLogger = ;
        } else {
            // append the _logger name with "._vs.<virtual-server-id>"
            String lname = .getName() + "._vs." + getID();
            newLogger = LogManager.getLogManager().getLogger(lname);
            if (newLogger == null) {
                newLogger = new Logger(lnamenull) {
                    // set thread id, see LogDomains.getLogger method
                    @Override
                    public void log(LogRecord record) {
                        if (record.getResourceBundle() == null) {
                            ResourceBundle bundle = getResourceBundle();
                            if (bundle != null) {
                                record.setResourceBundle(bundle);
                            }
                        }
                        record.setThreadID((int)Thread.currentThread().getId());
                        super.log(record);
                    }
                    // use the same resource bundle as default vs logger
                    @Override
                    public ResourceBundle getResourceBundle() {
                        return ;
                    }
                    @Override
                    public synchronized void addHandler(Handler handler) {
                        super.addHandler(handler);
                        if (handler instanceof FileLoggerHandler) {
                            ((FileLoggerHandler)handler).associate();
                        }
                    }
                    @Override
                    public synchronized void removeHandler(Handler handler) {
                        if (!(handler instanceof FileLoggerHandler)) {
                            super.removeHandler(handler);
                        } else {
                            boolean hasHandler = false;
                            Handler[] hs = getHandlers();
                            if (hs != null) {
                                for (Handler h : hs) {
                                    if (h == handler) {
                                        hasHandler = true;
                                        break;
                                    }
                                }
                            }
                            if (hasHandler) {
                                super.removeHandler(handler);
                                ((FileLoggerHandler)handler).disassociate();
                            }
                        }
                    }
                };
                synchronized(Logger.class) {
                    LogManager.getLogManager().addLogger(newLogger);
                }
            }
            // remove old handlers if necessary
            Handler[] handlers = newLogger.getHandlers();
            if (handlers != null) {
                for (Handler h : handlers) {
                    newLogger.removeHandler(h);
                }
            }
            // add handlers from root that is not GFFileHandler
            Logger rootLogger = ..getParent();
            if (rootLogger != null) {
                Handler[] rootHandlers = rootLogger.getHandlers();
                if (rootHandlers != null) {
                    for (Handler h : rootHandlers) {
                        if (!(h instanceof GFFileHandler)) {
                            newLogger.addHandler(h);
                        }
                    }
                }
            }
            // create and add new handler
             = .getHandler(logFile);
            newLogger.addHandler();
            newLogger.setUseParentHandlers(false);
        }
        setLogger(newLoggerlogLevel);
        close(oldHandler);
    }

    
Adds each host name from the 'hosts' attribute as an alias
    void configureAliases()