知识库--StandardService+Container+Connectors(64)
来源:互联网 发布:淘宝拍卖的玉是真的吗 编辑:程序博客网 时间:2024/04/29 10:35
Container and Connectors
A StandardService instance contains two types of components: a container and one or more connectors. Being able to have multiple connectors enable Tomcat to service multiple protocols. One connector can be used to service HTTP requests, and another for servicing HTTPS requests.
The StandardService class uses the container variable as an object reference for the Container instance and the connectors array for all the connectors.
private Container container = null;private Connector connector[] = new Connector[0];
To associate a container with this service, you use the setContainer method, which is given following:
public void setContainer(Container container){ Container oldContainer = this.container; if((oldContainer != null) &&(oldContainer instanceof Engine))//消除原关联 ((Engine)oldContainer).setService(null); this.container = container; if((this.container != null) && (this.container instanceof Engine))//建立新的关联关系 ((Engine)this.container).setService(this); if(started && (this.container != null) && (this.container instanceof Lifecyle)){//start() try{ ((Lifecycle)this.container).start(); }catch(LifecycleException e){ ; } } synchronized(connectors){//建立连接 for(int i = 0; i < connectors.length; i++){ connectors[i].setContainer(this.container); } } if(started && (oldContainer != nul) && (oldContainer instanceof Lifecycle)){//关闭历史容器 try{ ((Lifecycle)oldContainer).stop(); }catch(LifecycleException e){ ; } } //report this property change to interested listeners support.firePropertyChange("container",oldContainer,this.container);//通知事件}
The container associated with this service will be passed to the setContainer method on each Connector object that is available(数组元素–引用) in this service to create the association between the container and each individual connector.
To add a connector to a Service object, use the addConnector method. To remove a connector, call the removeConnector method.
public void addConnector(Connector connector){ synchronized(connectors){ connector.setContainer(this.container); connector.setService(this); Connector results[] = new Connector[connectors.length + 1]; System.arraycopy(connectoes,0,results,0,connector.length); results[connector.length] = connector; connectors = results; //初始化 if(initialized){ try{ connector.initialize(); }catch(LifecycleException e){ e.printStackTrace(System.err); } } if(started && (connector instanceof Lifecyle)){ try{ ((Lifecycle)connector).start(); }catch(LifecycleException e){;} } //Report this property change to interested listeners 原对象--改变后的对象 support.firePropertyChange("connector",null,connector); } }
//remove connector
public void removeConnector(Connector connector){ synchronized(connectors){ int j = -1; for(int i = 0; i < connectors.length;i++){ if(connector == connectors[i]){ j = i; break; } } if(j < 0) return; if(started && (connectors[j] instanceof Lifecycle)){ try{ ((Lifecycle)connectors[j]).stop(); }catch(LifecycleException e){ ; } } connectors[j].setContainer(null); connector.setService(null); int k = 0; Connector result[] = new Connector[connectors.length - 1]; for(int i = 0; i< connectors.length; i++){ if(i!=j) results[k++] = connectors[i]; } connectors = results; //report this property change to interested listeners support.firePropertyChange("connector",connector,null); }}
Have your attention :
addConnector method initializes and starts the added connector.
- 知识库--StandardService+Container+Connectors(64)
- 知识库--tomcat+StandardService
- 知识库--StandardService + Lifecycle(start/stop)+initialize(72)
- 知识库--The Simple Container Application
- Connectors
- ActiveMQ学习-Network connectors(1)
- ActiveMQ学习-Network connectors(1)
- 知识库--Lifecycle (44)
- 知识库--SimpleLoader (46)
- 知识库--Logger (46)
- 知识库--WebappLoader(47)
- 知识库--WebappClassLoader(47)
- 知识库--Session(47)
- 知识库--Sessions(48)
- 知识库--StandardSession (49)
- 知识库--PersistentManagerBase(50)
- 知识库--Realm(51)
- 知识库--Authenticator(51)
- C#怎么实现文件下载功能
- 从大学接触计算机到学习java编程,再到公司实习的小小过程
- linux grep命令详解
- Spring-tx-3.1.4.jar包目录结构
- View的测量onMeasure方法
- 知识库--StandardService+Container+Connectors(64)
- 为虚拟机linux扩充硬盘容量
- 微信小程序中使用的rpx单位换算
- 1002写出这个数
- 9.事件 弱事件
- mac PHP Storm 破解方法
- Linux学习–(DNS服务搭建)
- 项目二 选手评分系统1
- 1092. To Buy or Not to Buy (20)解题报告