首页 > 安全资讯 >

知识库--Server + Service

16-12-26

知识库--Server + Service。In previous chapters you have seen how you can have a servlet Container by instantiating a connector and container and then associating them with each other

Server and Service

Overview

In previous chapters you have seen howve a servlet Container by instantiating a connector and container and then associating them with each other. Only one connector could be used, and that was to serve HTTP requests on port 8080. You could not add a you can hanother connector to service HTTPS requests, for example.

In addition, a good mechanism for starting and stopping the servlet container. Here, we’ll look at two other components that offer this mechanism as well as offer many other features: server and service.

Server

The org.apache.catalina.Server interface represents the entire Catallina servlet container and engulfs all other components. A server is particularly useful because it provides an elegant mechanism for starting and stopping the whole system. There is no need to start the connector and the container individually any longer.

Here is how the start and stop mechanism works. When you start a server, it starts all components inside it. It then waits indefinitely(无限等待) for a shutdown command. If you want to shut the system down, you send a shutdown command to designated port. This will reach the server and if it receives the right shutdown command, it will obey by stopping all its components.

A server uses another component, a service, to contain components such as a container and one or more connectors.

    public interface Server{
        public String getInfo();
        //Return the global naming resources
        public NamingResources getGlobalNamingResources();
        public void setGlobalNamingResources(NamingResources globalNamingResources);
        public int getPort();
        public void setPort(int port);
        public String getShutdown();
        public void setShutdown(String shutdown);
        public void addService(Service service);
        public void await();
        public Service findService(String name);
        public Service[] findServices();
        public void removeService(Service service);
        public void initialize()throws LifecycleException;
    }
相关文章
最新文章
热点推荐