tomcat 嵌入式启动原理
******************
tomcat 嵌入式启动原理
tomcat标准启动方式:bootstrap通过反射创建catalina实例,catalina开启tomcat服务器
tomcat嵌入式启动方式:tomcat提供了一个同名类org.apache.catalina.startup.Tomcat,通过该类可将tomcat嵌入到应用程序中,直接在应用程序中开启tomcat服务器
tomcat
public class Tomcat {
private static final StringManager sm = StringManager.getManager(Tomcat.class);
private final Map<String, Logger> pinnedLoggers = new HashMap();
protected Server server;
protected int port = 8080;
protected String hostname = "localhost";
protected String basedir;
private final Map<String, String> userPass = new HashMap();
private final Map<String, List<String>> userRoles = new HashMap();
private final Map<String, Principal> userPrincipals = new HashMap();
private boolean addDefaultWebXmlToWebapp = true;
static final String[] silences = new String[]{"org.apache.coyote.http11.Http11NioProtocol", "org.apache.catalina.core.StandardService", "org.apache.catalina.core.StandardEngine", "org.apache.catalina.startup.ContextConfig", "org.apache.catalina.core.ApplicationContext", "org.apache.catalina.core.AprLifecycleListener"};
private boolean silent = false;
public Tomcat() {
ExceptionUtils.preload();
}
public void setPort(int port) {
public void setHost(Host host) {
public void setHostname(String s) {
public void setBaseDir(String basedir) {
public void setConnector(Connector connector) {
public void setAddDefaultWebXmlToWebapp(boolean addDefaultWebXmlToWebapp) {
public void addUser(String user, String pass) {
public void addRole(String user, String role) {
public Context addContext(String contextPath, String docBase) {
public Context addContext(Host host, String contextPath, String dir) {
public Context addContext(Host host, String contextPath, String contextName, String dir) {
public Context addWebapp(String contextPath, String docBase) {
public Context addWebapp(String contextPath, URL source) throws IOException {
public Context addWebapp(Host host, String contextPath, String docBase) {
public Context addWebapp(Host host, String contextPath, String docBase, LifecycleListener config) {
public Wrapper addServlet(String contextPath, String servletName, String servletClass) {
public static Wrapper addServlet(Context ctx, String servletName, String servletClass) {
public Wrapper addServlet(String contextPath, String servletName, Servlet servlet) {
public static Wrapper addServlet(Context ctx, String servletName, Servlet servlet) {
public void init(ConfigurationSource source) {
public void init(ConfigurationSource source, String[] catalinaArguments) {
public void init() throws LifecycleException {
public void start() throws LifecycleException { //调用该方法开启tomcat服务
this.getServer();
this.server.start();
}
public void stop() throws LifecycleException {
public void destroy() throws LifecycleException {
public void enableNaming() {
public String noDefaultWebXmlPath() {
public void initWebappDefaults(String contextPath) {
public static void initWebappDefaults(Context ctx) {
public static void addDefaultMimeTypeMappings(Context context) {
public Host getHost() {
public Engine getEngine() {
public Server getServer() {
public Service getService() {
public Connector getConnector() {
public void setSilent(boolean silent) {
public LifecycleListener getDefaultWebXmlListener() {
protected void initBaseDir() {
protected Realm createDefaultRealm() {
protected URL getWebappConfigFile(String pat