Tomcat源码解读--代码走读之(四十二的2-3-2-5)registerHost(host)(四十四)

  其中MapperListener mapperListener = new MapperListener(mapper, this) Mapper mapper = new Mapper()this=connector,代码在connector中。



 

1、mapper.addHost(host.getName(), aliases, host)



 

1)、insertMap(hosts, newHosts, newHost),如下。



 

    1)、在oldMap中找新元素的name

    2)、进行数组赋值。

    3)、新数组中增加元素。

2、registerContext((Context) container),从host中找出有效的context进行注册context,代码如下。



 

1)、   mapper.addContextVersion(host.getName(), host, contextPath,context.getWebappVersion(), context, welcomeFiles, resources);代码在mapper中。

1)、HostmappedHost = hosts[pos],取出host

2)、mappedHost.contextList.contexts= newContexts,增加context

3)、ContextmappedContext = mappedHost.contextList.contexts[pos2]newContextVersion的属性设置,mappedContext.versions = newContextVersions

2)、registerWrapper((Wrapper) container),也就是servlet



 

    1)、mapper.addWrapper(hostName, contextPath, version,mapping, wrapper,jspWildCard,context.isResourceOnlyServlet(wrapperName))



 

      1))、进行校验,hostcontextversion.

      2))、addWrapper(contextVersion,path, wrapper, jspWildCard,

                            resourceOnly),代码如下。



 

            1)))、根据path(也就是mapping)进行分类,在context中增加。分为4WildcardwrapperExtensionwrapperDefaultwrapperExactwrapper

 

猜你喜欢

转载自83519144.iteye.com/blog/1887014