浅尝Hessian远程调用
来源:互联网 发布:大学高等数学软件 编辑:程序博客网 时间:2024/06/07 19:17
Hessian是一个远程调用的技术,hessian由两个部分组成,服务端和客户端,服务端供客户端调用。下面先上一个小例子,然后再作一个简单的说明。
服务端项目结构图:
HelloService接口代码:
public interface HelloService { public void hello(); }
HelloServiceImpl实现类代码:
@Service("helloService") public class HelloServiceImpl implements HelloService { @Override public void hello() { System.out.println("hello hession !"); } }
spring相关的配置文件
<bean id="helloService" class="com.hession.HelloServiceImpl"/> <bean name="/hello" class="org.springframework.remoting.caucho.HessianServiceExporter"> <property name="service" ref="helloService"/> <property name="serviceInterface" value="com.hession.HelloService"/> </bean>
项目中导入hessian包,在web.xml配置hessian的servlet-mapping
<servlet-mapping> <servlet-name>dispatcher</servlet-name> <url-pattern>*.html</url-pattern> <url-pattern>*.json</url-pattern> <url-pattern>*.xml</url-pattern> <url-pattern>*.jhtml</url-pattern> <url-pattern>*.do</url-pattern> <url-pattern>/hessian/*</url-pattern>(配置hessian路径)</servlet-mapping>
客户端:
HelloService接口和服务端的一致,HessianClient代码如下:
public class HessionClient { public static void main(String[] args) { //具体路径根据服务端的配置改变而改变 String url="http://localhost:8182" +"/hessian/hessian/hello"; HessianProxyFactory pf = new HessianProxyFactory(); HelloService hello = null; try { hello = (HelloService)pf.create( HelloService.class,url); hello.hello(); } catch (MalformedURLException e) { e.printStackTrace(); } } }
运行main方法即可调用服务端的业务。
阅读全文
0 0
- 浅尝Hessian远程调用
- Hessian-远程服务调用
- Hessian实现远程调用
- spring hessian远程调用
- Java远程调用之Hessian
- Java 远程调用 Hessian 简例
- hessian 实现远程接口调用
- hessian远程调用的使用
- hessian 远程接口调用原理
- JFinal+Hessian调用远程服务
- hessian远程服务调用例子
- hessian远程调用及spring中使用hessian
- Java远程调用之Hessian篇简例
- Spring2.5远程调用Hessian的例子
- java远程调用之spring和hessian
- Hessian轻量级二进制远程调用框架
- Hessian远程调用及序列化协议
- Hessian轻量级二进制远程调用框架
- python基础学习-There's an error in your program:expected an indented block错误解决
- hrbust 2326 Blind Father (单调栈)
- 浏览器兼容问题详解
- php加盐加密
- 定时删除项目upload目录下的所有不需要的文件以及目录(保留upload目录)
- 浅尝Hessian远程调用
- jenkins,maven--Execute shell构建
- Node.js中package.json中库的版本号详解(^和~区别)
- 详谈java内存模型
- java中常见的session种类
- atos
- strcpy和memcpy的区别
- Hdu 5710 Digit-Sum【思维】
- 常驻通知栏跳转到别的应用