class SecurityClassLoad

package org.apache.catalina.startup
2003-03-24

package org.apache.catalina.startup;


/**
 * Static class used to preload java classes when using the
 * Java SecurityManager so that the defineClassInPackage
 * RuntimePermission does not trigger an AccessControlException.
 *
 * @author Glenn L. Nielsen
 * @version $Revision: 1.1 $ $Date: 2001/12/30 01:58:20 $
 */



/**
 * 该类只有一个静态方法,其作用仅仅相当于一个函数
 * 该静态方法负责载入一些指定的类
 * package org.apache.catalina.core
 * package org.apache.catalina.connector
 * package org.apache.catalina.loader
 * package org.apache.catalina.session
 * package org.apache.catalina.util
 * 这些包都在$CATALINA_HOME/server/catalina.jar文件中
 * (由此看来,该静态方法的合法参数仅为catalinaLoader?)
 */


public final class SecurityClassLoad {

    static void securityClassLoad(ClassLoader loader)
        throws Exception {

        if( System.getSecurityManager() == null )
            return;

        String basePackage = "org.apache.catalina.";
        loader.loadClass
            (basePackage +
             "core.ApplicationContext$PrivilegedGetRequestDispatcher");
        loader.loadClass
            (basePackage +
             "core.ApplicationContext$PrivilegedGetResource");
        loader.loadClass
            (basePackage +
             "core.ApplicationContext$PrivilegedGetResourcePaths");
        loader.loadClass
            (basePackage +
             "core.ApplicationContext$PrivilegedLogMessage");
        loader.loadClass
            (basePackage +
             "core.ApplicationContext$PrivilegedLogException");
        loader.loadClass
            (basePackage +
             "core.ApplicationContext$PrivilegedLogThrowable");
        loader.loadClass
            (basePackage +
             "core.ApplicationDispatcher$PrivilegedForward");
        loader.loadClass
            (basePackage +
             "core.ApplicationDispatcher$PrivilegedInclude");
        loader.loadClass
            (basePackage +
             "core.ContainerBase$PrivilegedAddChild");
        loader.loadClass
            (basePackage +
             "connector.HttpRequestBase$PrivilegedGetSession");
        loader.loadClass
            (basePackage +
             "connector.HttpResponseBase$PrivilegedFlushBuffer");
        loader.loadClass
            (basePackage +
             "loader.WebappClassLoader$PrivilegedFindResource");
        loader.loadClass
            (basePackage + "session.StandardSession");
        loader.loadClass
            (basePackage + "util.CookieTools");
        loader.loadClass
            (basePackage + "util.URL");
        loader.loadClass(basePackage + "util.Enumerator");
        loader.loadClass("javax.servlet.http.Cookie");

    }
}