Intro to Spring Remoting with HTTP Invokers (#964)

* First test with log4j rolling appenders

* small fix

* Log4j rolling appender

* First set up with rolling file on log4j 2

* Added logback code.

* log4j2 more detailed example

* log4j2 more detailed example

* Improved names and examples

* Fixed configurations

* improved configs

* formatted

* Final fix

* fixed formatting

* Formatting fix

* Fix sample apps to avoid try / catch

* Fix request to replace files

* Fix end lines

* Log4j2 logger is shot down at the end.

* Initial commit, the server starts launched from maven

* made room for client and server projects

* made room for client and server projects

* base example works

* poms restructured

* packages restructured

* packages restructured

* Some renaming and a proper formatting string

* Small renamings

* Small renamings

* Fixed invoked URL in client through fixing bean name
This commit is contained in:
Daniele Demichelis
2017-01-10 19:54:07 +01:00
committed by KevinGilmore
parent 6e9b667aef
commit a0de46efb9
17 changed files with 515 additions and 0 deletions
@@ -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">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.baeldung</groupId>
<artifactId>spring-remoting-http</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<artifactId>spring-remoting-http-client</artifactId>
<description>Shows how to invoke a remote service using Spring Remoting.</description>
<dependencies>
<!-- spring -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
</dependency>
<!-- companion modules -->
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>api</artifactId>
</dependency>
</dependencies>
</project>
@@ -0,0 +1,25 @@
package com.baeldug.client;
import com.baeldung.api.*;
public class CabBookingClient {
private CabBookingService cabService;
public CabBookingClient(CabBookingService cabService) {
this.cabService = cabService;
}
public void run() {
Address pickUp = new Address("13 Seagate Blvd, Key Largo, FL 33037", "US");
Address dropDown = new Address("91831 Overseas Hwy, Tavernier, FL 33070", "US");
try {
System.out.println( cabService.bookPickUp(pickUp, dropDown, 3) );
} catch (BookingException e) {
e.printStackTrace();
}
}
}
@@ -0,0 +1,34 @@
package com.baeldug.client;
import com.baeldung.api.CabBookingService;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.remoting.httpinvoker.HttpInvokerProxyFactoryBean;
@Configuration
public class Main {
@Bean
public HttpInvokerProxyFactoryBean invoker() {
HttpInvokerProxyFactoryBean invoker = new HttpInvokerProxyFactoryBean();
invoker.setServiceUrl("http://localhost:9090/spring-remoting-http-server/booking");
invoker.setServiceInterface(CabBookingService.class);
return invoker;
}
@Bean
public CabBookingClient client(CabBookingService service){
return new CabBookingClient(service);
}
public static void main(String[] args) throws InterruptedException {
AnnotationConfigApplicationContext rootContext =
new AnnotationConfigApplicationContext();
rootContext.scan(Main.class.getPackage().getName());
rootContext.refresh();
CabBookingClient bean = rootContext.getBean(CabBookingClient.class);
bean.run();
}
}