zoukankan      html  css  js  c++  java
  • [tomcat] tomcat简析(一)

    1.Tomcat的顶层结构

       Tomcat中最顶层的容器叫Server,代表整个服务器,Server中包含至少一个Service,用于 具体提供服务。

       Service主要包含两部分:Connector和Container。Connector用于处理连接相关 的事情,并提供Socket与request、response的转换,Container用于封装和管理Servlet,以及具 体处理request请求。一个Tomcat中只有一个Server, —个Server可以包含多个Service,一个 Service只有一个Container,但可以有多个Connectors (因为一个服务可以有多个连接,如同时 提供http和https连接,也可以提供相同协议不同端门的连接),结构图如图

      2. Bootstrap 的启动过程

         

    public static void main(String args[]) {
    
            if (daemon == null) {
                // Don't set daemon until init() has completed
                Bootstrap bootstrap = new Bootstrap();
                try {
                    bootstrap.init();
                } catch (Throwable t) {
                    handleThrowable(t);
                    t.printStackTrace();
                    return;
                }
                daemon = bootstrap;
            } else {
                // When running as a service the call to stop will be on a new
                // thread so make sure the correct class loader is used to prevent
                // a range of class not found exceptions.
                Thread.currentThread().setContextClassLoader(daemon.catalinaLoader);
            }
    
            try {
                String command = "start";
                if (args.length > 0) {
                    command = args[args.length - 1];
                }
    
                if (command.equals("startd")) {
                    args[args.length - 1] = "start";
                    daemon.load(args);
                    daemon.start();
                } else if (command.equals("stopd")) {
                    args[args.length - 1] = "stop";
                    daemon.stop();
                } else if (command.equals("start")) {
                    daemon.setAwait(true);
                    daemon.load(args);
                    daemon.start();
                } else if (command.equals("stop")) {
                    daemon.stopServer(args);
                } else if (command.equals("configtest")) {
                    daemon.load(args);
                    if (null==daemon.getServer()) {
                        System.exit(1);
                    }
                    System.exit(0);
                } else {
                    log.warn("Bootstrap: command "" + command + "" does not exist.");
                }
            } catch (Throwable t) {
                // Unwrap the Exception for clearer error reporting
                if (t instanceof InvocationTargetException &&
                        t.getCause() != null) {
                    t = t.getCause();
                }
                handleThrowable(t);
                t.printStackTrace();
                System.exit(1);
            }
    
        }
    

      

  • 相关阅读:
    我看Slashdot
    三维地形建模工具(MultiGenParadigm公司)
    街头新景:数字公交站
    美国一公司开发出WiFi定位系统 比GPS更精确
    理想、激情、生存—— 一位技术管理人员的20年工作经历和感悟 (ZT)
    西安国际化 市场化 人文化 生态化发展报告
    Google Earth Plus
    Visual Studio 2003 “默认设置”快捷键
    Google免费开放地图大餐
    向Windows 2000道声珍重
  • 原文地址:https://www.cnblogs.com/qunan/p/7569315.html
Copyright © 2011-2022 走看看