spring-tomcat架构分析
2023-11-14 14:33:55 1 举报
spring嵌入式tomcat的基础架构图,同时介绍了spring是如何引入Tomcat Server的过程
作者其他创作
大纲/内容
Embedded tomcat启动器,所有基础组件集成在此
Embedded tomcat的基础组组件实现类
继承
<<接口>>Wrapper
<<接口>>JmxEnabled
+getDomain+setDomain+getObjectName
<<接口>>WebServer
+start():void+stop():void+getPort():int
<<接口>>ServletContainerInitializer
Embedded tomcat的基础组组件接口
工厂方法
LifecycleMBeanBase
略
继承了LifecycleBase基类的基础上,实现了JmxEnable和MBeanRegistration接口的JMX功能
双向关联
StandardService
- server:Server = null- connectors:Connector[] =new Connector[0]- engine: Engine = null- executors: Array<Executor> = new ArrayList<>();
+ setServer(Server):void+ setContainer(Engine):void+ addConnector(Connector):void+ addExecutor(Executor):void+get...
LifecycleBase
- sm:StringManager = StringManager.getManager(...)- lifecycleListener:List<LifecycleListener>= new CopyOnWriteList<>()- state: LifecycleState = LifecycleState.NEW
+init():void+start():void+stop():void+destroy():void+addLifecycleListener(LifecycleListener)+getState:LifeState
TomcatServletWebServerFactory
JDK的JMX接口
<<接口>>Engine
+ setService(Service):void+ setDefaultHost(String): void+setJvmRoute(String): void+get...以及继承自Container的方法,尤其是addChild方法
<<接口>>Container
+ addChild(Container):voidfont color=\"#323232\
<<接口>>MBeanRegistration
+preRegister+postRegister+preDeregister+postDeregister
<<接口>>ServletContextInitializer
+ onStartup(servletContext):void
来自spring-boot-2.1.0.Release-sources兼容层的类,其他都是Embedded Tomcat和JDK包的类
StandardContext
- context:ApplicationContext = null- applicationListeners: String[] = new String[0];- resources:WebResourceRoot- useHttpOnly: boolean =true-cookieProcessor:CookieProcessor-requestEncoding: String = null-responseEncoding: String = null...以及继承自ContainerBase的属性
实现了Context接口的方法以及继承自ContainerBase的方法
TomcatEmbeddedContext
- starter:TomcatStarter 以及从StandardContext和ContainerBase、LifecycleMBeanBase继承的属性
<<接口>>Lifecycle
<<接口>>Service
+ setServer(Server):void+ setContainer(Engine):void+ addConnector(Connector):void+ addExecutor(Executor):void+getContainer():Engine......
TomcatWebServer
- tomcat: Tomcat
+ TomcatWebServer(Tomcat)+ start():void+ stop():void+ getPort():int
ContainerBase
+ addChild(Container):void+setParent(Container):void+addContainerListener(ContainerListener):voidfont color=\"#323232\
<<接口>>Server
+ setPort(int): void+ setAddress(String): void+addService(Service): void+setCatalina(Catalina):void
TomatStarter
+intializers:ServletContextInitializer[]
<<接口>>ServletWebServerFactory
+getWebServer(servletContextInitializers):WebServer
Tomcat
- server:Server - port: int=8080- hostname: String=\"localhost\" - basedir: String
+setBaseDir(String): void+ getService(): void+setConnector():void+getEngine():void+ getHost():Host+ start(): void+ stop(): void+ destroy: void-initBaseDir(): void
<<接口>>Context
+setApplicationEventListeners( Object[]):void+setApplicationLifecycleListeners( Object[]):void+setConfigFile(URL): void+setSessionCookieName(String): void+setSessionCookiePath(String):void+setUseHttpOnly(boolean):void+set...+get...
StandardEngine
+ defaultHost: String = null+ service:Service = null+ jvmRouted:String以及继承自ContainerBase的属性
+ setService(Service):void+ setDefaultHost(String): void+setJvmRoute(String): void+get...以及继承自ContainerBase的API
StandardServer
- port: int = 8005- address: String=\"localhost\"- services:Service[] = new Service[0]- catalina: Catalina = null
contains
StandardHost
+ appBase: String = \"webApps\"+ appBaseFile:File = null+ autoDeploy: boolean = true+ configClass: String = \"org.apache.catalina.startup. ContextConfig\"+contextClass:String = \"org.apache.catalina.core. StardardContext\"...以及其他继承自ContainerBase的属性
+ setAutoDeploy(boolean):void+setAppBase(String):void+setConfigClass(String):void......+get...以及其他继承自ContainerBase的方法
Connector
- service : Service = null- port : int=-1- secure: boolean = false- protocolHandler:ProtocolHandler其他继承的属性
+ setService(Service):void+ setPort(int):void+ setSecure(boolean):void+ get...其他继承的方法
<<接口>>Host
+ setAutoDeploy(boolean):void+setAppBase(String):void+setConfigClass(String):void......+get...
StandardWrapper
实现
0 条评论
回复 删除
下一页