Magazine
 
Remoting with Spring

Spring features remoting support using various technologies. Remoting support eases the development of remote-enabled services, implemented with usual (Spring) POJOs. Currently, Spring supports different remoting technologies few of them are:

• Remote Method Invocation (RMI): Through the use of the RmiProxyFactoryBean and the RmiServiceExporter, Spring supports both traditional RMI (with java.rmi.Remote interfaces and java.rmi.RemoteException) and transparent remoting via RMI invokers (with any Java interface).

• Spring’s HTTP invoker: Spring provides a special remoting strategy which allows Java serialization via HTTP, supporting any Java interface (just like the RMI invoker). The corresponding support classes are HttpInvokerProxyFactoryBean and HttpInvokerServiceExporter.

• Hessian: By using the HessianProxyFactoryBean and the HessianServiceExporter, one can transparently expose his services using the lightweight binary HTTP-based protocol provided by Caucho.

• Burlap: Burlap is Caucho’s XML-based alternative for Hessian. Spring provides support classes such as BurlapProxyFactoryBean and BurlapServiceExporter.

• JAX RPC: Spring provides remoting support for web services via JAX-RPC.

• JMS: Remoting using JMS as the underlying protocol is supported via the JmsInvokerServiceExporter and JmsInvokerProxyFactoryBean classes.

In all these models, services are configured into the application through the spring configuration file known as spring managed beans.

 

This is accomplished by using a proxy factory bean that enables to wire remote services into the properties of our beans as if they were local objects.

Spring provides ‘RmiProxyFactoryBean’ to use the RMI service and ‘RmiServiceExporter’ to export any spring managed bean as a RMI service.

For wiring a Hessian based service to Spring client, Spring’s ‘HessianProxyFactoryBean’ is used. To export a Hessian Service ‘HessianServiceExporter’ is used and similarly for wiring a Burlap service ‘BurlapProxyFactoryBean’ is used and ‘BurlapServiceExporter’ is used to export a burlap service. Similarly, for exporting beans as HTTP invoker services, ‘HttpInvokerServiceExporter’ is used .To access an HTTP invoker service ‘HttpInvokerProxyFactoryBean’ can be used. Spring provides two proxy factory beans to access the Enterprise Java Beans. ‘LocalStatelessSessionProxyFactoryBean’ is used to access the EJB in the same container(local) and another one is ‘SimpleRemoteStatelessSessionProxy FactoryBean’ which is used to access the remote EJBs.

For all the above models spring provides service exporter classes that exports Java Beans as remote service.

Spring does not provide any EJB Service Exporter and it provides four abstract support classes to make the development of Spring enabled EJB. They are

1. AbstractMessageDrivenBean to develop MDBs that accept sources other than JMS.

2. AbstractJmsMessageDrivenBean to develop MDBs that accept messages from
JMS sources.

3. AbstractStatelessSessionBean to develop stateless session bean.

4. AbstractStstefulSessionBean to develop stateful session bean.

‘JaxRpcPostProxyFactoryBean’ is used to wire a web service into the spring application.

     
Oct 2007 | Java Jazz Up | 41
 
previous
index
next
 
Pages: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29,

30
, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53 , 54, 55, 56, 57,

58
, 59, 60, 61, 62, 63 , 64, 65 , 66 , 67 , 68 , 69 , 70, 71, 72, 73, 74, 75, 76, 77, 78,   Download PDF