日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

tomcat(supplement)HttpConnector.initialize() 和 start() 方法 以及 StandardContext.start()方法的分析

發布時間:2023/12/3 编程问答 36 豆豆
生活随笔 收集整理的這篇文章主要介紹了 tomcat(supplement)HttpConnector.initialize() 和 start() 方法 以及 StandardContext.start()方法的分析 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

【0】README

0.0)本文中源代碼的背景,參見?tomcat(9)session管理

0.1)本文主要以圖片的形式分析他們大致的調用過程;

0.2)HttpConnector == org.apache.catalina.connector.http.HttpConnector; 而StandardContext ==?org.apache.catalina.core.StandardContext;

0.3)應用程序的source code 如下:

public final class Bootstrap {public static void main(String[] args) {System.setProperty("catalina.base", System.getProperty("user.dir"));Connector connector = new HttpConnector();Wrapper wrapper1 = new SimpleWrapper();wrapper1.setName("Session");wrapper1.setServletClass("SessionServlet");Context context = new StandardContext();context.setPath("/myApp");context.setDocBase("myApp");context.addChild(wrapper1);context.addServletMapping("/myApp/Session", "Session");LifecycleListener listener = new SimpleContextConfig();((Lifecycle) context).addLifecycleListener(listener);Loader loader = new WebappLoader();context.setLoader(loader);connector.setContainer(context);Manager manager = new StandardManager();context.setManager(manager);try {connector.initialize(); // highlight line.((Lifecycle) connector).start(); // highlight line.((Lifecycle) context).start(); // highlight line.// make the application wait until we press a key.System.in.read();((Lifecycle) context).stop();}catch (Exception e) {e.printStackTrace();}} }

【1】HttpConnector.initialize()



【2】HttpConnector.start()



【3】StandardContext.start()



/*** Load and initialize all servlets marked "load on startup" in the* web application deployment descriptor.** @param children Array of wrappers for all currently defined* servlets (including those not declared load on startup)*/public void loadOnStartup(Container children[]) { // org.apache.catalina.core.StandardContext.loadOnStartUp().// Collect "load on startup" servlets that need to be initializedTreeMap map = new TreeMap();for (int i = 0; i < children.length; i++) {Wrapper wrapper = (Wrapper) children[i];int loadOnStartup = wrapper.getLoadOnStartup();if (loadOnStartup < 0)continue;if (loadOnStartup == 0) // Arbitrarily put them lastloadOnStartup = Integer.MAX_VALUE;Integer key = new Integer(loadOnStartup);ArrayList list = (ArrayList) map.get(key);if (list == null) {list = new ArrayList();map.put(key, list);}list.add(wrapper);}// Load the collected "load on startup" servletsIterator keys = map.keySet().iterator();while (keys.hasNext()) {Integer key = (Integer) keys.next();ArrayList list = (ArrayList) map.get(key);Iterator wrappers = list.iterator();while (wrappers.hasNext()) {Wrapper wrapper = (Wrapper) wrappers.next();try {wrapper.load();} catch (ServletException e) {log(sm.getString("standardWrapper.loadException",getName()), e);// NOTE: load errors (including a servlet that throws// UnavailableException from tht init() method) are NOT// fatal to application startup}}}}

創作挑戰賽新人創作獎勵來咯,堅持創作打卡瓜分現金大獎

總結

以上是生活随笔為你收集整理的tomcat(supplement)HttpConnector.initialize() 和 start() 方法 以及 StandardContext.start()方法的分析的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。