Use Hessian in SSH

Source: Internet
Author: User
Use Hessian in SSH

17:10:13| Category:Remote Call
| Tag:SSH Hessian interceptor|Font SizeLargeMediumSmall Subscription

I personally feel that using Hessian can solve some network applications with relatively simple business logic and a small number of nodes that require remote calls. However, when the number increases and the logic is responsible, especially when each node can call each other, it is a little troublesome.

The Hessian version used in the SSH structure is preferably the built-in spring version, usually under the LIB/Caucho directory. First, assume that the service we want to remotely call is hello, which is located at Org. dreamfly. core. test. hello. its implementation class is helloimpl, located at Org. dreamfly. core. test. helloimpl. in the web. add <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-m Apping> This section means that the remote servlet processes all URLs intercepted at any or below the remote/path. (This place has to note, will be written later) and then add the WEB-INF in the remote-servlet.xml directory. <? 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> Add <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> Note: Ht In TP: // localhost: 8080/shuzi/remote/Hessian, shuzi is the project name. In this way, you can remotely call the bean by injecting hessianproxy to any bean. It is worth mentioning that struts2 also uses an interceptor. In the first place, I allocated the struts2 Interceptor to/* For convenience, so that the Remote Call request was intercepted by struts2, the system will prompt that http: // localhost: 8080/shuzi/remote/Hessian is not found. The solution can be to refine the struts2 Interceptor to the namespace of struts2, in this way, only the namespace and web. if the interceptor in XML does not have a duplicate name, the problem will not occur.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.