Netty的橫空出世讓Java開發者眼前一亮,數據流處理、應用程序開啓、處理協議編碼等工做由於Netty都變得更加簡單,也正因如此,掌握Netty也成爲了搶手Java開發的必備素質。本次課程從Socket例子入手,一步步深刻探究Netty源碼,剖析代碼背後的原理,解決面試中遇到的Netty問題,完全掌握Netty。
適合人羣
有Netty編程經驗,想了解Netty底層實現的小夥伴,IDE不熟悉的小夥伴
能夠學習老師的《IntelliJ IDEA神器使用技巧》課程
技術儲備要求
IntelliJ IDEA,會使用虛擬機,maven,使用過Netty
瞭解nio,多線程知識html
package com.yky.logic.test;
import java.io.File;
import org.apache.catalina.core.AprLifecycleListener;
import org.apache.catalina.core.StandardServer;
import org.apache.catalina.startup.Tomcat;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
/**java
- TOMCAT
*/
public class EmbeddedTomcat {
private final Logger log = LogManager.getLogger(EmbeddedTomcat.class);
private static String CONTEXT_PATH = "/cis";
private static String PROJECT_PATH = System.getProperty("user.dir");
private static String WEB_APP_PATH = PROJECT_PATH + File.separatorChar + "src/main/webapp";
private static int PORT = 8080;
private Tomcat tomcat = new Tomcat();
public void start() throws Exception {
tomcat.setPort(PORT);
tomcat.setBaseDir(WEB_APP_PATH);
tomcat.getHost().setAppBase(WEB_APP_PATH);
StandardServer server = (StandardServer) tomcat.getServer();
AprLifecycleListener listener = new AprLifecycleListener();
server.addLifecycleListener(listener);
tomcat.addWebapp(CONTEXT_PATH, WEB_APP_PATH);
tomcat.enableNaming();
tomcat.start();
tomcat.getServer().await();
log.info("============== Tomcat 啓動 ==============");
}
public void stop() throws Exception {
tomcat.stop();
log.info("============== Tomcat 終止 ==============");
}
/**
- @param args
- @throws Exception*/public static void main(String[] args) throws Exception {EmbeddedTomcat embededTomcat = new EmbeddedTomcat();embededTomcat.start();}