Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


advertisement
 

Spring and Hessian for Fast, Easy Java Remoting : Page 3

The Hessian binary web service protocol is a powerful and easy-to-use alternative to RMI, XML/SOAP, and REST/JSON for remote communication. Learn how to integrate Spring and Hessian and then create Hessian components as simple Java objects.


advertisement

Setting Up the Client

On the client side, you need to create an instance of a HessianProxyFactoryBean that points to your service URL:

<beans xmlns="http://www.springframework.org/schema/beans" xmlns:context="http://www.springframework.org/schema/context" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd"
> <context:annotation-config /> <context:component-scan base-package="com.devx.hessian.client" /> <bean id="personService" class="org.springframework.remoting.caucho.HessianProxyFactoryBean"> <property name="serviceUrl" value="http://0.0.0.0:8080/remoting/PersonService" /> <property name="serviceInterface" value="com.dexv.hessian.IPersonService" /> </bean> </beans>

When your service URL is defined, you can just inject the HessianProxyFactoryBean instance into your client application using regular dependency injection:

@Component("mainClient") public class MainClient { private IPersonService service = null; @Autowired public void setPersonService(@Qualifier("personService") IPersonService service) { this.service = service; } }

Spring 2.5 and Hessian 2 Incompatibility Alert

As of version 3.2.0, the Hessian library started using a new version of the protocol called simply Hessian 2. Unfortunately, the current production version of Spring (namely 2.5.6.SEC01) has support for the original Hessian protocol only. Therefore, if you are on Spring 2.5, the version of Hessian that you should download is 3.1.6.



Fortunately, this has been corrected in the latest milestone builds of Spring 3.0. The code samples attached to this article use the latest Hessian 4.0.1 and Spring 3.0 M4 builds.



Jacek Furmankiewicz is a Senior Java EE and Erlang/OTP developer at Radialpoint. He has 15 years of professional IT experience and is a Sun Certified Java Programmer (SCJP).
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap