代码拉取完成,页面将自动刷新
同步操作将从 郑大侠/lamp 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
#lamp
基于netty&spring容器封装的json通讯协议组件
##modules ##protocol
现仅支持私有JSONP协议 TODO 自定义协议扩展,开放解包封包实现
###JSONP实现 RequestJSON
{
"id": 0,
"uri": "/lamp/test",
"data": {
"name": "dempe"
}
}
ResponseJSON
{
"id": 0,
"uri": "/lamp/test",
"data": {
"data": "6666"
}
}
##example ###服务端的打开方式 ####基于spring注解的打开方式
@Configuration
@ComponentScan
public class LampServer {
public static void main(String[] args) {
ApplicationContext context = new AnnotationConfigApplicationContext(LampServer.class);
BaseServer baseServer = new BaseServer(DefConfigFactory.createDEVConfig(), context);
baseServer.start();
}
}
####基于spring xml的打开方式
ApplicationContext context = new ClassPathXmlApplicationContext(new String[]{"application.xml"});
BaseServer baseServer = new BaseServer(DefConfigFactory.createDEVConfig(), context);
baseServer.start();
application.xml配置如下
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
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">
<context:annotation-config/>
<!-- 主动搜索以下目录 -->
<context:component-scan base-package="com.dempe.lamp"/>
</beans>
###业务逻辑的编写方式
@Controller("lamp")
public class LampController {
@Resource
LampService lampService;
@Path
public JSONObject test(@Param String name) {
System.out.println("name===>" + name);
lampService.say();
JSONObject jsonObject = new JSONObject();
jsonObject.put("code", 6666);
return jsonObject;
}
}
###客户端的使用方式
public class LampClient {
public static void main(String[] args) {
ReplyClient client = new ReplyClient("localhost", 8888);
JSONObject data = new JSONObject();
data.put("name", "dempe");
JSONRequest request = new JSONRequest("/lamp/test", data);
Response response = client.sendAndWait(request);
client.sendOnly(request);
System.out.println(response);
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。