Open In App
Related Articles

Spring – Remoting By Burlap

Improve Article
Save Article
Like Article

Coucho can provide both Hessian and Burlap. Burlap is an xml-based Hessian substitute. We may use the BurlapServiceExporter and BurlapProxyFactoryBean classes to implement burlap’s remoting service.

Implementation: You need to create the following files for creating a simple burlap application:

  3. web.xml
  4. burlap-servlet.xml
  5. client-beans.xml

The project structure will look as follows: 

A. File:


// Java Program to illustrate Simple Interface
// Containing a Method
package com.geeksforgeeks;
// Interface
public interface Calculation {
    int cube(int number);

B. File:


// Java Program to Implement Calculation Interface
package com.geeksforgeeks;
// Class
// Implementing interface
public class CalculationImpl implements Calculation {
    // Method
    public int cube(int number)
        // Returning cube of a number
        return number * number * number;

C. File: web.xml

The front controller is defined in this XML file called DispatcherServlet. Any request that ends in.http will be routed to DispatcherServlet.


<?xml version="1.0" encoding="UTF-8"?>

D. File: burlap-servlet.xml

It has to be placed in the WEB-INF folder. It must be called servletname-servlet.xml. It specifies CalculationImpl and BurlapServiceExporter as beans.


<?xml version="1.0" encoding="UTF-8"?>
    <bean id="calculationBean"
    <bean name="/Calculation.http" class="org.springframework.remoting.caucho.BurlapServiceExporter">
        <property name="service" ref="calculationBean"></property>
        <property name="serviceInterface" value="com.geeksforgeeks.Calculation"></property>

E. File: client-beans.xml

The bean for BurlapProxyFactoryBean is defined in this XML file. This class requires two attributes to be defined.

  1. serviceUrl
  2. serviceInterface


<?xml version="1.0" encoding="UTF-8"?>
    <bean id="calculationBean" class="org.springframework.remoting.caucho.BurlapProxyFactoryBean">
        <property name="serviceUrl" value="http://localhost:8888/burlap/Calculation.http"></property>
        <property name="serviceInterface" value="com.geeksforgeeks.Calculation"></property>

F. File:

This class gets the instance of Calculation and calls the cube method.


// Java Program to Illustrate Client Class
package com.geeksforgeeks;
// Importing required classes
import org.springframework.context.ApplicationContext;
// Class
public class Client {
    // Main driver method
    public static void main(String[] args)
        // Creating an object of ApplicationContext class
        ApplicationContext context
            = new ClassPathXmlApplicationContext(
        Calculation calculation
            = (Calculation)context.getBean(
        // Printing cube of a random number



Note: In order to run the above code fragment to get the output:

  • Start and deploy the project, assuming that the server is listening on port 8888. Change the serviceURL in client-beans.xml if the port number is changed.
  • The file should then be compiled and run.

Feeling lost in the vast world of Backend Development? It's time for a change! Join our Java Backend Development - Live Course and embark on an exciting journey to master backend development efficiently and on schedule.
What We Offer:
  • Comprehensive Course
  • Expert Guidance for Efficient Learning
  • Hands-on Experience with Real-world Projects
  • Proven Track Record with 100,000+ Successful Geeks

Last Updated : 24 Mar, 2022
Like Article
Save Article
Similar Reads
Complete Tutorials