https://github.com/cng1985/jsonrpc
一个简单的rpc
https://github.com/cng1985/jsonrpc
Last synced: 4 months ago
JSON representation
一个简单的rpc
- Host: GitHub
- URL: https://github.com/cng1985/jsonrpc
- Owner: cng1985
- Created: 2015-03-12T02:04:07.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2022-12-10T05:07:18.000Z (over 2 years ago)
- Last Synced: 2025-01-14T23:46:08.660Z (5 months 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
[](http://mvnrepository.com/artifact/com.quhaodian.jsonrpc/core)
[](//shang.qq.com/wpa/qunwpa?idkey=d1a308945e4b2ff8aeb1711c2c7914342dae15e9ce7041e94756ab355430dc78)
[](https://www.apache.org/licenses/LICENSE-2.0.html)
[](https://www.jetbrains.com/idea/)
[](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);