zoukankan      html  css  js  c++  java
  • jetty启动源码分析

    Main类是jetty的启动类,是项目启动的入口,

    main方法通过解析传入的参数,来决定加载哪些组件的配置文件,默认根据jetty根目录下面的start.ini来决定加载。

    Main的start方法,会启动监控线程Monitor,在绝大情况下都不会使用,它会在接受到stop命令后,销毁Main创建的子进程。

    由Config加载start.conf,确定各个子模块所对应需要加载的jar包,及Main需要委托调用的主类,默认是XmlConfiguration类。

    在加载XmlConfiguration类定义时,切换了类加载器。

    XmlConfiguration实现了ioc功能,根据Main方法选定的配置文件,装配实例。

    如:

    <Configure id="Server" class="org.eclipse.jetty.server.Server">
    
        <!-- =========================================================== -->
        <!-- Server Thread Pool                                          -->
        <!-- =========================================================== -->
        <Set name="ThreadPool">
          <!-- Default queued blocking threadpool -->
          <New class="org.eclipse.jetty.util.thread.QueuedThreadPool">
            <Set name="minThreads">10</Set>
            <Set name="maxThreads">200</Set>
            <Set name="detailedDump">false</Set>
          </New>
        </Set>
    
        <!-- =========================================================== -->
        <!-- Set connectors                                              -->
        <!-- =========================================================== -->
    
        <Call name="addConnector">
          <Arg>
              <New class="org.eclipse.jetty.server.nio.SelectChannelConnector">
                <Set name="host"><Property name="jetty.host" /></Set>
                <Set name="port"><Property name="jetty.port" default="8080"/></Set>
                <Set name="maxIdleTime">300000</Set>
                <Set name="Acceptors">2</Set>
                <Set name="statsOn">false</Set>
                <Set name="confidentialPort">8443</Set>
            <Set name="lowResourcesConnections">20000</Set>
            <Set name="lowResourcesMaxIdleTime">5000</Set>
              </New>
          </Arg>
        </Call>
    
        <!-- =========================================================== -->
        <!-- Set handler Collection Structure                            --> 
        <!-- =========================================================== -->
        <Set name="handler">
          <New id="Handlers" class="org.eclipse.jetty.server.handler.HandlerCollection">
            <Set name="handlers">
             <Array type="org.eclipse.jetty.server.Handler">
               <Item>
                 <New id="Contexts" class="org.eclipse.jetty.server.handler.ContextHandlerCollection"/>
               </Item>
               <Item>
                 <New id="DefaultHandler" class="org.eclipse.jetty.server.handler.DefaultHandler"/>
               </Item>
             </Array>
            </Set>
          </New>
        </Set>
    
        <!-- =========================================================== -->
        <!-- extra options                                               -->
        <!-- =========================================================== -->
        <Set name="stopAtShutdown">true</Set>
        <Set name="sendServerVersion">true</Set>
        <Set name="sendDateHeader">true</Set>
        <Set name="gracefulShutdown">1000</Set>
        <Set name="dumpAfterStart">false</Set>
        <Set name="dumpBeforeStop">false</Set>
    
    </Configure>

    装配好实例之后,如果实例实现了LifeCycle接口,调用start方法完成初始工作。

  • 相关阅读:
    Ubuntu下安装mysql
    MySQL聚集索引与非聚集索引
    mysql索引的简单介绍
    Hive数据导入与导出
    hive的基本操作
    hive的数据模型
    29 ArcMap许可服务器点击授权后无法进入下一步
    28 ArcMap 运行特别慢怎么办
    27 ArcMap加载天地图服务一片空白怎么办
    26 Arcpy跳坑系列——ExportToPNG
  • 原文地址:https://www.cnblogs.com/knockon/p/3367292.html
Copyright © 2011-2022 走看看