浏览 4510 次
锁定老帖子 主题:Spring发布多协议的远程服务最简单办法
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
|
|
---|---|
作者 | 正文 |
发表时间:2007-03-23
1.ServiceExporter public class ServiceExporter extends RemoteExporter implements Controller, InitializingBean { /** *访问协议属性 */ public static final String REMOTE_EXPORTER = "RemoteExporter"; /** *访问协议hession */ public static final String HESSIAN_SERVICE_EXPORTER = "HessianServiceExporter"; HessianServiceExporter hessian=new HessianServiceExporter(); /** *访问协议HttpInvoker */ public static final String HTTP_INVOKER_SERVICE_EXPORTER = "HttpInvokerServiceExporter"; HttpInvokerServiceExporter httpInvoker=new HttpInvokerServiceExporter(); /** *访问协议Burlap */ public static final String BURLAP_SERVICE_EXPORTER = "BurlapServiceExporter"; BurlapServiceExporter burlap=new BurlapServiceExporter(); public void setService(Object service) { super.setService(service); hessian.setService(service); httpInvoker.setService(service); burlap.setService(service); } public void setServiceInterface(Class serviceInterface) { super.setServiceInterface(serviceInterface); hessian.setServiceInterface(serviceInterface); httpInvoker.setServiceInterface(serviceInterface); burlap.setServiceInterface(serviceInterface); } public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception{ //检查访问协议属性 String remoteExporter = request.getHeader(ServiceExporter.REMOTE_EXPORTER); // 访问协议Hessian if(remoteExporter==null) { hessian.handleRequest(request,response); return null; } //访问协议HttpInvoker if(remoteExporter.equalsIgnoreCase(ServiceExporter.HTTP_INVOKER_SERVICE_EXPORTER)) httpInvoker.handleRequest(request,response); //访问协议Burlap else if(remoteExporter.equalsIgnoreCase(ServiceExporter.BURLAP_SERVICE_EXPORTER)) burlap.handleRequest(request,response); //访问协议Hessian else hessian.handleRequest(request,response); return null; } public void afterPropertiesSet() throws Exception { hessian.afterPropertiesSet(); burlap.afterPropertiesSet(); httpInvoker.afterPropertiesSet(); } 2.把接口发布为多协议远程服务 <bean name="/log/BusinessLogMessageService" class="bpo.ServiceExporter"> <property name="service" ref="log.BusinessLogMessageBPOTx"/> <property name="serviceInterface" value="log.ILogMessageService"/> </bean> 声明:ITeye文章版权属于作者,受法律保护。没有作者书面许可不得转载。
推荐链接
|
|
返回顶楼 | |
发表时间:2007-03-23
无所谓了,轻巧的有轻巧的用处,多功能也有多功能的用处.
|
|
返回顶楼 | |
发表时间:2007-04-12
你好,想问你一个问题,有没有什么办法可以获得hessian和burlap传输过程中压缩数据的大小,然后对这两者做个比较好进行选择?
|
|
返回顶楼 | |