用户工具

站点工具


light4j:solon
  • 官网 gitee HTTP+WEBSOCKET+SOCKET三源合一,集合 Handler + Context 和 Listener + Message 两种架构,支持注解和手动、Not Servlet,基于订阅模式的 IOC & AOP 容器设计
    • solon-api,接口应用,可选http(默认jdkhttp jlhttp smarthttp jetty undertow)和cache(默认local caffine jedis redission spymemcached)
    • solon-web,网站应用,可选sessionstate(默认local jwt redis)和view(默认freemarker beetl enjoy jsp thymeleaf velocity)
    • solon-cloud,微服务,可选plugin(默认consul nacos water)
    • nami,客户端,支持http(hutool okhttp) socketd(jdksocket netty rsocket smartsocket websocket) coder(fastjson snack3 jackson hessian protostuff)
  <parent>
    <groupId>org.noear</groupId>
    <artifactId>solon-parent</artifactId>
    <version>1.9.0</version>
  </parent>
  <!-- 默认使用jdkhttp,可选jlhttp smarthttp jetty undertow;普通接口应用可使用solon-api -->
    <dependency>
      <groupId>org.noear</groupId>
      <artifactId>solon-web</artifactId>
    </dependency>
    <dependency>
      <groupId>org.noear</groupId>
      <artifactId>solon-test</artifactId>
      <scope>test</scope>
    </dependency>
    <!-- 编译参数需要-parameters,自定义mainClass -->
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.8.1</version>
        <configuration>
          <compilerArgument>-parameters</compilerArgument>
          <source>1.8</source>
          <target>1.8</target>
          <encoding>UTF-8</encoding>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-assembly-plugin</artifactId>
        <version>3.3.0</version>
        <configuration>
          <finalName>${project.artifactId}</finalName>
          <appendAssemblyId>false</appendAssemblyId>
          <descriptorRefs>
            <descriptorRef>jar-with-dependencies</descriptorRef>
          </descriptorRefs>
          <archive>
            <manifest>
              <mainClass>org.example.demo.DemoApp</mainClass>
            </manifest>
          </archive>
        </configuration>
        <executions>
          <execution>
            <id>make-assembly</id>
            <phase>package</phase>
            <goals>
              <goal>single</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
  • 接口实现
    • main函数:SolonApp app = Solon.start(App.class,args);
    • Handler模式:app.get(“/”,©→c.output(“Hello world!”));
    • 注解模式:@Controller Hello { @Get @Mapping(“/”) String hello(){ return “Hello world!”; } }
    • 远程接口:@Socket @Remoting @Mapping(“/”) Hello { String hello(){return “Hello world!”;} }
    • 客户端:@NamiClient(“http://host/”) Hello hello; Nami.builder().url(“http://host/”).create(Hello.class);
    • 配置:@Configuration Config{ @Inject(“${key:def}”) String key; }
    • 校验:@Valid Hello { @Tran @NotZero(“id”) @CacheRemove(tags=“tag_${id}”) void update(int id); }
    • 上传:@Mapping(“file/upload”) void upload(UploadedFile file){ IoUtils.save(file.content,“data/file_”+file.name); }
    • 下载:@Mapping(“file/download”) DownloadedFile download(String path){ return new DownloadedFile(“text/json”,Utils.getResource(path).openStream(),“test.json”); }
  • water:一站式服务治理平台,相当于consul + rabbitmq + elk + prometheus + openFaas + quartz
    • xwater:初始化,最低要求redis+mysql,可选mongodb+es等
    • waterapi:服务端,“env”:{“water.ds.server”:“localhost:3306”,“water.ds.username”:“water”,“water.ds.password”:“water”}
    • wateradmin:控制台,“vmArgs”: “-Dwater.host=localhost:9371 -Dfile.encoding=utf-8”,初始账户admin/admin
    • watersev:后台服务(健康检测;数据监视;消息派发;定时任务等)
    • waterfaas:轻量级FaaS服务,“env”:{“TS”:“Asia/Shanghai”}
  • marsh:集成应用开发框架(solon cloud + water)
    • _demo/marsh_admin_demo:“vmArgs”: “-Dsolon.cloud.water.server=localhost:9371 -Dfile.encoding=utf-8”,wateradmin已包含grit.server服务
  • 访问控制
    • app.filter拦截器,可用于ip控制
    • Aop.context().beanAroundAdd(Mapping.class,inv→{retur inv.invoke();});可用于修改返回结果
    • ActionExecutorDefault解析方法参数,支持Context ModelAndView Locale UploadedFile HttpServletRequest HttpServletResponse String InputStream 自定义Entity
light4j/solon.txt · 最后更改: 2022/07/05 17:04 由 admin