zoukankan      html  css  js  c++  java
  • tomcat容器启动的启动过程(三)

    Catalina的start方法

       /**
         * Start a new server instance.
         */
        public void start() {
    
            if (server == null) {
                load();
            }
    
            long t1 = System.nanoTime();
            
            // Start the new server
            if (server instanceof Lifecycle) {
                try {
                    ((Lifecycle) server).start();//启动Server
                } catch (LifecycleException e) {
                    log.error("Catalina.start: ", e);
                }
            }
    
            long t2 = System.nanoTime();
            if(log.isInfoEnabled())
                log.info("Server startup in " + ((t2 - t1) / 1000000) + " ms");
    
            try {
                // Register shutdown hook
                if (useShutdownHook) {
                    if (shutdownHook == null) {
                        shutdownHook = new CatalinaShutdownHook();
                    }
                    Runtime.getRuntime().addShutdownHook(shutdownHook);
                }
            } catch (Throwable t) {
                // This will fail on JDK 1.2. Ignoring, as Tomcat can run
                // fine without the shutdown hook.
            }
        //启动完成 等待客户端连接
            if (await) {
                await();
                stop();
            }
    
        }

    启动server的时候启动service。

        public void start() throws LifecycleException {
    
            // Validate and update our current component state
            if (started) {
                log.debug(sm.getString("standardServer.start.started"));
                return;
            }
    
            // Notify our interested LifecycleListeners
            lifecycle.fireLifecycleEvent(BEFORE_START_EVENT, null);
    
            lifecycle.fireLifecycleEvent(START_EVENT, null);
            started = true;
    
            // Start our defined Services
            synchronized (services) {
                for (int i = 0; i < services.length; i++) {
                    if (services[i] instanceof Lifecycle)
                        ((Lifecycle) services[i]).start();//启动service
                }
            }
    
            // Notify our interested LifecycleListeners
            lifecycle.fireLifecycleEvent(AFTER_START_EVENT, null);
    
        }
  • 相关阅读:
    垃圾回收于内存优化(摘自网络)
    as3.0 动态改变影片剪辑的颜色
    2进制_8进制_16进制之间快速转换的技巧.txt
    24位真彩色转换为8位灰度图片(完整代码)
    大端模式和小端模式
    如何将真彩色图转换为各种灰度图
    C++图像缩放
    二进制转十进制快速转换方法
    电脑上运行的使用大全
    移位运算符详解
  • 原文地址:https://www.cnblogs.com/hjy9420/p/4285575.html
Copyright © 2011-2022 走看看