在SSH中使用Hessian
来源:互联网 发布:互联网数据运营 编辑:程序博客网 时间:2024/05/21 10:44
在SSH中使用Hessian
2010-11-16 17:10:13| 分类:远程调用| 标签:ssh hessian 拦截器 |字号大中小 订阅
个人感觉使用hessian可以解决一些需要远程调用的业务逻辑相对简单,节点数量不是太多的网络应用。但是当数量增加,逻辑负责,特别是各个节点间又可以相互调用的时候就有些麻烦了。
在SSH结构下使用的Hessian版本最好是spring自带的版本,通常在lib/caucho目录下。
首先,假设我们要远程调用的service是Hello,位于org.dreamfly.core.test.Hello.它的实现类是HelloImpl,位于org.dreamfly.core.test.HelloImpl.
在web.xml 中加入
<servlet>
<servlet-name>remote</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>remote</servlet-name>
<url-pattern>/remote/*</url-pattern>
</servlet-mapping>
这段的意思是拦截到任何/remote/ 以下的URL 都交由remote servlet处理。(这个地方有需要注意的,稍后会写)
然后再在WEB-INF目录加入remote-servlet.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:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
<bean id="hessianService" class="org.dreamfly.core.test.HelloImpl"/>
<bean name="/hessian" class="org.springframework.remoting.caucho.HessianServiceExporter">
<property name="service" >
<ref bean="hessianService"></ref>
</property>
<property name="serviceInterface" >
<value>org.dreamfly.core.test.Hello</value>
</property>
</bean>
</beans>
接下来在任意一个spring的上下文中加入
<bean id="hessianProxy" class="org.springframework.remoting.caucho.HessianProxyFactoryBean">
<property name="serviceUrl">
<value>http://localhost:8080/shuzi/remote/hessian</value>
</property>
<property name="serviceInterface" value="org.dreamfly.core.test.Hessian"></property>
</bean>
注:http://localhost:8080/shuzi/remote/hessian中的shuzi是项目名。
这样就可以通过向任意一个bean中注入hessianProxy这个bean来实现远程调用了。
值得一提的是由于struts2也是通过拦截器作用的,我最开始的时候为了省事把struts2的拦截器配成了/*,这样远程调用的请求被struts2拦截了,就会提示找不到http://localhost:8080/shuzi/remote/hessian,解决的方法可以有把struts2的拦截器细化,具体到struts2 的namespace,这样只要struts2 的namespace和web.xml中的拦截器不重名就不会出现问题了。
- 在SSH中使用Hessian
- 在应用中使用 Hessian
- 在Spring中使用Hessian Remoting技术。
- 在Spring中使用Hessian Remoting技术
- 在Spring中使用Hessian Remoting技
- 在Spring中使用Hessian Remoting技术
- 在Spring中使用Hessian Remoting技术-------实例附件源码
- 在IIS7中配置Hessian
- hessian远程调用及spring中使用hessian
- 在Spring中集成Hessian框架
- 如何在Spring中集成Hessian框架
- 如何在Spring中集成Hessian框架
- Hessian技术在java中的使用
- 对使用Hessian协议调用在程序中应用的理解
- 在SSH框架中使用Validator框架
- log4j使用配置 在ssh中配置
- 在LoadRunner中使用SSH连接Linux
- log4j使用配置 在ssh中配置
- VS2008(VC6)出现如下链接错误的解决方法uafxcwd.lib(afxmem.obj) : error LNK2005: "void * __cdecl operator new(unsign
- 输入T-CODE执行DEBUG操作
- Context [] startup failed due to previous errors
- Android 签名详解
- IllegalArgumentException occurred while calling setter of
- 在SSH中使用Hessian
- 转的:Hibernate 的 Criteria用法
- c#控制输入法
- [转]Eclipse下tomcat输出路径配置
- hibernate 批量删除
- C语言基础知识
- 【web前端】折腾:瀑布流布局(基于多栏列表流体布局实现)
- 正则表达式
- SSL java