BAEL-554 Spring Remoting with Hessian and Burlap (#1166)

* Burlap & Hessian server added

* Burlap & Hessian client work

* Fixed main

* Fixed formatting
This commit is contained in:
Daniele Demichelis 2017-02-21 04:38:52 +01:00 committed by KevinGilmore
parent 3371c9047a
commit a75ed7e70a
7 changed files with 185 additions and 5 deletions

View File

@ -3,16 +3,17 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.baeldung</groupId>
<artifactId>spring-remoting</artifactId>
<packaging>pom</packaging>
<version>1.0-SNAPSHOT</version>
<name>spring-remoting</name>
<description>Parent for all projects related to Spring Remoting.</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.4.3.RELEASE</version>
</parent>
<groupId>com.baeldung</groupId>
<artifactId>spring-remoting</artifactId>
<version>1.0-SNAPSHOT</version>
<description>Parent for all projects related to Spring Remoting.</description>
<packaging>pom</packaging>
<properties>
<java.version>1.8</java.version>
@ -34,6 +35,7 @@
<modules>
<module>remoting-http</module>
<module>remoting-hessian-burlap</module>
</modules>
</project>

View File

@ -0,0 +1,35 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>remoting-hessian-burlap</artifactId>
<groupId>com.baeldung</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>spring-remoting-hessian-burlap-client</artifactId>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>api</artifactId>
</dependency>
<dependency>
<groupId>com.caucho</groupId>
<artifactId>hessian</artifactId>
<version>4.0.38</version>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,28 @@
package com.baeldung.client;
import com.baeldung.api.BookingException;
import com.baeldung.api.CabBookingService;
import org.springframework.boot.SpringApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.remoting.caucho.BurlapProxyFactoryBean;
import static java.lang.System.out;
@Configuration
public class BurlapClient {
@Bean
public BurlapProxyFactoryBean burlapInvoker() {
BurlapProxyFactoryBean invoker = new BurlapProxyFactoryBean();
invoker.setServiceUrl("http://localhost:8080/b_booking");
invoker.setServiceInterface(CabBookingService.class);
return invoker;
}
public static void main(String[] args) throws BookingException {
CabBookingService service = SpringApplication.run(BurlapClient.class, args).getBean(CabBookingService.class);
out.println(service.bookRide("13 Seagate Blvd, Key Largo, FL 33037"));
}
}

View File

@ -0,0 +1,28 @@
package com.baeldung.client;
import com.baeldung.api.BookingException;
import com.baeldung.api.CabBookingService;
import org.springframework.boot.SpringApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.remoting.caucho.HessianProxyFactoryBean;
import static java.lang.System.out;
@Configuration
public class HessianClient {
@Bean
public HessianProxyFactoryBean hessianInvoker() {
HessianProxyFactoryBean invoker = new HessianProxyFactoryBean();
invoker.setServiceUrl("http://localhost:8080/booking");
invoker.setServiceInterface(CabBookingService.class);
return invoker;
}
public static void main(String[] args) throws BookingException {
CabBookingService service = SpringApplication.run(HessianClient.class, args).getBean(CabBookingService.class);
out.println(service.bookRide("13 Seagate Blvd, Key Largo, FL 33037"));
}
}

View File

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>spring-remoting</artifactId>
<groupId>com.baeldung</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<packaging>pom</packaging>
<modules>
<module>server</module>
<module>client</module>
</modules>
<modelVersion>4.0.0</modelVersion>
<artifactId>remoting-hessian-burlap</artifactId>
</project>

View File

@ -0,0 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>remoting-hessian-burlap</artifactId>
<groupId>com.baeldung</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>remoting-hessian-burlap-server</artifactId>
<dependencies>
<dependency>
<groupId>com.baeldung</groupId>
<artifactId>spring-remoting-http-server</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>com.caucho</groupId>
<artifactId>hessian</artifactId>
<version>4.0.38</version>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,37 @@
package com.baeldung.server;
import com.baeldung.api.CabBookingService;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.remoting.caucho.BurlapServiceExporter;
import org.springframework.remoting.caucho.HessianServiceExporter;
import org.springframework.remoting.support.RemoteExporter;
@Configuration @ComponentScan @EnableAutoConfiguration public class Server {
@Bean CabBookingService bookingService() {
return new CabBookingServiceImpl();
}
@Bean(name = "/booking") RemoteExporter hessianService(CabBookingService service) {
HessianServiceExporter exporter = new HessianServiceExporter();
exporter.setService(bookingService());
exporter.setServiceInterface(CabBookingService.class);
return exporter;
}
@Bean(name = "/b_booking") RemoteExporter burlapService(CabBookingService service) {
BurlapServiceExporter exporter = new BurlapServiceExporter();
exporter.setService(bookingService());
exporter.setServiceInterface(CabBookingService.class);
return exporter;
}
public static void main(String[] args) {
SpringApplication.run(Server.class, args);
}
}