- 浏览: 204420 次
- 性别:
- 来自: 福建省
文章分类
最新评论
-
c929833623:
...
Mysql JDBC驱动源码分析(Statement,ResultSet的创建)四 -
pythonlord:
顶 很有帮助,感谢楼主,好人一生平安
Mysql JDBC驱动源码分析(加载驱动)一 -
kiaonly:
代码有错误,我戳。
解释器模式(Interpreter)---java与模式(例子) -
wyzxzws:
小鸟学习了!
JAVA编码问题记录 -
xiaotao.2010:
写的不错! 弱弱说一句 建议使用URL二次转码, 这样可以避免 ...
JAVA编码问题记录
一,容器已经启动到部暑文件(webapps),接下去是StandardContext,standardWarpper还有Connector等的启动
我们来了解一下部暑war文件
// Deploy WARs, and loop if additional descriptors are found
//appBase:webapps File appBase.list:所存放的工程 deployWARs(appBase, appBase.list());
/**
* Deploy WAR files. */ protected void deployWARs(File appBase, String[] files) { if (files == null) return; for (int i = 0; i < files.length; i++) { if (files[i].equalsIgnoreCase("META-INF")) continue; if (files[i].equalsIgnoreCase("WEB-INF")) continue; File dir = new File(appBase, files[i]); if (files[i].toLowerCase().endsWith(".war") && dir.isFile()) { // Calculate the context path and make sure it is unique String contextPath = "/" + files[i].replace('#','/'); int period = contextPath.lastIndexOf("."); if (period >= 0) contextPath = contextPath.substring(0, period); if (contextPath.equals("/ROOT")) contextPath = ""; if (isServiced(contextPath)) continue; String file = files[i]; //以上是对每一个工程名以及路径进行解析 //这一步才进行部暑 deployWAR(contextPath, dir, file); } } }
/**
* @param contextPath * @param war * @param file */ protected void deployWAR(String contextPath, File war, String file) { if (deploymentExists(contextPath)) return; // Checking for a nested /META-INF/context.xml JarFile jar = null; JarEntry entry = null; InputStream istream = null; BufferedOutputStream ostream = null; File xml = new File (configBase, file.substring(0, file.lastIndexOf(".")) + ".xml"); if (deployXML && !xml.exists()) { try { jar = new JarFile(war); entry = jar.getJarEntry(Constants.ApplicationContextXml); if (entry != null) { istream = jar.getInputStream(entry); configBase.mkdirs(); ostream = new BufferedOutputStream (new FileOutputStream(xml), 1024); byte buffer[] = new byte[1024]; while (true) { int n = istream.read(buffer); if (n < 0) { break; } ostream.write(buffer, 0, n); } ostream.flush(); ostream.close(); ostream = null; istream.close(); istream = null; entry = null; jar.close(); jar = null; } } catch (Exception e) { // Ignore and continue if (ostream != null) { try { ostream.close(); } catch (Throwable t) { ; } ostream = null; } if (istream != null) { try { istream.close(); } catch (Throwable t) { ; } istream = null; } } finally { entry = null; if (jar != null) { try { jar.close(); } catch (Throwable t) { ; } jar = null; } } } //这个是用来存放已经部暑好的文件 DeployedApplication deployedApp = new DeployedApplication(contextPath); // Deploy the application in this WAR file if(log.isInfoEnabled()) log.info(sm.getString("hostConfig.deployJar", file)); try { Context context = null; if (deployXML && xml.exists()) { synchronized (digester) { try { context = (Context) digester.parse(xml); if (context == null) { log.error(sm.getString("hostConfig.deployDescriptor.error", file)); return; } } finally { digester.reset(); } } context.setConfigFile(xml.getAbsolutePath()); deployedApp.redeployResources.put (xml.getAbsolutePath(), new Long(xml.lastModified())); } else { context = (Context) Class.forName(contextClass).newInstance(); } // Populate redeploy resources with the WAR file deployedApp.redeployResources.put (war.getAbsolutePath(), new Long(war.lastModified())); if (context instanceof Lifecycle) { Class clazz = Class.forName(host.getConfigClass()); LifecycleListener listener = (LifecycleListener) clazz.newInstance(); ((Lifecycle) context).addLifecycleListener(listener); } context.setPath(contextPath); context.setDocBase(file); //以下这一步跟进去,StandardContext的启动 host.addChild(context); // If we're unpacking WARs, the docBase will be mutated after // starting the context if (unpackWARs && (context.getDocBase() != null)) { String name = null; String path = context.getPath(); if (path.equals("")) { name = "ROOT"; } else { if (path.startsWith("/")) { name = path.substring(1); } else { name = path; } } name = name.replace('/', '#'); File docBase = new File(name); if (!docBase.isAbsolute()) { docBase = new File(appBase(), name); } //将部暑完的工程存放进该map中 deployedApp.redeployResources.put(docBase.getAbsolutePath(), new Long(docBase.lastModified())); addWatchedResources(deployedApp, docBase.getAbsolutePath(), context); } else { addWatchedResources(deployedApp, null, context); } } catch (Throwable t) { log.error(sm.getString("hostConfig.deployJar.error", file), t); } deployed.put(contextPath, deployedApp); }
//以下这一步跟进去,StandardContext的启动
host.addChild(context);
private void addChildInternal(Container child) { if( log.isDebugEnabled() ) log.debug("Add child " + child + " " + this); synchronized(children) { if (children.get(child.getName()) != null) throw new IllegalArgumentException("addChild: Child name '" + child.getName() + "' is not unique"); child.setParent(this); // May throw IAE children.put(child.getName(), child); // Start child if (started && startChildren && (child instanceof Lifecycle)) { boolean success = false; try { //StandardContext的启动 ((Lifecycle) child).start(); success = true; } catch (LifecycleException e) { log.error("ContainerBase.addChild: start: ", e); throw new IllegalStateException ("ContainerBase.addChild: start: " + e); } finally { if (!success) { children.remove(child.getName()); } } } fireContainerEvent(ADD_CHILD_EVENT, child); } }
StandardContext#start//由于里面的方法过长,就对里面的个别调用进行详解
public synchronized void start() throws LifecycleException { if( !initialized ) { try { //war文件解压缩成工程就是在这步执行 init(); } catch( Exception ex ) { throw new LifecycleException("Error initializaing ", ex); } } }
以上是对环境部暑启动的简单调试过程,没能全部理解清楚,,会根据后面的调试补全
主要是做了把工程文件存放在DeployedApplication这个类里的 deployedApp.redeployResources.put(docBase.getAbsolutePath(),
new Long(docBase.lastModified()));以备访问调用
发表评论
-
Nginx1.1实现Resin4集群
2011-10-17 17:56 7215一,web服务器小论 以前的公司使用的web服务器是to ... -
Apache实现Tomcat集群
2010-06-08 20:14 1390一,配置介绍 1,linux 2,tomcat6. ... -
Tomcat源码---容器生命周期管理(Lifecycle)一
2010-03-31 11:12 4414一,tomcat中每一个容器 ... -
Tomcat源码---Session的分析一
2010-03-29 11:31 3795一,前面看了大致的tomcat的请求/响应,接下来的文章对to ... -
Tomcat源码---响应处理五
2010-03-25 16:01 1784一,响应工作我们应该从CoyoteAdapter#servic ... -
Tomcat源码---请求处理四(2)
2010-03-25 15:34 1582对以上的StandardWrapperValve#invok ... -
Tomcat源码---请求处理四(1)
2010-03-25 11:08 1617一,现在到了StandardWrapperValve# ... -
Tomcat源码---请求处理三
2010-03-25 10:39 1315一,这一章节主要讲request与response通过管道,阀 ... -
Tomcat源码---请求处理二
2010-03-24 15:04 1797一,经过以上文章(JIoEndpoint$Worker#run ... -
Tomcat源码---请求处理(接收,线程分配)一
2010-03-24 14:34 2787一,在以上文章中tomcat启动已经完毕,接着要做的是消息的请 ... -
Tomcat源码---容器启动六(4)
2010-03-24 11:14 1399现在容器已经启动成功的StanderService#start ... -
Tomcat源码---容器启动六(2)
2010-03-23 16:42 1457super.start()--->org.apach ... -
Tomcat源码---容器启动六(1)
2010-03-22 16:02 1455一,完成了以上的初始化工作,现在进行容器的启动工作由 ... -
Tomcat源码---初始化容器五
2010-03-22 15:03 1775一,上面文章完成了对server.xml载入以及解析,现在主要 ... -
Tomcat源码---载入相应的资源及解析四(2)
2010-03-19 16:47 1468一,根据以上文章所讲的对server.xml的解析作下简单的分 ... -
Tomat源码---载入相应的资源及解析四(1)
2010-03-19 16:22 1366一,进行了以上的类包加载后,现在主要的工作是载入server. ... -
Tomcat源码---启动.初始化(加载类包)分析三
2010-03-19 15:37 2194一,启动 Tomcat是从org.apache.catali ... -
Tomcat的简单了解二
2010-03-19 14:40 1798在查看源代码时,在网上找了一系列的文章,在些作详解: ... -
Tomcat中server.xml的配置分析一
2010-03-19 14:07 1781最近查看了tomcat6的源代码,了解了里面的大概 ...
相关推荐
tomcat 源码分析系列文档 http深入分析,tomcat中类的加载,tomcat的启动,tomcat的容器思想,
3-8Tomcat请求容器中的处理与启动过程源码实现(1).mp4
Tomcat启动流程分析 组件的生命周期管理 用Lifecycle管理启动、停止、关闭 Lifecycle接口预览 几个核心方法 Server中的init方法示例 为啥StandardServer没有init方法 LifecycleBase中的init与...
3-8Tomcat请求容器中的处理与启动过程源码实现(2).mp4
Tomcat源码研究.pdf。Catalina脚本解析,Tomcat启动遇到的常见问题,架构探讨,JMX在tomcat中的应用,容器初探,生命周期
开发人员无需搭建Tomcat的环境就可以使用内嵌式Tomcat进行开发,减少搭建J2EE容器环境的时间和开发时容器频繁启动所花时间,提高开发的效率. 基于内嵌apache-tomcat-8.0.24的应用开发解决了网上提供省了el-ri相关...
tomcat的基础脚本分析 tomcat的源码启动分析 tomcat的web应用启动分析 tomcat的socket分析 tomcat的cocket与容器对接时序分析
容器启动后会自动创建一个具有所有权限的admin用户,并自动生成随机密码。你可以通过查看容器log获得密码,比如 => Creating and admin user with a random password in Tomcat => Done! ==========================...
TomcatTomcat启动脚本,配置文件,源码剖析============ Tomcat 7.0.56 RUNNING.txt-安装并运行Tomcat 7.0 Servlet / JSP容器(2014.10.28-) serverStartup.txt-Tomcat 5启动顺序,serverStartup.pdf-启动过程的UML...
Tomcat的核心类图如下所示:1、Catalina:与开始/关闭shell脚本交互的主类,因此如果要研究启动和关闭的过程,就从这个类开始看起。2、Server:是整个Tomcat组件的容器,包含一个或多个Service。3、
使用idea开发工具调试代码的时候,如果是java的web项目,使用的是tomcat作为web容器,打断点debug调试跟踪,当跟踪到org.apache.catalina包下的时候,则无法进入,这是因为idea运行的tomcat是通过插件的方式集成的,...
java版s源码couchdb-lucene 版本兼容性 CouchDB-Lucene 适用于 0.10 以上的所有版本的 CouchDB。 问题跟踪 问题跟踪在 . 最低系统要求 需要 Java 1.8; 推荐使用 Oracle Java 8 或 OpenJDK 8。 构建并运行 couchdb-...
java开发斗地主源码#About LandManager 是一个让房东轻松记账的小网站(2013 年)。 客户允许共享源代码(无保密协议)。 从项目中删除了有关客户和环境(数据库帐户)的所有数据。 #技术: maven、spring、spring-...
3.修改源码中biyesheji\src\main\resources\jdbc.properties数据库配置文件,修改1-3行,配置为本机数据库地址 4.将项目放入tomcat容器中,并启动项目 5.浏览器访问地址 前台访问路径:...
MyBatis | ORM框架 | [http://www.mybatis.org/mybatis-3/zh/index.html](http://www.mybatis.org/mybatis-3/zh/index.html) MyBatis Generator | 代码生成 | [http://www.mybatis.org/generator/index.html]...
Java 3DMenu 界面源码,有人说用到游戏中不错,其实平时我信编写Java应用程序时候也能用到吧,不一定非要局限于游戏吧,RES、SRC资源都有,都在压缩包内。 Java zip压缩包查看程序源码 1个目标文件 摘要:Java源码...
Java 3DMenu 界面源码,有人说用到游戏中不错,其实平时我信编写Java应用程序时候也能用到吧,不一定非要局限于游戏吧,RES、SRC资源都有,都在压缩包内。 Java zip压缩包查看程序源码 1个目标文件 摘要:Java源码...
它会自动进行数据库初始化、编译、启动tomcat容器.(此命令将会启动tomcat,因此之前tomcat必须处于停止状态) 然后,打开您的浏览器,输入http://localhost:8080/forum 您应该看到我们的示例正常运行. 9, 在您的...
createWebServer()这个方法的源码我就不贴上了,大家可以自己看一下源码,最后就会看到new tomcat();并进行启动tomcat。启动容器后当然是开始进行初始化。 1 private void selfInitialize(ServletContext ...