java easyrest_EasyRest 一个为快速开发而设计的高性能RESTful框架

EasyRest是一个基于Netty、Akka和Spring的高性能RESTful框架,旨在简化快速开发。它无需Tomcat和web.xml,只需一个包含'main'函数的jar包即可构建分布式系统。框架易于集群和分布式部署,支持与Spring集成,即使不了解Netty、Akka或Spring也能使用。通过简单的注解定义REST接口,结合Spring服务实现,可以快速创建RESTful服务。
摘要由CSDN通过智能技术生成

EasyRest-NAS

中文文档地址:

EasyRest integration with Netty, Akka and Spring.

This is the high performance RESTful framework, designed for the fast development. Easy to cluster and distributed. You can focus on your business logic.

No tomcat, no web.xml, only need a jar package with 'main' function, you can get a prefect distributed system.

You can don't know Netty, Akka even Spring. You can still using this framework.

Quick start:

The rest definition

@BindURL("/rest/{TENANT}/stock")

public interface StockInfoRest {

@Post("/personal/{USER_ID}/favorite/{CODE}")

void addFavorite(String TENANT, String USER_ID, String CODE, long time);

@Post

ResponseEntity addStocks(int userNumber, String userName, List stockList);

@Get("/personal/{USER_ID}/favorite/list")

List getStockList(String USER_ID);

}

The Service is the bean of spring, you can integrate with spring

@Service

public class StockInfoRestController implements StockInfoRest {

@Override

public void addFavorite(String TENANT, String USER_ID, String CODE, long time) {

System.out.println(TENANT + " " + USER_ID + " " + CODE + " " + time);

}

@Override

@AllDefined

public ResponseEntity addStocks(int userNumber, String userName, List stockList) {

return ResponseEntity.buildOkResponse(Lists.asList(userNumber, userName, new List[]{stockList}));

}

@Override

public List getStockList(String USER_ID) {

return Lists.newArrayList(new Stock(100000, "stock1"), new Stock(100001, "stock2"), new Stock(100002, "stock3"));

}

}

The main class.

public class Example {

public static void main(String[] args) {

EasyRest easyRest = new EasyRest("classpath:MyExampleApplicationContext.xml");

easyRest.startup("EasyRestServer");

}

}

An empty spring config file

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

xmlns:context="http://www.springframework.org/schema/context"

xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">

@BindURL("/rest/{TENANT}/stock") will bind this endpoint at "/rest/{TENANT}/stock"

@AllDefined will check all parameters not be null, if any parameter is null, the framework will reject the request directly.

@Service is spring annotation, that will create bean by spring.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值