tomcat一点

1.TOMCAT的启动过程主要分为初始化init 和启动二步start.
2.容器主要为二大块,连接器connector与容器Container'
  connector负责接受来的请求,并且创建请求与响应对象,然后交给Container去处理
3.tomcat定义了好多的组件,如下:
  server service connector  Container等组件,
  组件对应关系:
  一个server可以对应多个service组件,如源码中:
public void addService(Service service) {

        service.setServer(this);

        synchronized (services) {
            Service results[] = new Service[services.length + 1];
            System.arraycopy(services, 0, results, 0, services.length);
            results[services.length] = service;
            services = results;

            if (initialized) {
                try {
                    service.initialize();
                } catch (LifecycleException e) {
                    log.error(e);
                }
            }

            if (started && (service instanceof Lifecycle)) {
                try {
                    ((Lifecycle) service).start();
                } catch (LifecycleException e) {
                    ;
                }
            }

            // Report this property change to interested listeners
            support.firePropertyChange("service", null, service);
        }

    }
    一个Service组件对应多个连接器:
     public void addConnector(Connector connector) {

        synchronized (connectors) {
            connector.setContainer(this.container);
            connector.setService(this);
            Connector results[] = new Connector[connectors.length + 1];
            System.arraycopy(connectors, 0, results, 0, connectors.length);
            results[connectors.length] = connector;
            connectors = results;

            if (initialized) {
                try {
                    connector.initialize();
                } catch (LifecycleException e) {
                    log.error("Connector.initialize", e);
                }
            }

            if (started && (connector instanceof Lifecycle)) {
                try {
                    ((Lifecycle) connector).start();
                } catch (LifecycleException e) {
                    log.error("Connector.start", e);
                }
            }

            // Report this property change to interested listeners
            support.firePropertyChange("connector", null, connector);
        }

    }
    Container里饮食几个组件 Engine,Host,Context,Wrapper
           Host对应的是一个Server,可以供多个应用服务,而Context

你可能感兴趣的:(tomcat)