next-jfinal整合tio成功

next-jfinal整合tio成功

1.将jfinal移除servlet,命名为next-jfinal

2.使用tio-内部是实现servlet工程

3.使用next-jfinal对接tio

4.自定义tio的handler将请求转发到jfinal的Controller

5.编写jfinal测试Hello World测试


测试工程地址

https://github.com/litongjava/java-ee-next-jfinal-study/tree/main/next-jfinal-web-hello-study

关联工程

https://github.com/litongjava/next-jfinal

https://github.com/litongjava/t-io

package com.litongjava.tio.web.hello;

import com.jfinal.aop.annotation.ComponentScan;
import com.litongjava.tio.boot.JFinalApplication;

@ComponentScan
public class HelloApp {
  public static void main(String[] args) {
    long start = System.currentTimeMillis();
    JFinalApplication.run(HelloApp.class, args);
    long end = System.currentTimeMillis();
    System.out.println((end - start) + "ms");
  }
}
package com.litongjava.tio.web.hello.config;

import com.jfinal.config.Constants;
import com.jfinal.config.Handlers;
import com.jfinal.config.Interceptors;
import com.jfinal.config.JFinalConfig;
import com.jfinal.config.Plugins;
import com.jfinal.config.Routes;
import com.jfinal.template.Engine;

public class DemoConfig extends JFinalConfig {

  public void configConstant(Constants me) {
    me.setDevMode(true);

    // 开启解析 json 请求,5.0.0 版本新增功能
    me.setResolveJsonRequest(true);

  }

  public void configRoute(Routes me) {
    me.scan("com.litongjava.tio.web.hello.controller");
  }

  public void configEngine(Engine me) {
  }

  public void configPlugin(Plugins me) {
  }

  public void configInterceptor(Interceptors me) {
  }

  public void configHandler(Handlers me) {
  }

}


package com.litongjava.tio.web.hello.config;

import com.jfinal.aop.annotation.Bean;
import com.jfinal.aop.annotation.Configuration;
import com.jfinal.config.JFinalConfig;

@Configuration
public class JFinalConfiguration {

  @Bean  public JFinalConfig jfinalConfig() {
    return new DemoConfig();
  }
}
package com.litongjava.tio.web.hello.controller;

import com.jfinal.core.Controller;
import com.jfinal.core.Path;

@Path("/")
public class IndexController extends Controller {

  public void index() {
    renderText("Hello Web");
  }
}


2023-12-19 03:47:45.274 [main] INFO  c.l.t.s.TioServer.start:156 - 
|----------------------------------------------------------------------------------------|
| t-io site         | https://www.litongjava.com/t-io                                    |
| t-io on gitee     | https://gitee.com/ppnt/t-io                                        |
| t-io on github    | https://github.com/litongjava/t-io                                 |
| t-io version      | 3.7.3.v20231218-RELEASE                                            |
| ---------------------------------------------------------------------------------------|
| TioConfig name    | tio-boot                                                           |
| Started at        | 2023-12-19 03:47:45                                                |
| Listen on         | 0.0.0.0:80                                                         |
| Main Class        | com.litongjava.tio.web.hello.HelloApp                              |
| Jvm start time    | 414ms                                                              |
| Tio start time    | 18ms                                                               |
| Pid               | 2064                                                               |
|----------------------------------------------------------------------------------------|

2023-12-19 03:47:45.282 [main] INFO  c.j.a.p.ConfigurationAnnotaionProcess.processConfigBean:102 - inited config bean:com.litongjava.tio.web.hello.config.DemoConfig
2023-12-19 03:47:45.283 [main] INFO  c.j.a.p.ConfigurationAnnotaionProcess.processConfigBean:108 - add bean mapping:class com.jfinal.config.JFinalConfig from com.litongjava.tio.web.hello.config.DemoConfig
2023-12-19 03:47:45.294 [main] INFO  c.l.t.b.c.JFinalApplicationContext.run:197 - jfinal config:com.litongjava.tio.web.hello.config.DemoConfig@1753acfe
2023-12-19 03:47:45.320 [main] INFO  c.l.t.b.c.JFinalApplicationContext.run:212 - scan class and init:58,server:120(ms),config:16(ms),http reoute:26(ms)
2023-12-19 03:47:45.321 [main] INFO  c.l.t.b.c.JFinalApplicationContext.run:215 - port:80
http://localhost
432ms

JFinal-5.1.5 action report -------- 2023-12-19 03:47:47 --------------------------
Url         : null /
Controller  : com.litongjava.tio.web.hello.controller.IndexController.(IndexController.java:1)
Method      : index
--------------------------------------------------------------------------------


image.png

评论区

89426094

2023-12-20 09:17

tio 这是原来那的吗?t-io: 不仅仅是百万级即时通讯框架

李通

2023-12-20 09:22

不是我对tio的源码也做了一些修改,但是tio的核心源码我没有动

热门分享

扫码入社