Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/cng1985/jsonrpc
一个简单的rpc
https://github.com/cng1985/jsonrpc
Last synced: about 23 hours ago
JSON representation
一个简单的rpc
- Host: GitHub
- URL: https://github.com/cng1985/jsonrpc
- Owner: cng1985
- Created: 2015-03-12T02:04:07.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2022-12-10T05:07:18.000Z (almost 2 years ago)
- Last Synced: 2023-07-26T22:34:25.647Z (over 1 year ago)
- Language: Java
- Size: 102 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# jsonrpc
[![maven](https://img.shields.io/maven-central/v/com.quhaodian.jsonrpc/core.svg)](http://mvnrepository.com/artifact/com.quhaodian.jsonrpc/core)
[![QQ](https://img.shields.io/badge/chat-on%20QQ-ff69b4.svg?style=flat-square)](//shang.qq.com/wpa/qunwpa?idkey=d1a308945e4b2ff8aeb1711c2c7914342dae15e9ce7041e94756ab355430dc78)
[![Apache-2.0](https://img.shields.io/hexpm/l/plug.svg)](https://www.apache.org/licenses/LICENSE-2.0.html)
[![使用IntelliJ IDEA开发维护](https://img.shields.io/badge/IntelliJ%20IDEA-提供支持-blue.svg)](https://www.jetbrains.com/idea/)
[![GitHub forks](https://img.shields.io/github/stars/cng1985/jsonrpc.svg?style=social&logo=github&label=Stars)](https://github.com/cng1985/jsonrpc)
======
##一个简单android访问api组件##
部分代码参考:https://github.com/RitwikSaikia/jsonrpc
这部分代码版权归RitwikSaikia所有。服务端缓存、客服端缓存、注解支持,spring支持等版权归ada.young所有。##maven使用##
com.quhaodian.jsonrpc
core
1.01
## 使用方法 ##
1. 定义接口@RestFul(api=Calculator.class,value="calculator")
public interface Calculator {
double add(double x, double y);
double multiply(double x, double y);
}
2. 实现接口
public class SimpleCalculatorImpl implements Calculator {
public double add(double x, double y) {
return x + y;
}
public double multiply(double x, double y) {
return x * y;
}
}3. 通过与spring集成,配置servlet。
contextConfigLocation
classpath:context.xml
org.springframework.web.context.ContextLoaderListener
dispatcher
org.springframework.web.servlet.DispatcherServlet
contextConfigLocation
1
rpc
com.quhaodian.servlet.RpcServlet
2
rpc
/rpc
4. 客服端访问
String url="远程服务端servlet地址"
Calculator s = RestFulClient.getService(url, Calculator .class);
double result = calc.add(1.2, 7.5);