baeldung-articlesBAEL-553 Intro to Spring Remoting with HTTP Invokers (#1034)
* 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 * java.time.* instead of java.util.Date * java.time.* instead of java.util.Date * Removed log on file, kepts log on console * Updated Spring and Logback version to latest release. * Exception removed from run() * Code simplification. - Interfaces and objects simplified. - Spring Boot instead of plain Spring - No need for Tomcat plug in anymore. * Small updates to poms. * Unused classes removed. * Unused classes removed.
This commit is contained in:
committed by
KevinGilmore
parent
9220584528
commit
673faede4c
@@ -9,22 +9,22 @@
|
||||
<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>
|
||||
|
||||
<description>Shows how to invoke a remote service using Spring Remoting HTTP.</description>
|
||||
<dependencies>
|
||||
<!-- spring -->
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-web</artifactId>
|
||||
<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>
|
||||
|
||||
<!-- companion modules -->
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>api</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
-21
@@ -1,21 +0,0 @@
|
||||
package com.baeldug.client;
|
||||
|
||||
import com.baeldung.api.*;
|
||||
|
||||
public class CabBookingClient {
|
||||
|
||||
private CabBookingService cabService;
|
||||
|
||||
public CabBookingClient(CabBookingService cabService) {
|
||||
this.cabService = cabService;
|
||||
}
|
||||
|
||||
public void run() throws BookingException {
|
||||
|
||||
Address pickUp = new Address("13 Seagate Blvd, Key Largo, FL 33037", "US");
|
||||
Address dropDown = new Address("91831 Overseas Hwy, Tavernier, FL 33070", "US");
|
||||
System.out.println( cabService.bookPickUp(pickUp, dropDown, 3) );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.baeldug.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.httpinvoker.HttpInvokerProxyFactoryBean;
|
||||
|
||||
import static java.lang.System.out;
|
||||
|
||||
@Configuration
|
||||
public class Client {
|
||||
|
||||
@Bean
|
||||
public HttpInvokerProxyFactoryBean invoker() {
|
||||
HttpInvokerProxyFactoryBean invoker = new HttpInvokerProxyFactoryBean();
|
||||
invoker.setServiceUrl("http://localhost:8080/booking");
|
||||
invoker.setServiceInterface(CabBookingService.class);
|
||||
return invoker;
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws BookingException {
|
||||
CabBookingService service = SpringApplication.run(Client.class, args).getBean(CabBookingService.class);
|
||||
out.println(service.bookRide("13 Seagate Blvd, Key Largo, FL 33037"));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
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 Exception {
|
||||
AnnotationConfigApplicationContext rootContext =
|
||||
new AnnotationConfigApplicationContext();
|
||||
rootContext.scan(Main.class.getPackage().getName());
|
||||
rootContext.refresh();
|
||||
CabBookingClient bean = rootContext.getBean(CabBookingClient.class);
|
||||
bean.run();
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user