AI智能
改变未来

Java读源码之Netty深入剖析


download:Java读源码之Netty深入剖析

Netty的横空出世让Java开发者眼前一亮,数据流处理、应用程序开启、处理协议编码等工作因为Netty都变得更加简单,也正因如此,掌握Netty也成为了抢手Java开发的必备素质。本次课程从Socket例子入手,一步步深入探究Netty源码,剖析代码背后的原理,解决面试中遇到的Netty问题,彻底掌握Netty。
适合人群
有Netty编程经验,想了解Netty底层实现的小伙伴,IDE不熟悉的小伙伴
可以学习老师的《IntelliJ IDEA神器使用技巧》课程
技术储备要求
IntelliJ IDEA,会使用虚拟机,maven,使用过Netty
了解nio,多线程知识

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;
/**

  • 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();
    }
赞(0) 打赏
未经允许不得转载:爱站程序员基地 » Java读源码之Netty深入剖析