In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
What this article shares to you is about the default value of each component of the Tomcat application, the editor thinks it is very practical, so I share it with you to learn. I hope you can get something after reading this article.
Today, let's find out the default values of each component together.
Default value of the component
Server- > StandardServer
Service- > StandardService
Executor- > StandardThreadExecutor (thread pool implementation in tomcat, shared by all Service)
Connector- > new Connector (attributes.getValue ("protocol"))
In EngineRuleSet, we can see a series of initializations related to Engine
Engine- > StandardEngine
EngineConfigClass- > org.apache.catalina.startup.EngineConfig
Will be converted into LifecycleListener.
Host- > StandardHost
HostConfigClass- > org.apache.catalina.startup.HostConfig
Context- > StandardContext
ConfigClass- > org.apache.catalina.startup.ContextConfig
From the source code, we can see that Context is closely related to our web application. Such as session, cookie,Parameter
The most important point is:
The loader set in Context is a WebappLoader. A new WebappLoader is created for each Context, so web applications in tomcat are separate class loaders.
Digester.addObjectCreate (prefix + "Context/Loader", "org.apache.catalina.loader.WebappLoader", "className"); digester.addSetProperties (prefix + "Context/Loader") Digester.addSetNext (prefix + "Context/Loader", "setLoader", "org.apache.catalina.Loader")
After the Context is loaded, the class loader for Engine is set
Digester.addRule ("Server/Service/Engine", new SetParentClassLoaderRule (parentClassLoader)); addClusterRuleSet (digester, "Server/Service/Engine/Cluster/")
SetParentClassLoaderRule:
The element at the top of the current stack of digester is fetched and a class loader is set for the element at the top of the stack
Container top = (Container) digester.peek (); top.setParentClassLoader (parentClassLoader)
The parentClassLoader is shown in the following code, which is SharedClassLoader
/ * The shared extensions class loader for this server. * / protected ClassLoader parentClassLoader = Catalina.class.getClassLoader (); classloader in tomcat
In the above analysis, we see the initialization of class loaders. In fact, in tomcat, there are four kinds of loaders, namely Common Class Loader, Catalina Class Loader, Shared Class Loader, Web App Class Loader.
They can load classes from different locations to achieve the effect of isolation, but also can achieve a general effect.
Explain it in detail. We will introduce it in detail in the next article.
Finally, a few words.
Most components in Tomcat can be thought of as Container, as shown in the following figure
They all have a complete life cycle at the same time:
So they have similar behavior, because when reading the source code, there is a feeling that they are all doing the same thing, and it is true, they just have different rewriting of the same behavior.
These are the default values for each component of the Tomcat application. The editor believes that there are some knowledge points that we may see or use in our daily work. I hope you can learn more from this article. For more details, please follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.