文档章节

Container

pczhangtl
 pczhangtl
发布于 2013/11/22 09:53
字数 1802
阅读 43
收藏 0
点赞 0
评论 0
/* 
 * Licensed to the Apache Software Foundation (ASF) under one or more 
 * contributor license agreements.  See the NOTICE file distributed with 
 * this work for additional information regarding copyright ownership. 
 * The ASF licenses this file to You under the Apache License, Version 2.0 
 * (the "License"); you may not use this file except in compliance with 
 * the License.  You may obtain a copy of the License at 
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0 
 * 
 * Unless required by applicable law or agreed to in writing, software 
 * distributed under the License is distributed on an "AS IS" BASIS, 
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
 * See the License for the specific language governing permissions and 
 * limitations under the License. 
 */ 
package org.apache.catalina; 


import java.beans.PropertyChangeListener; 
import java.io.File; 


import javax.management.ObjectName; 


import org.apache.catalina.connector.Request; 
import org.apache.catalina.connector.Response; 
import org.apache.juli.logging.Log; 




/** 
 * A <b>Container</b> is an object that can execute requests received from 
 * a client, and return responses based on those requests.  A Container may 
 * optionally support a pipeline of Valves that process the request in an 
 * order configured at runtime, by implementing the <b>Pipeline</b> interface 
 * as well. 
 * <p> 
 * Containers will exist at several conceptual levels within Catalina.  The 
 * following examples represent common cases: 
 * <ul> 
 * <li><b>Engine</b> - Representation of the entire Catalina servlet engine, 
 *     most likely containing one or more subcontainers that are either Host 
 *     or Context implementations, or other custom groups. 
 * <li><b>Host</b> - Representation of a virtual host containing a number 
 *     of Contexts. 
 * <li><b>Context</b> - Representation of a single ServletContext, which will 
 *     typically contain one or more Wrappers for the supported servlets. 
 * <li><b>Wrapper</b> - Representation of an individual servlet definition 
 *     (which may support multiple servlet instances if the servlet itself 
 *     implements SingleThreadModel). 
 * </ul> 
 * A given deployment of Catalina need not include Containers at all of the 
 * levels described above.  For example, an administration application 
 * embedded within a network device (such as a router) might only contain 
 * a single Context and a few Wrappers, or even a single Wrapper if the 
 * application is relatively small.  Therefore, Container implementations 
 * need to be designed so that they will operate correctly in the absence 
 * of parent Containers in a given deployment. 
 * <p> 
 * A Container may also be associated with a number of support components 
 * that provide functionality which might be shared (by attaching it to a 
 * parent Container) or individually customized.  The following support 
 * components are currently recognized: 
 * <ul> 
 * <li><b>Loader</b> - Class loader to use for integrating new Java classes 
 *     for this Container into the JVM in which Catalina is running. 
 * <li><b>Logger</b> - Implementation of the <code>log()</code> method 
 *     signatures of the <code>ServletContext</code> interface. 
 * <li><b>Manager</b> - Manager for the pool of Sessions associated with 
 *     this Container. 
 * <li><b>Realm</b> - Read-only interface to a security domain, for 
 *     authenticating user identities and their corresponding roles. 
 * <li><b>Resources</b> - JNDI directory context enabling access to static 
 *     resources, enabling custom linkages to existing server components when 
 *     Catalina is embedded in a larger server. 
 * </ul> 
 * 
 * @author Craig R. McClanahan 
 * @author Remy Maucherat 
 * @version $Id: Container.java 1357413 2012-07-04 21:22:03Z markt $ 
 */ 
public interface Container extends Lifecycle { 




    // ----------------------------------------------------- Manifest Constants 




    /** 
     * The ContainerEvent event type sent when a child container is added 
     * by <code>addChild()</code>. 
     */ 
    public static final String ADD_CHILD_EVENT = "addChild"; 




    /** 
     * The ContainerEvent event type sent when a valve is added 
     * by <code>addValve()</code>, if this Container supports pipelines. 
     */ 
    public static final String ADD_VALVE_EVENT = "addValve"; 




    /** 
     * The ContainerEvent event type sent when a child container is removed 
     * by <code>removeChild()</code>. 
     */ 
    public static final String REMOVE_CHILD_EVENT = "removeChild"; 




    /** 
     * The ContainerEvent event type sent when a valve is removed 
     * by <code>removeValve()</code>, if this Container supports pipelines. 
     */ 
    public static final String REMOVE_VALVE_EVENT = "removeValve"; 




    // ------------------------------------------------------------- Properties 


    /** 
     * Return the Logger with which this Container is associated.  If there is 
     * no associated Logger, return the Logger associated with our parent 
     * Container (if any); otherwise return <code>null</code>. 
     */ 
    public Log getLogger(); 




    /** 
     * Return the JMX name associated with this container. 
     */ 
    public ObjectName getObjectName(); 




    /** 
     * Obtain the domain under which this container will be / has been 
     * registered. 
     */ 
    public String getDomain(); 




    /** 
     * Calculate the key properties string to be added to an object's 
     * {@link ObjectName} to indicate that it is associated with this container. 
     * 
     * @return          A string suitable for appending to the ObjectName 
     * 
     */ 
    public String getMBeanKeyProperties(); 




    /** 
     * Return the Pipeline object that manages the Valves associated with 
     * this Container. 
     */ 
    public Pipeline getPipeline(); 




    /** 
     * Return the Cluster with which this Container is associated.  If there is 
     * no associated Cluster, return the Cluster associated with our parent 
     * Container (if any); otherwise return <code>null</code>. 
     */ 
    public Cluster getCluster(); 




    /** 
     * Set the Cluster with which this Container is associated. 
     * 
     * @param cluster the Cluster with which this Container is associated. 
     */ 
    public void setCluster(Cluster cluster); 




    /** 
     * Get the delay between the invocation of the backgroundProcess method on 
     * this container and its children. Child containers will not be invoked 
     * if their delay value is not negative (which would mean they are using 
     * their own thread). Setting this to a positive value will cause 
     * a thread to be spawn. After waiting the specified amount of time, 
     * the thread will invoke the executePeriodic method on this container 
     * and all its children. 
     */ 
    public int getBackgroundProcessorDelay(); 




    /** 
     * Set the delay between the invocation of the execute method on this 
     * container and its children. 
     * 
     * @param delay The delay in seconds between the invocation of 
     *              backgroundProcess methods 
     */ 
    public void setBackgroundProcessorDelay(int delay); 




    /** 
     * Return a name string (suitable for use by humans) that describes this 
     * Container.  Within the set of child containers belonging to a particular 
     * parent, Container names must be unique. 
     */ 
    public String getName(); 




    /** 
     * Set a name string (suitable for use by humans) that describes this 
     * Container.  Within the set of child containers belonging to a particular 
     * parent, Container names must be unique. 
     * 
     * @param name New name of this container 
     * 
     * @exception IllegalStateException if this Container has already been 
     *  added to the children of a parent Container (after which the name 
     *  may not be changed) 
     */ 
    public void setName(String name); 




    /** 
     * Return the Container for which this Container is a child, if there is 
     * one.  If there is no defined parent, return <code>null</code>. 
     */ 
    public Container getParent(); 




    /** 
     * Set the parent Container to which this Container is being added as a 
     * child.  This Container may refuse to become attached to the specified 
     * Container by throwing an exception. 
     * 
     * @param container Container to which this Container is being added 
     *  as a child 
     * 
     * @exception IllegalArgumentException if this Container refuses to become 
     *  attached to the specified Container 
     */ 
    public void setParent(Container container); 




    /** 
     * Return the parent class loader for this component. If not set, return 
     * {@link #getParent()} {@link #getParentClassLoader()}. If no parent has 
     * been set, return the system class loader. 
     */ 
    public ClassLoader getParentClassLoader(); 




    /** 
     * Set the parent class loader for this component. For {@link Context}s 
     * this call is meaningful only <strong>before</strong> a Loader has 
     * been configured, and the specified value (if non-null) should be 
     * passed as an argument to the class loader constructor. 
     * 
     * @param parent The new parent class loader 
     */ 
    public void setParentClassLoader(ClassLoader parent); 




    /** 
     * Return the Realm with which this Container is associated.  If there is 
     * no associated Realm, return the Realm associated with our parent 
     * Container (if any); otherwise return <code>null</code>. 
     */ 
    public Realm getRealm(); 




    /** 
     * Set the Realm with which this Container is associated. 
     * 
     * @param realm The newly associated Realm 
     */ 
    public void setRealm(Realm realm); 




    // --------------------------------------------------------- Public Methods 




    /** 
     * Execute a periodic task, such as reloading, etc. This method will be 
     * invoked inside the classloading context of this container. Unexpected 
     * throwables will be caught and logged. 
     */ 
    public void backgroundProcess(); 




    /** 
     * Add a new child Container to those associated with this Container, 
     * if supported.  Prior to adding this Container to the set of children, 
     * the child's <code>setParent()</code> method must be called, with this 
     * Container as an argument.  This method may thrown an 
     * <code>IllegalArgumentException</code> if this Container chooses not 
     * to be attached to the specified Container, in which case it is not added 
     * 
     * @param child New child Container to be added 
     * 
     * @exception IllegalArgumentException if this exception is thrown by 
     *  the <code>setParent()</code> method of the child Container 
     * @exception IllegalArgumentException if the new child does not have 
     *  a name unique from that of existing children of this Container 
     * @exception IllegalStateException if this Container does not support 
     *  child Containers 
     */ 
    public void addChild(Container child); 




    /** 
     * Add a container event listener to this component. 
     * 
     * @param listener The listener to add 
     */ 
    public void addContainerListener(ContainerListener listener); 




    /** 
     * Add a property change listener to this component. 
     * 
     * @param listener The listener to add 
     */ 
    public void addPropertyChangeListener(PropertyChangeListener listener); 




    /** 
     * Return the child Container, associated with this Container, with 
     * the specified name (if any); otherwise, return <code>null</code> 
     * 
     * @param name Name of the child Container to be retrieved 
     */ 
    public Container findChild(String name); 




    /** 
     * Return the set of children Containers associated with this Container. 
     * If this Container has no children, a zero-length array is returned. 
     */ 
    public Container[] findChildren(); 




    /** 
     * Return the set of container listeners associated with this Container. 
     * If this Container has no registered container listeners, a zero-length 
     * array is returned. 
     */ 
    public ContainerListener[] findContainerListeners(); 




    /** 
     * Remove an existing child Container from association with this parent 
     * Container. 
     * 
     * @param child Existing child Container to be removed 
     */ 
    public void removeChild(Container child); 




    /** 
     * Remove a container event listener from this component. 
     * 
     * @param listener The listener to remove 
     */ 
    public void removeContainerListener(ContainerListener listener); 




    /** 
     * Remove a property change listener from this component. 
     * 
     * @param listener The listener to remove 
     */ 
    public void removePropertyChangeListener(PropertyChangeListener listener); 




    /** 
     * Notify all container event listeners that a particular event has 
     * occurred for this Container.  The default implementation performs 
     * this notification synchronously using the calling thread. 
     * 
     * @param type Event type 
     * @param data Event data 
     */ 
    public void fireContainerEvent(String type, Object data); 




    /** 
     * Log a request/response that was destined for this container but has been 
     * handled earlier in the processing chain so that the request/response 
     * still appears in the correct access logs. 
     * @param request       Request (associated with the response) to log 
     * @param response      Response (associated with the request) to log 
     * @param time          Time taken to process the request/response in 
     *                      milliseconds (use 0 if not known) 
     * @param   useDefault  Flag that indicates that the request/response should 
     *                      be logged in the engine's default access log 
     */ 
    public void logAccess(Request request, Response response, long time, 
            boolean useDefault); 




    /** 
     * Identify the AccessLog to use to log a request/response that was destined 
     * for this container but was handled earlier in the processing chain so 
     * that the request/response still appears in the correct access logs. 
     */ 
    public AccessLog getAccessLog(); 




    /** 
     * Returns the number of threads available for starting and stopping any 
     * children associated with this container. This allows start/stop calls to 
     * children to be processed in parallel. 
     */ 
    public int getStartStopThreads(); 




    /** 
     * Sets the number of threads available for starting and stopping any 
     * children associated with this container. This allows start/stop calls to 
     * children to be processed in parallel. 
     * @param   startStopThreads    The new number of threads to be used 
     */ 
    public void setStartStopThreads(int startStopThreads); 




    /** 
     * 
     */ 
    public File getCatalinaBase(); 
}




© 著作权归作者所有

共有 人打赏支持
pczhangtl
粉丝 46
博文 680
码字总数 113318
作品 0
浦东
高级程序员
【4】Linking Containers Together

//网络端口映射 //-P随机映射到主机的49153~49155端口 $ docker run -d -P training/webapp python app.py //将镜像的5000端口映射到主机的5000端口 $ docker run -d -p 127.0.0.1::5000 t...

Sean-x ⋅ 2016/02/23 ⋅ 0

执行composer update之后

Fatal error: Uncaught ReflectionException: Class log does not exist in /opt/data/api-php-admin/vendor/illuminate/container/Container.php:738 Stack trace: 0 /opt/data/api-php-adm......

1122_guo ⋅ 2016/04/22 ⋅ 0

Docker初步实践遇到的一些问题

为什么删除不了有些Images 当你试图删除一个你不用的image的时候,有时候会告诉你有个container正在使用这个镜像,但是docker ps 并没有发现相关的container,这个是由于对container的exit理...

Finley.Hamilton ⋅ 2014/12/03 ⋅ 0

Using Web App Firewalls and Container Firewalls to Secure App Containers

The shift from monolithic applications to containerized environments and microservices has had two significant effects: it’s made applications much easier to deploy and manage,......

Gary Duan ⋅ 2017/12/13 ⋅ 0

CentOS6.6安装和使用Docker

Docker简介 docker 是一个linux 上的LXC 容器项目,是很轻量级的虚拟化技术。 docker虽然基于lxc技术(cgroup、namespace等),但是思路完全和lxc不一样。 lxc看起来更像是一个虚拟机,多用于...

yuanhuan_2005 ⋅ 2015/03/09 ⋅ 0

SpringXD on yarn 使用Container工作组

SpringXD on yarn 使用Container工作组 OneCoder2016-12-0150 阅读 containeryarn SpringXD on Yarn支持Container分组。可以更好的控制admin和container分配。 控制组内成员 以组单位整体控制...

OneCoder ⋅ 2016/12/01 ⋅ 0

Docker 基础用法和命令帮助

一、Docker的基础用法 Docker镜像首页,包括官方镜像和其它公开镜像 因为国情的原因,国内下载 Docker HUB 官方的相关镜像比较慢,可以使用 docker.cn 镜像,镜像保持和官方一致,关键是速度...

我爱吃葱花 ⋅ 2016/10/25 ⋅ 0

将Django Web应用打包到Docker容器中

source:点击打开链接 Docker is an open-source software container management system. It allows you to create an isolated, self-contained environment to run your application. In t......

spylyt ⋅ 04/13 ⋅ 0

Docker 快速学习(三) docker命令的使用

docker 命令的使用 总结一下常用命令: 其中<>阔起来的参数为必选,[]阔起来为可选 docker version 查看docker的版本号,包括客户端、服务端、依赖的Go等 docker info 查看系统(docker)层面信...

ZhouLS ⋅ 2014/07/18 ⋅ 0

Java线程:生产者消费者模型

public class ProduceConsume { /** @param 生产消费程序 @author wenhaibo */ public static void main(String[] args) { Container container=new Container(); Producer p=new Producer(......

BobWen123 ⋅ 2011/02/24 ⋅ 0

没有更多内容

加载失败,请刷新页面

加载更多

下一页

Sqoop

1.Sqoop: 《=》 SQL to Hadoop 背景 1)场景:数据在RDBMS中,我们如何使用Hive或者Hadoop来进行数据分析呢? 1) RDBMS ==> Hadoop(广义) 2) Hadoop ==> RDBMS 2)原来可以通过MapReduce I...

GordonNemo ⋅ 48分钟前 ⋅ 0

全量构建和增量构建的区别

1.全量构建每次更新时都需要更新整个数据集,增量构建只对需要更新的时间范围进行更新,所以计算量会较小。 2.全量构建查询时不需要合并不同Segment,增量构建查询时需要合并不同Segment的结...

无精疯 ⋅ 58分钟前 ⋅ 0

如何将S/4HANA系统存储的图片文件用Java程序保存到本地

我在S/4HANA的事务码MM02里为Material维护图片文件作为附件: 通过如下简单的ABAP代码即可将图片文件的二进制内容读取出来: REPORT zgos_api.DATA ls_appl_object TYPE gos_s_obj.DA...

JerryWang_SAP ⋅ 今天 ⋅ 0

云计算的选择悖论如何对待?

导读 人们都希望在工作和生活中有所选择。但心理学家的调查研究表明,在多种选项中进行选择并不一定会使人们更快乐,甚至不会产生更好的决策。心理学家Barry Schwartz称之为“选择悖论”。云...

问题终结者 ⋅ 今天 ⋅ 0

637. Average of Levels in Binary Tree - LeetCode

Question 637. Average of Levels in Binary Tree Solution 思路:定义一个map,层数作为key,value保存每层的元素个数和所有元素的和,遍历这个树,把map里面填值,遍历结束后,再遍历这个map,把每...

yysue ⋅ 今天 ⋅ 0

IDEA配置和使用

版本控制 svn IDEA版本控制工具不能使用 VCS-->Enable Version Control Integration File-->Settings-->Plugins 搜索Subversion,勾选SVN和Git插件 删除.idea文件夹重新生成项目 安装SVN客户......

bithup ⋅ 今天 ⋅ 0

PE格式第三讲扩展,VA,RVA,FA的概念

作者:IBinary 出处:http://www.cnblogs.com/iBinary/ 版权所有,欢迎保留原文链接进行转载:) 一丶VA概念 VA (virtual Address) 虚拟地址的意思 ,比如随便打开一个PE,找下它的虚拟地址 这边...

simpower ⋅ 今天 ⋅ 0

180623-SpringBoot之logback配置文件

SpringBoot配置logback 项目的日志配置属于比较常见的case了,之前接触和使用的都是Spring结合xml的方式,引入几个依赖,然后写个 logback.xml 配置文件即可,那么在SpringBoot中可以怎么做?...

小灰灰Blog ⋅ 今天 ⋅ 0

冒泡排序

原理:比较两个相邻的元素,将值大的元素交换至右端。 思路:依次比较相邻的两个数,将小数放在前面,大数放在后面。即在第一趟:首先比较第1个和第2个数,将小数放前,大数放后。然后比较第...

人觉非常君 ⋅ 今天 ⋅ 0

Vagrant setup

安装软件 brew cask install virtualboxbrew cask install vagrant 创建project mkdir -p mst/vmcd mst/vmvagrant init hashicorp/precise64vagrant up hashicorp/precise64是一个box......

遥借东风 ⋅ 今天 ⋅ 0

没有更多内容

加载失败,请刷新页面

加载更多

下一页

返回顶部
顶部