zoukankan      html  css  js  c++  java
  • tomcat架构分析和源码解读

        最近在看《深入分析java web技术内幕》,书中讲解了一部分tomcat的相关知识,我也去查看了一些源码,看了大神们写的代码,我才知道自己就像在做加减乘除一样,这是不行的。还有好多包和类要属性。就像要盖高楼大厦一样,对其不熟悉怎么行呢?只有对底层架构了如指掌,才能流畅的写业务,同时也是一个学习的过程。

      private Context createContext(Host host, String url) {
            String contextClass = StandardContext.class.getName();
            if (host == null) {
                host = this.getHost();
            }
    
            if (host instanceof StandardHost) {
                contextClass = ((StandardHost)host).getContextClass();
            }
    
            try {
                return (Context)Class.forName(contextClass).getConstructor().newInstance();
            } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException | ClassNotFoundException | InstantiationException var5) {
                throw new IllegalArgumentException("Can't instantiate context-class " + contextClass + " for host " + host + " and url " + url, var5);
            }
        }
    

      Tomcat.class中的一个方法,自己实现这个方法,能够学习很多。Context和Host的关系,已经cath中多个异常的写法,还有throw和throws的写法。

    -----------------------

    再补充一下,在linux下安装tomcat的问题,首先就是要配置好java的path,然后有一个小问题就是,startup.sh和catlatina.sh需要更改文件的执行权限,这个比较隐蔽

    ApplicationContext implements ServletContext

    这句话可以看出Servlet的继承关系。

  • 相关阅读:
    第10组 Beta冲刺 (3/5)
    第10组 Beta冲刺 (2/5)
    第10组 Beta冲刺 (1/5)
    软工实践个人总结
    第03组 每周小结(3/3)
    第03组 每周小结(2/3)
    第03组 每周小结(1/3)
    第03组 Beta冲刺 总结
    第03组 Beta冲刺 (5/5)
    第03组 Beta冲刺 (4/5)
  • 原文地址:https://www.cnblogs.com/Robin008/p/10184060.html
Copyright © 2011-2022 走看看