zoukankan      html  css  js  c++  java
  • Atitit 嵌入式tomcat 嵌入式服务器 attilax 你感觉艾提拉 总结 比起嵌入jetty ,文件可以自动刷新貌似还不错。。方便调试debug package com.attilax.

    Atitit 嵌入式tomcat 嵌入式服务器 attilax 你感觉艾提拉 总结

    比起嵌入jetty ,文件可以自动刷新貌似还不错。。方便调试debug

    package com.attilax.web;

    import java.io.File;

    import org.apache.catalina.LifecycleException;

    import org.apache.catalina.core.AprLifecycleListener;

    import org.apache.catalina.core.StandardServer;

    import org.apache.catalina.startup.ClassLoaderFactory;

    import org.apache.catalina.startup.Tomcat;

    import com.attilax.io.pathx;

    import com.attilax.util.Global;

    import javax.servlet.ServletException;

    /**

     * Created by nil on 2014/8/1.

     */

    public class EmbeddedTomcat {

        private Tomcat tomcat;

        private void startTomcat(int port, String contextPath, String baseDir)

                throws ServletException, LifecycleException {

            tomcat = new Tomcat();

            tomcat.setPort(port);

            tomcat.setBaseDir(".");

            StandardServer server = (StandardServer) tomcat.getServer();

            AprLifecycleListener listener = new AprLifecycleListener();

            server.addLifecycleListener(listener);

            tomcat.addWebapp(contextPath, baseDir);

            tomcat.start();

        }

        private void stopTomcat() throws LifecycleException {

            tomcat.stop();

        }

        public static void main(String[] args) {

         System.out.println("");

            try {

                int port = 80;

                String contextPath = "/";

                String baseDir =pathx.webAppPath_jensyegeor();

                 //new File("webroot").getAbsolutePath();  // 项目中web目录名称,以前版本为WebRootwebappwebapps,现在为WebContent

                EmbeddedTomcat tomcat = new EmbeddedTomcat();

                tomcat.startTomcat(port, contextPath, baseDir);

                // 由于Tomcatstart方法为非阻塞方法,加一个线程睡眠模拟线程阻塞.

                

                

                String heartbeat_str = "--tomcat run. heartbeat_str";

               Global.heartbeatRecycle(heartbeat_str);

               

            } catch (Exception e) {

                e.printStackTrace();

            }

        }

    }

    配置简单的嵌入式tomcat - CSDN博客.html

  • 相关阅读:
    腾讯为什么会出Q立方浏览器?
    String,StringBuffer与StringBuilder的区别??
    Linux Socket编程(不限Linux)
    将div显示在屏幕正中央
    计算鼠标坐标是否在指定范围内
    正则
    ajax异步通信
    CSS Float 换行
    jQuery强大的jQuery选择器
    给display字段增加筛选功能
  • 原文地址:https://www.cnblogs.com/attilax/p/15197674.html
Copyright © 2011-2022 走看看