Tomcat8.x 上下文(StandardServer)中命名上下文(NamingContext)的创建
2016-08-06 18:47
330 查看
(StandardServer)中命名上下文(NamingContext)的创建
// 命名上下文的创建---------1 class org.apache.catalina.core.StandardServer{ // 构造函数 public StandardServer() { // “命名资源” globalNamingResources = new NamingResourcesImpl(); globalNamingResources.setContainer(this); // 创建“命名上下文”监听器 namingContextListener = new NamingContextListener(); addLifecycleListener(namingContextListener); } protected void startInternal() throws LifecycleException { // 触发监听器 // org.apache.catalina.core.NamingContextListener.lifecycleEvent(...) fireLifecycleEvent(CONFIGURE_START_EVENT, null); // "configure_start" 事件 // org.apache.catalina.deploy.NamingResourcesImpl globalNamingResources.start(); } } // "命名资源" class org.apache.catalina.deploy.NamingResourcesImpl{ protected void startInternal() throws LifecycleException { fireLifecycleEvent(CONFIGURE_START_EVENT, null); setState(LifecycleState.STARTING); } } // "命名上下文"监听器 class org.apache.catalina.core.NamingContextListener{ // 事件处理器,创建"命名上下文" public void lifecycleEvent(LifecycleEvent event) { container = event.getLifecycle(); namingResources = ((Server) container).getGlobalNamingResources(); if (Lifecycle.CONFIGURE_START_EVENT.equals(event.getType())) { Hashtable<String, Object> contextEnv = new Hashtable<>(); namingContext = new NamingContext(contextEnv, getName()); // 创建"命名上下文"文---------- ContextAccessController.setSecurityToken(getName(), token); ContextAccessController.setSecurityToken(container, token); ContextBindings.bindContext(container, namingContext, token); createNamingContext(); // 创建“名称上下文” } } // 创建"命名上下文" private void createNamingContext() throws NamingException { // container === org.apache.catalina.core.StandardServer if (container instanceof Server) { // 走这里 compCtx = namingContext; // org.apache.naming.NamingContext envCtx = namingContext; } else { compCtx = namingContext.createSubcontext("comp"); envCtx = compCtx.createSubcontext("env"); } // Resources ContextResource[] resources = namingResources.findResources(); for (i = 0; i < resources.length; i++) { addResource(resources[i]); } } }
相关文章推荐
- Tomcat8.x 上下文(StandardContext)中(名称上下文(NamingContext)的创建->名称上下文(NamingContext))的使用
- 创建.net web项目出错HTTP/1.1 500 Internal Server Error
- MS SQLSERVER 中如何得到表的创建语句
- 创建ASP.NET程序时候发生错误"HTTP/1.0 500 Server Error"的一个解决办法
- 尝试通过使用 TCP/IP 套接字连接到群集中的 SQL Server 命名实例时收到“SQL Server does not exist or access denied”(SQL Server 不存在,或者访问被拒绝)错误消息
- [视频]用SQL Server Compact创建简单的Windows应用程序
- 找不到类型或命名空间名称“Server”(是否缺少 using 指令或程序集引用?)
- 创建文件夹,用系统日期命名。
- 用ASP.NET(VB版)创建WINDOWS 2000 SERVER站点
- 如何用创建命名对象来判断应用程序是否已有一个实例在运行?
- 用ASP.NET(VB版)创建WINDOWS 2000 SERVER站点
- 尝试创建web项目或打开URL (Http/1.0 500 Server Error)
- [MySQL-server-standard-5.0.19-0.rhel4.x86_64.rpm]安装的一个问题的解决办法
- 在Office SharePoint Server 2007上创建自己的WebPart!
- 无法在 RIS 服务器上创建 Windows 2000 Server 映像
- 用命名的参数创建简单语句
- 用ASP.NET(VB版)创建WINDOWS 2000 SERVER站点
- 创建Windows 2000 Active Directory Server
- 创建强命名程序集简单步骤
- Server.MapPath的命名空间