• 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);
    
        }
  • 相关阅读:
    go语言关于线程与通道channal
    linux 搭建SVN服务端
    使用mbedtls的使用说明和AES加密方法(原来的PolarSSL)
    清理 Xcode 10 记录
    Windows下修改iTunes备份路径
    Winform窗口自适应
    修改类模板文件
    HashTable
    修改App.config的键和值
    博客园动画效果
  • 原文地址:https://www.cnblogs.com/hjy9420/p/4285575.html
Copyright © 2020-2023  润新知