소스 파일 최초 업로드

This commit is contained in:
ByeonJungHun
2024-04-05 10:31:45 +09:00
commit 718e6822af
682 changed files with 90848 additions and 0 deletions

View File

@@ -0,0 +1,35 @@
<!DOCTYPE html SYSTEM "about:legacy-compat">
<html lang="en"><head><META http-equiv="Content-Type" content="text/html; charset=UTF-8"><link href="../images/docs-stylesheet.css" rel="stylesheet" type="text/css"><title>Apache Tomcat 9 Architecture (9.0.74) - Table of Contents</title><meta name="author" content="Yoav Shapira"></head><body><div id="wrapper"><header><div id="header"><div><div><div class="logo noPrint"><a href="https://tomcat.apache.org/"><img alt="Tomcat Home" src="../images/tomcat.png"></a></div><div style="height: 1px;"></div><div class="asfLogo noPrint"><a href="https://www.apache.org/" target="_blank"><img src="../images/asf-logo.svg" alt="The Apache Software Foundation" style="width: 266px; height: 83px;"></a></div><h1>Apache Tomcat 9 Architecture</h1><div class="versionInfo">
Version 9.0.74,
<time datetime="2023-04-13">Apr 13 2023</time></div><div style="height: 1px;"></div><div style="clear: left;"></div></div></div></div></header><div id="middle"><div><div id="mainLeft" class="noprint"><div><nav><div><h2>Links</h2><ul><li><a href="../index.html">Docs Home</a></li><li><a href="index.html">Architecture Home</a></li><li><a href="https://cwiki.apache.org/confluence/display/TOMCAT/FAQ">FAQ</a></li><li><a href="#comments_section">User Comments</a></li></ul></div><div><h2>Contents</h2><ul><li><a href="index.html">Contents</a></li><li><a href="overview.html">Overview</a></li><li><a href="startup.html">Server Startup</a></li><li><a href="requestProcess.html">Request Process</a></li></ul></div></nav></div></div><div id="mainRight"><div id="content"><h2>Table of Contents</h2><h3 id="Preface">Preface</h3><div class="text">
<p>This section of the Tomcat documentation attempts to explain
the architecture and design of the Tomcat server. It includes significant
contributions from several tomcat developers:
</p>
<ul>
<li>Yoav Shapira
(<a href="mailto:yoavs@apache.org">yoavs@apache.org</a>)</li>
<li>Jeanfrancois Arcand
(<a href="mailto:jfarcand@apache.org">jfarcand@apache.org</a>)</li>
<li>Filip Hanik
(<a href="mailto:fhanik@apache.org">fhanik@apache.org</a>)</li>
</ul>
</div><h3 id="Table_of_Contents">Table of Contents</h3><div class="text">
<p>The information presented is divided into the following sections:</p>
<ul>
<li><a href="overview.html"><strong>Overview</strong></a> -
An overview of the Tomcat server architecture with key terms
and concepts.</li>
<li><a href="startup.html"><strong>Server Startup</strong></a> -
A detailed description, with sequence diagrams, of how the Tomcat
server starts up.</li>
<li><a href="requestProcess.html"><strong>Request Process Flow</strong></a> -
A detailed description of how Tomcat handles a request.</li>
</ul>
</div></div></div></div></div><footer><div id="footer">
Copyright &copy; 1999-2023, The Apache Software Foundation
</div></footer></div></body></html>

View File

@@ -0,0 +1,104 @@
<!DOCTYPE html SYSTEM "about:legacy-compat">
<html lang="en"><head><META http-equiv="Content-Type" content="text/html; charset=UTF-8"><link href="../images/docs-stylesheet.css" rel="stylesheet" type="text/css"><title>Apache Tomcat 9 Architecture (9.0.74) - Architecture Overview</title><meta name="author" content="Yoav Shapira"></head><body><div id="wrapper"><header><div id="header"><div><div><div class="logo noPrint"><a href="https://tomcat.apache.org/"><img alt="Tomcat Home" src="../images/tomcat.png"></a></div><div style="height: 1px;"></div><div class="asfLogo noPrint"><a href="https://www.apache.org/" target="_blank"><img src="../images/asf-logo.svg" alt="The Apache Software Foundation" style="width: 266px; height: 83px;"></a></div><h1>Apache Tomcat 9 Architecture</h1><div class="versionInfo">
Version 9.0.74,
<time datetime="2023-04-13">Apr 13 2023</time></div><div style="height: 1px;"></div><div style="clear: left;"></div></div></div></div></header><div id="middle"><div><div id="mainLeft" class="noprint"><div><nav><div><h2>Links</h2><ul><li><a href="../index.html">Docs Home</a></li><li><a href="index.html">Architecture Home</a></li><li><a href="https://cwiki.apache.org/confluence/display/TOMCAT/FAQ">FAQ</a></li><li><a href="#comments_section">User Comments</a></li></ul></div><div><h2>Contents</h2><ul><li><a href="index.html">Contents</a></li><li><a href="overview.html">Overview</a></li><li><a href="startup.html">Server Startup</a></li><li><a href="requestProcess.html">Request Process</a></li></ul></div></nav></div></div><div id="mainRight"><div id="content"><h2>Architecture Overview</h2><h3 id="Overview">Overview</h3><div class="text">
<p>
This page provides an overview of the Tomcat server architecture.
</p>
</div><h3 id="Terms">Terms</h3><div class="text">
<div class="subsection"><h4 id="Server">Server</h4><div class="text">
<p>
In the Tomcat world, a
<a href="../config/server.html">Server</a> represents the whole container.
Tomcat provides a default implementation of the
<a href="../api/org/apache/catalina/Server.html">Server interface</a>
which is rarely customized by users.
</p>
</div></div>
<div class="subsection"><h4 id="Service">Service</h4><div class="text">
<p>
A <a href="../config/service.html">Service</a> is an intermediate component
which lives inside a Server and ties one or more Connectors to exactly one
Engine. The Service element is rarely customized by users, as the default
implementation is simple and sufficient:
<a href="../api/org/apache/catalina/Service.html">Service interface</a>.
</p>
</div></div>
<div class="subsection"><h4 id="Engine">Engine</h4><div class="text">
<p>
An
<a href="../config/engine.html">Engine</a> represents request processing
pipeline for a specific Service. As a Service may have multiple Connectors,
the Engine receives and processes all requests from these connectors, handing
the response back to the appropriate connector for transmission to the client.
The <a href="../api/org/apache/catalina/Engine.html">Engine interface</a>
may be implemented to supply custom Engines, though this is uncommon.
</p>
<p>
Note that the Engine may be used for Tomcat server clustering via the
jvmRoute parameter. Read the Clustering documentation for more information.
</p>
</div></div>
<div class="subsection"><h4 id="Host">Host</h4><div class="text">
<p>
A <a href="../config/host.html">Host</a> is an association of a network name,
e.g. www.yourcompany.com, to the Tomcat server. An Engine may contain
multiple hosts, and the Host element also supports network aliases such as
yourcompany.com and abc.yourcompany.com. Users rarely create custom
<a href="../api/org/apache/catalina/Host.html">Hosts</a>
because the
<a href="../api/org/apache/catalina/core/StandardHost.html">StandardHost
implementation</a> provides significant additional functionality.
</p>
</div></div>
<div class="subsection"><h4 id="Connector">Connector</h4><div class="text">
<p>
A Connector handles communications with the client. There are multiple
connectors available with Tomcat. These include the
<a href="../config/http.html">HTTP connector</a> which is used for
most HTTP traffic, especially when running Tomcat as a standalone server,
and the <a href="../config/ajp.html">AJP connector</a> which implements
the AJP protocol used when connecting Tomcat to a web server such as
Apache HTTPD server. Creating a customized connector is a significant
effort.
</p>
</div></div>
<div class="subsection"><h4 id="Context">Context</h4><div class="text">
<p>
A
<a href="../config/context.html">Context</a>
represents a web application. A Host may contain multiple
contexts, each with a unique path. The
<a href="../api/org/apache/catalina/Context.html">Context
interface</a> may be implemented to create custom Contexts, but
this is rarely the case because the
<a href="../api/org/apache/catalina/core/StandardContext.html">
StandardContext</a> provides significant additional functionality.
</p>
</div></div>
</div><h3 id="Comments">Comments</h3><div class="text">
<p>
Tomcat is designed to be a fast and efficient implementation of the
Servlet Specification. Tomcat came about as the reference implementation
of this specification, and has remained rigorous in adhering to the
specification. At the same time, significant attention has been paid
to Tomcat's performance and it is now on par with other servlet containers,
including commercial ones.
</p>
<p>
In recent releases of Tomcat, mostly starting with Tomcat 5,
we have begun efforts to make more aspects of Tomcat manageable via
JMX. In addition, the Manager and Admin webapps have been greatly
enhanced and improved. Manageability is a primary area of concern
for us as the product matures and the specification becomes more
stable.
</p>
</div></div></div></div></div><footer><div id="footer">
Copyright &copy; 1999-2023, The Apache Software Foundation
</div></footer></div></body></html>

View File

@@ -0,0 +1,43 @@
<!DOCTYPE html SYSTEM "about:legacy-compat">
<html lang="en"><head><META http-equiv="Content-Type" content="text/html; charset=UTF-8"><link href="../images/docs-stylesheet.css" rel="stylesheet" type="text/css"><title>Apache Tomcat 9 Architecture (9.0.74) - Request Process Flow</title><meta name="author" content="Yoav Shapira"></head><body><div id="wrapper"><header><div id="header"><div><div><div class="logo noPrint"><a href="https://tomcat.apache.org/"><img alt="Tomcat Home" src="../images/tomcat.png"></a></div><div style="height: 1px;"></div><div class="asfLogo noPrint"><a href="https://www.apache.org/" target="_blank"><img src="../images/asf-logo.svg" alt="The Apache Software Foundation" style="width: 266px; height: 83px;"></a></div><h1>Apache Tomcat 9 Architecture</h1><div class="versionInfo">
Version 9.0.74,
<time datetime="2023-04-13">Apr 13 2023</time></div><div style="height: 1px;"></div><div style="clear: left;"></div></div></div></div></header><div id="middle"><div><div id="mainLeft" class="noprint"><div><nav><div><h2>Links</h2><ul><li><a href="../index.html">Docs Home</a></li><li><a href="index.html">Architecture Home</a></li><li><a href="https://cwiki.apache.org/confluence/display/TOMCAT/FAQ">FAQ</a></li><li><a href="#comments_section">User Comments</a></li></ul></div><div><h2>Contents</h2><ul><li><a href="index.html">Contents</a></li><li><a href="overview.html">Overview</a></li><li><a href="startup.html">Server Startup</a></li><li><a href="requestProcess.html">Request Process</a></li></ul></div></nav></div></div><div id="mainRight"><div id="content"><h2>Request Process Flow</h2><h3 id="Request_Process_Flow">Request Process Flow</h3><div class="text">
<p>
This page describes the process used by Tomcat to handle
an incoming request. This process is largely defined by
the Servlet Specification, which outlines the order
of events that must take place.
</p>
<div class="subsection"><h4 id="description">description</h4><div class="text">
<p>
TODO
</p>
</div></div>
<div class="subsection"><h4 id="diagrams">diagrams</h4><div class="text">
<p>
A UML sequence diagram of the request process is available
<a href="requestProcess/request-process.png">here.</a>
</p>
<p>
A UML sequence diagram of the authentication process is available
<a href="requestProcess/authentication-process.png">here.</a>
</p>
</div></div>
<div class="subsection"><h4 id="comments">comments</h4><div class="text">
<p>
The Servlet Specification provides many opportunities for
listening in (using Listeners) or modifying (using Filters)
the request handling process even before the request arrives
at the servlet that will handle it.
</p>
</div></div>
</div></div></div></div></div><footer><div id="footer">
Copyright &copy; 1999-2023, The Apache Software Foundation
</div></footer></div></body></html>

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 107 KiB

View File

@@ -0,0 +1,42 @@
<!DOCTYPE html SYSTEM "about:legacy-compat">
<html lang="en"><head><META http-equiv="Content-Type" content="text/html; charset=UTF-8"><link href="../images/docs-stylesheet.css" rel="stylesheet" type="text/css"><title>Apache Tomcat 9 Architecture (9.0.74) - Startup</title><meta name="author" content="Yoav Shapira"></head><body><div id="wrapper"><header><div id="header"><div><div><div class="logo noPrint"><a href="https://tomcat.apache.org/"><img alt="Tomcat Home" src="../images/tomcat.png"></a></div><div style="height: 1px;"></div><div class="asfLogo noPrint"><a href="https://www.apache.org/" target="_blank"><img src="../images/asf-logo.svg" alt="The Apache Software Foundation" style="width: 266px; height: 83px;"></a></div><h1>Apache Tomcat 9 Architecture</h1><div class="versionInfo">
Version 9.0.74,
<time datetime="2023-04-13">Apr 13 2023</time></div><div style="height: 1px;"></div><div style="clear: left;"></div></div></div></div></header><div id="middle"><div><div id="mainLeft" class="noprint"><div><nav><div><h2>Links</h2><ul><li><a href="../index.html">Docs Home</a></li><li><a href="index.html">Architecture Home</a></li><li><a href="https://cwiki.apache.org/confluence/display/TOMCAT/FAQ">FAQ</a></li><li><a href="#comments_section">User Comments</a></li></ul></div><div><h2>Contents</h2><ul><li><a href="index.html">Contents</a></li><li><a href="overview.html">Overview</a></li><li><a href="startup.html">Server Startup</a></li><li><a href="requestProcess.html">Request Process</a></li></ul></div></nav></div></div><div id="mainRight"><div id="content"><h2>Startup</h2><h3 id="Server_Startup">Server Startup</h3><div class="text">
<p>
This page describes how the Tomcat server starts up. There are several
different ways to start tomcat, including:
</p>
<ul>
<li>From the command line.</li>
<li>From a Java program as an embedded server.</li>
<li>Automatically as a Windows service.</li>
</ul>
<div class="subsection"><h4 id="description">description</h4><div class="text">
<p>
A text description of the startup procedure is available
<a href="startup/serverStartup.txt">here.</a>
</p>
</div></div>
<div class="subsection"><h4 id="diagram">diagram</h4><div class="text">
<p>
A UML sequence diagram of the startup procedure is available
<a href="startup/serverStartup.pdf">here.</a>
</p>
</div></div>
<div class="subsection"><h4 id="comments">comments</h4><div class="text">
<p>
The startup process can be customized in many ways, both
by modifying Tomcat code and by implementing your own
LifecycleListeners which are then registered in the server.xml
configuration file.
</p>
</div></div>
</div></div></div></div></div><footer><div id="footer">
Copyright &copy; 1999-2023, The Apache Software Foundation
</div></footer></div></body></html>

View File

@@ -0,0 +1,139 @@
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Tomcat Startup Sequence
Sequence 1. Start from Command Line
Class: org.apache.catalina.startup.Bootstrap
What it does:
a) Set up classloaders
commonLoader (common)-> System Loader
sharedLoader (shared)-> commonLoader -> System Loader
catalinaLoader(server) -> commonLoader -> System Loader
(by default the commonLoader is used for the
sharedLoader and the serverLoader)
b) Load startup class (reflection)
org.apache.catalina.startup.Catalina
setParentClassloader -> sharedLoader
Thread.contextClassloader -> catalinaLoader
c) Bootstrap.daemon.init() complete
Sequence 2. Process command line argument (start, stop)
Class: org.apache.catalina.startup.Bootstrap (assume command->start)
What it does:
a) Catalina.setAwait(true);
b) Catalina.load()
b1) initDirs() -> set properties like
catalina.home
catalina.base == catalina.home (most cases)
b2) initNaming
setProperty(javax.naming.Context.INITIAL_CONTEXT_FACTORY,
org.apache.naming.java.javaURLContextFactory ->default)
b3) createStartDigester()
Configures a digester for the main server.xml elements like
org.apache.catalina.core.StandardServer (can change of course :)
org.apache.catalina.deploy.NamingResources
Stores naming resources in the J2EE JNDI tree
org.apache.catalina.LifecycleListener
implements events for start/stop of major components
org.apache.catalina.core.StandardService
The single entry for a set of connectors,
so that a container can listen to multiple connectors
ie, single entry
org.apache.catalina.Connector
Connectors to listen for incoming requests only
It also adds the following rulesets to the digester
NamingRuleSet
EngineRuleSet
HostRuleSet
ContextRuleSet
b4) Load the server.xml and parse it using the digester
Parsing the server.xml using the digester is an automatic
XML-object mapping tool, that will create the objects defined in server.xml
Startup of the actual container has not started yet.
b5) Assigns System.out and System.err to the SystemLogHandler class
b6) Calls initialize on all components, this makes each object register itself with the
JMX agent.
During the process call the Connectors also initialize the adapters.
The adapters are the components that do the request pre-processing.
Typical adapters are HTTP1.1 (default if no protocol is specified,
org.apache.coyote.http11.Http11NioProtocol)
AJP1.3 for mod_jk etc.
c) Catalina.start()
c1) Starts the NamingContext and binds all JNDI references into it
c2) Starts the services under <Server> which are:
StandardService -> starts Engine (ContainerBase -> Realm,Cluster etc)
c3) StandardHost (started by the service)
Configures an ErrorReportValve to do proper HTML output for different HTTP
errors codes
Starts the Valves in the pipeline (at least the ErrorReportValve)
Configures the StandardHostValve,
this valves ties the Webapp Class loader to the thread context
it also finds the session for the request
and invokes the context pipeline
Starts the HostConfig component
This component deploys all the webapps
(webapps & conf/Catalina/localhost/*.xml)
HostConfig will create a Digester for your context, this digester
will then invoke ContextConfig.start()
The ContextConfig.start() will process the default web.xml (conf/web.xml)
and then process the applications web.xml (WEB-INF/web.xml)
c4) During the lifetime of the container (StandardEngine) there is a background thread that
keeps checking if the context has changed. If a context changes (timestamp of war file,
context xml file, web.xml) then a reload is issued (stop/remove/deploy/start)
d) Tomcat receives a request on an HTTP port
d1) The request is received by a separate thread which is waiting in the ThreadPoolExecutor
class. It is waiting for a request in a regular ServerSocket.accept() method.
When a request is received, this thread wakes up.
d2) The ThreadPoolExecutor assigns the a TaskThread to handle the request.
It also supplies a JMX object name to the catalina container (not used I believe)
d3) The processor to handle the request in this case is Coyote Http11Processor,
and the process method is invoked.
This same processor is also continuing to check the input stream of the socket
until the keep alive point is reached or the connection is disconnected.
d4) The HTTP request is parsed using an internal buffer class (Http11InputBuffer)
The buffer class parses the request line, the headers, etc and store the result in a
Coyote request (not an HTTP request) This request contains all the HTTP info, such
as servername, port, scheme, etc.
d5) The processor contains a reference to an Adapter, in this case it is the
CoyoteAdapter. Once the request has been parsed, the Http11Processor
invokes service() on the adapter. In the service method, the Request contains a
CoyoteRequest and CoyoteResponse (null for the first time)
The CoyoteRequest(Response) implements HttpRequest(Response) and HttpServletRequest(Response)
The adapter parses and associates everything with the request, cookies, the context through a
Mapper, etc
d6) When the parsing is finished, the CoyoteAdapter invokes its container (StandardEngine)
and invokes the invoke(request,response) method.
This initiates the HTTP request into the Catalina container starting at the engine level
d7) The StandardEngine.invoke() simply invokes the container pipeline.invoke()
d8) By default the engine only has one valve the StandardEngineValve, this valve simply
invokes the invoke() method on the Host pipeline (StandardHost.getPipeLine())
d9) the StandardHost has two valves by default, the StandardHostValve and the ErrorReportValve
d10) The standard host valve associates the correct class loader with the current thread
It also retrieves the Manager and the session associated with the request (if there is one)
If there is a session access() is called to keep the session alive
d11) After that the StandardHostValve invokes the pipeline on the context associated
with the request.
d12) The first valve that gets invoked by the Context pipeline is the FormAuthenticator
valve. Then the StandardContextValve gets invoke.
The StandardContextValve invokes any context listeners associated with the context.
Next it invokes the pipeline on the Wrapper component (StandardWrapperValve)
d13) During the invocation of the StandardWrapperValve, the JSP wrapper (Jasper) gets invoked
This results in the actual compilation of the JSP.
And then invokes the actual servlet.
e) Invocation of the servlet class