开发者

Why does Tomcat use reflection for Catalina instancilization

Reading the Tomcat 7 source code, I just wonder why Tomcat instance Catalina and invokes the related methods by using reflection instead of simply using new to create the object and calling the method direc开发者_开发问答tly?


The answer is in the javadoc comment of the Bootstrap class:

/**
 * Bootstrap loader for Catalina.  This application constructs a class loader
 * for use in loading the Catalina internal classes (by accumulating all of the
 * JAR files found in the "server" directory under "catalina.home"), and
 * starts the regular execution of the container.  The purpose of this
 * roundabout approach is to keep the Catalina internal classes (and any
 * other classes they depend on, such as an XML parser) out of the system
 * class path and therefore not visible to application level classes.
 *
 * @author Craig R. McClanahan
 * @author Remy Maucherat
 * @version $Id: Bootstrap.java 1142323 2011-07-02 21:57:12Z markt $
 */

public final class Bootstrap { ... }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜