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);
    
        }
  • 相关阅读:
    数据结构上篇
    异步编程下篇
    异步编程上篇
    异步编程中篇
    对象与原型对象下篇
    对象与原型对象上篇
    移动端开发
    函数进阶
    二.全局安装需要配置NODE_PATH命令
    一.完全删除VSC
  • 原文地址:https://www.cnblogs.com/hjy9420/p/4285575.html
Copyright © 2011-2022 走看看