Open In App

Remoting in Spring Framework

Last Updated : 31 Dec, 2022
Improve
Improve
Like Article
Like
Save
Share
Report

Spring has integration classes for remoting support that use a variety of technologies. The Spring framework simplifies the development of remote-enabled services. It saves a significant amount of code by having its own API. The remote support simplifies the building of remote-enabled services, which are implemented by your standard (Spring) POJOs. Spring now supports the following remoting technologies:

  1. Remote Method Invocation (RMI)
  2. Hessian
  3. Burlap
  4. Spring’s HTTP invoker
  5. JAX-RPC 
  6. JAX-WS
  7. JMS

1. Exposing services using RMI

You may transparently expose your services across the RMI infrastructure by using Spring’s RMI support. After you’ve done this, you’ll have a setup that’s similar to remote EJBs, except there’s no standard support for security context propagation or remote transaction propagation. When utilizing the RMI invoker, Spring provides hooks for such extra invocation context, so you may, for example, plug-in security frameworks or custom security credentials.

  • Using the RmiServiceExporter to export the service.
  • Client-side service integration.

To know more refer to this article: Remote Method Invocation in Java

2. Using Hessian to call services remotely through HTTP

Spring has its own remoting service that supports HTTP serialization. HTTP Invoker makes use of the classes HttpInvokerServiceExporter and HttpInvokerProxyFactoryBean.

  • Configuring the DispatcherServlet for Hessian and company.
  • Using the HessianServiceExporter to expose your beans
  • Connecting the client to the service

To know more refer to this article: Spring – Remoting By Hessian

3. Using Burlap

It is the same as Hessian but XML-based implementation provided by Coucho. The classes used in Burlap are BurlapServiceExporter and BurlapProxyFactoryBean.

To know more refer to this article: Spring – Remoting By Burlap

4. Using HTTP invokers to expose services

Spring HTTP invokers employ the regular Java serialization technique to expose services through HTTP, as opposed to Burlap and Hessian, which are both lightweight protocols with their own compact serialization mechanisms. This is especially useful if your arguments and return types are complicated and cannot be serialized using the serialization procedures used by Hessian and Burlap (refer to the next section for more considerations when choosing a remoting technology).

  • Displaying the service object
  • Client-side service integration

5. Exposing servlet-based web services using JAX-RPC

Spring provides a convenience base class for JAX-RPC servlet endpoint implementations – ServletEndpointSupport. To expose our AccountService we extend Spring’s ServletEndpointSupport class and implement our business logic here, usually delegating the call to the business layer.

  • Using JAX-RPC to gain access to online services
  • JAX-RPC Bean Mappings Registration
  • Adding your own JAX-RPC Handler 

6. Using JAX-WS to provide servlet-based web services

SpringBeanAutowiringSupport is a useful basic class for JAX-WS servlet endpoint implementations. We modify Spring’s SpringBeanAutowiringSupport class to expose our AccountService and execute our business logic here, generally outsourcing the request to the business layer.

7. JMS

Using JMS as the underlying communication protocol, it is also feasible to provide services transparently. The Spring Framework’s JMS remoting functionality is fairly minimal – it transmits and receives on the same thread and in the same non-transactional Session, thus performance will be very implementation dependant. It’s worth noting that these single-threaded and non-transactional restrictions only apply to Spring’s JMS remoting functionality. Spring’s extensive support for JMS-based messaging is covered in Chapter 23, JMS (Java Message Service).

To know more refer to this article: Spring – JMS Integration


Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads