Hessian探究(一)Hessian与Spring结合
上一篇博客Hessian探究(一)Hessian入门示例我们初步简单的介绍了一下Hessian的使用入门示例,由于Spring现在使用的实在是太广泛了,接下来我们介绍一下Hessian和Spring一起开发的过程。
在上一篇博客中我们是通过如下代码来调用Hessian发布的服务:简单来说就是通过URL进行访问来使用Hessian发布的服务。
package com.tianjunwei.hessian.client;
import java.net.MalformedURLException;
import com.caucho.hessian.client.HessianProxyFactory;
import com.tianjunwei.hessian.server.HelloService;
public class HelloServiceMain {
public static void main(String [] args) throws MalformedURLException{
String url = "http://localhost:8080/hessian";
System.out.println(url);
HessianProxyFactory factory = new HessianProxyFactory();
HelloService helloService = (HelloService) factory.create(HelloService.class, url);
System.out.println(helloService.helloWorld("jimmy"));
}
}
在Spring下我们又是如何来使用Hessian的服务端来发布的服务的。
(1)Hessian给我们提供了在Spring下使用的HessianProxyFactoryBean,其实就是一个代理工厂,生成代理类。在spring的ApplicationContext.xml中进行如下配置,其实就是两个信息serviceUrl为Hessian暴露服务的连接,serviceInterface为暴露服务的接口。
<!-- 客户端Hessian代理工厂Bean -->
<bean id="clientSpring" class="org.springframework.remoting.caucho.HessianProxyFactoryBean">
<!-- 服务端请求地址 -->
<property name="serviceUrl">
<span style="white-space:pre"> </span><value>http://localhost:8080/hessian</value>
</property>
<!-- 接口定义 -->
<property name="serviceInterface">
<span style="white-space:pre"> </span><value>com.tianjunwei.hessian.server.HelloService</value>
</property>
</bean>
(2)经过第一步配置之后,接下来我们就可以在Spring中像使用普通的Bean一样来进行远程调用了,示例代码如下:
package com.tianjunwei.hessian.client;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import com.tianjunwei.hessian.server.HelloService;
public class SpringClient {
public static void main(String[] args) {
ApplicationContext contex = new ClassPathXmlApplicationContext(
"applicationContext.xml");
// 获得客户端的Hessian代理工厂bean
HelloService helloService = (HelloService) contex.getBean("clientSpring");
System.out.println(helloService.helloWorld("world"));
}
}
运行结果:
hello,world
Hessian探究(一)Hessian与Spring结合的更多相关文章
- Hessian探究(一)Hessian与springMVC结合
上一篇博客Hessian探究(一)Hessian入门示例我们初步简单的介绍了一下Hessian的使用入门示例,我们是通过Servlet来暴露Hessian的对外服务的,接下来我们介绍一下通过Sprin ...
- Hessian Servlet和Hessian Spring的简单应用
转自: http://lancui.iteye.com/blog/935578 简介 相比WebService,Hessian更简单.快捷.采用的是二进制RPC协议(Binary),因为采用的是二进制 ...
- Hessian探究(一)Hessian入门示例
一.hessian的maven信息: [html] view plain copy print? <dependency> <groupId>com.caucho</gr ...
- java深入探究12-框架之Spring
1.引入Spring 我们在搭建框架时常常会解决问题:对象创建,对象之间依赖关系如何处理,Spring就是来解决这类问题的:控制反转依赖注入 2.环境搭建 1)下载源码:其中3.0以下版本源码中有Sp ...
- Spring整合Hessian
Spring让Hessian变得不但强大,而且易用,但是易用背后,却有不少陷阱! 这个例子很简单,但实际上的确花费了我超过一小时的时间,排除了种种问题,最后问题终于水落石出. 整合以上篇Hel ...
- spring mvc 结合 Hessian 配置
spring mvc 结合 Hessian 配置 1.先在web.xml中配置 <!-- Hessian配置 --> <servlet> <servlet-name> ...
- spring集成Hessian的基本使用方法
一.什么是RPC RPC全称Remote Procedure Call,中文名叫远程过程调用.RPC是一种远程调用技术,用于不同系统之间的远程相互调用.其在分布式系统中应用十分广泛. 二.什么是Hes ...
- hessian的简单使用以及与spring整合
Hessian是一个由Caucho Technology开发的轻量级二进制RPC协议.和其他Web服务的实现框架不同的是,Hessian是一个使用二进制格式传输的Web服务协议的框架,相对传统soap ...
- hessian+spring集成应用
注意事项 ▲JAVA服务器端必须具备以下几点:---->包含Hessian的jar包---->设计一个接口,用来给客户端调用---->实现该接口的功能---->配置web.xm ...
随机推荐
- 解决win10 VC++6.0 应用程序无法正常运行 0xc0000142
废话不多说,无法正常运行原因就是win10不兼容中文版的vc,解决方法就是一句话,用英文版的msdev.exe替换中文版的msdev.exe,msdev.exe是vc的启动程序.直接上来教你怎么做.废 ...
- A TensorBoard plugin for visualizing arbitrary tensors in a video as your network trains.Beholder是一个TensorBoard插件,用于在模型训练时查看视频帧。
Beholder is a TensorBoard plugin for viewing frames of a video while your model trains. It comes wit ...
- php+xdebug远程调试(单人)
目录 服务器上安装 XDebug 及配置 客户端 PHPstorm 配置 浏览器安装插件 服务器上安装 XDebug 及配置 XDebug 安装 略 配置: 打开 php.ini 配置文件: vim ...
- text-align:center属性失效
text-align:center只对inline元素有效,失效的情况下 给它所有的子元素加上 display:inline-block即可 inline-block不兼容ie6
- Redis学习汇总
[Redis教程目录] 1.redis是什么 2.redis的作者何许人也 3.谁在使用redis 4.学会安装redis 5.学会启动redis 6.使用redis客户端 7.redis数据结构 – ...
- Java面试06|项目相关介绍
1.明确你的项目到底是做什么的,有哪些功能 广告投放机:项目主要是为移动端有针对性的进行广告展示. 媒体管理平台SSP:为媒体端实现多种变现途径 (1)广告投放机中关于广告检索与排序的功能 1.广告检 ...
- FJUT寒假作业第三周数蚂蚁(记录第一道并查集)
http://210.34.193.66:8080/vj/Contest.jsp?cid=162#P7 思路:用并查集合并集合,最后遍历,找到集合的根的个数. 并查集是森林,森林中的每一颗树是一个集合 ...
- Eleven
A. Eleven time limit per test : 1 second memory limit per test: 256 megabytes input: standard inpu ...
- Node.js ZLIB
Zlib 稳定性: 3 - 文档 可以通过以下方式访问这个模块: var zlib = require('zlib'); 这个模块提供了对 Gzip/Gunzip, Deflate/Inflate, ...
- Linux搭建lamp(Apache+PHP+Mysql环境)centos7.2版详细教程
我们更多的网站服务器是选择了Linux系统,这里建议你选择centos,这也是阿里云ecs推荐的系统,在服务器上比较推荐centos,特别对于新手,首选CentOS,并不是centos比Debian和 ...