About the test, we update String Vowel Test
This commit is contained in:
parent
50c63df0e8
commit
40d63b97f5
|
@ -0,0 +1,10 @@
|
|||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
# Editor-based HTTP Client requests
|
||||
/httpRequests/
|
||||
# Datasource local storage ignored files
|
||||
/dataSources/
|
||||
/dataSources.local.xml
|
||||
# Zeppelin ignored files
|
||||
/ZeppelinRemoteNotebooks/
|
|
@ -0,0 +1,16 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="CheckStyle-IDEA" serialisationVersion="2">
|
||||
<checkstyleVersion>10.12.2</checkstyleVersion>
|
||||
<scanScope>JavaOnly</scanScope>
|
||||
<copyLibs>true</copyLibs>
|
||||
<option name="thirdPartyClasspath" />
|
||||
<option name="activeLocationIds" />
|
||||
<option name="locations">
|
||||
<list>
|
||||
<ConfigurationLocation id="bundled-sun-checks" type="BUNDLED" scope="All" description="Sun Checks">(bundled)</ConfigurationLocation>
|
||||
<ConfigurationLocation id="bundled-google-checks" type="BUNDLED" scope="All" description="Google Checks">(bundled)</ConfigurationLocation>
|
||||
</list>
|
||||
</option>
|
||||
</component>
|
||||
</project>
|
|
@ -0,0 +1,17 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="CompilerConfiguration">
|
||||
<annotationProcessing>
|
||||
<profile name="Maven default annotation processors profile" enabled="true">
|
||||
<sourceOutputDir name="target/generated-sources/annotations" />
|
||||
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
|
||||
<outputRelativeToContentRoot value="true" />
|
||||
<module name="remoting-jms-server" />
|
||||
<module name="remoting-http-server" />
|
||||
<module name="remoting-http-api" />
|
||||
<module name="remoting-http-client" />
|
||||
<module name="remoting-jms-client" />
|
||||
</profile>
|
||||
</annotationProcessing>
|
||||
</component>
|
||||
</project>
|
|
@ -0,0 +1,21 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Encoding">
|
||||
<file url="file://$PROJECT_DIR$/remoting-http/remoting-http-api/src/main/java" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/remoting-http/remoting-http-api/src/main/resources" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/remoting-http/remoting-http-client/src/main/java" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/remoting-http/remoting-http-client/src/main/resources" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/remoting-http/remoting-http-server/src/main/java" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/remoting-http/remoting-http-server/src/main/resources" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/remoting-http/src/main/java" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/remoting-http/src/main/resources" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/remoting-jms/remoting-jms-client/src/main/java" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/remoting-jms/remoting-jms-client/src/main/resources" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/remoting-jms/remoting-jms-server/src/main/java" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/remoting-jms/remoting-jms-server/src/main/resources" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/remoting-jms/src/main/java" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/remoting-jms/src/main/resources" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/src/main/java" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/src/main/resources" charset="UTF-8" />
|
||||
</component>
|
||||
</project>
|
|
@ -0,0 +1,30 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="RemoteRepositoriesConfiguration">
|
||||
<remote-repository>
|
||||
<option name="id" value="ossez-repo-snapshots" />
|
||||
<option name="name" value="OSSEZ Private Snapshots" />
|
||||
<option name="url" value="https://repo.ossez.com/repository/maven-snapshots/" />
|
||||
</remote-repository>
|
||||
<remote-repository>
|
||||
<option name="id" value="ossez-repo-releases" />
|
||||
<option name="name" value="OSSEZ Private Releases" />
|
||||
<option name="url" value="https://repo.ossez.com/repository/maven-releases/" />
|
||||
</remote-repository>
|
||||
<remote-repository>
|
||||
<option name="id" value="central" />
|
||||
<option name="name" value="Central Repository" />
|
||||
<option name="url" value="https://repo.ossez.com/repository/maven-public/" />
|
||||
</remote-repository>
|
||||
<remote-repository>
|
||||
<option name="id" value="central" />
|
||||
<option name="name" value="Maven Central repository" />
|
||||
<option name="url" value="https://repo1.maven.org/maven2" />
|
||||
</remote-repository>
|
||||
<remote-repository>
|
||||
<option name="id" value="jboss.community" />
|
||||
<option name="name" value="JBoss Community repository" />
|
||||
<option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" />
|
||||
</remote-repository>
|
||||
</component>
|
||||
</project>
|
|
@ -0,0 +1,7 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="JpaBuddyIdeaProjectConfig">
|
||||
<option name="defaultUnitInitialized" value="true" />
|
||||
<option name="renamerInitialized" value="true" />
|
||||
</component>
|
||||
</project>
|
|
@ -0,0 +1,18 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||
<component name="MavenProjectsManager">
|
||||
<option name="originalFiles">
|
||||
<list>
|
||||
<option value="$PROJECT_DIR$/pom.xml" />
|
||||
</list>
|
||||
</option>
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="temurin-17" project-jdk-type="JavaSDK" />
|
||||
<component name="ProjectType">
|
||||
<option name="id" value="jpab" />
|
||||
</component>
|
||||
<component name="ThriftCompiler">
|
||||
<compilers />
|
||||
</component>
|
||||
</project>
|
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$/.." vcs="Git" />
|
||||
</component>
|
||||
</project>
|
|
@ -0,0 +1,13 @@
|
|||
## Spring Remoting
|
||||
|
||||
This module contains articles about Spring Remoting
|
||||
|
||||
|
||||
### Overview
|
||||
This Maven project contains the Java source code for various modules used in the Spring Remoting series of articles.
|
||||
|
||||
### Building the Project
|
||||
You can build the project using Maven inside your IDE or from the command line:
|
||||
```
|
||||
mvn clean install
|
||||
```
|
|
@ -0,0 +1,58 @@
|
|||
<?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>
|
||||
<artifactId>spring-remoting-modules</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<name>spring-remoting-modules</name>
|
||||
<packaging>pom</packaging>
|
||||
<description>Parent for all projects related to Spring Remoting, except remoting-hessian-burlap</description>
|
||||
<!-- remoting-hessian-burlap needs to stick to spring-boot-1, -->
|
||||
<!-- some classes were removed in spring 5 -->
|
||||
|
||||
<parent>
|
||||
<groupId>com.ossez</groupId>
|
||||
<artifactId>parent-boot-2</artifactId>
|
||||
<version>0.0.2-SNAPSHOT</version>
|
||||
<relativePath>parent-boot-2</relativePath>
|
||||
</parent>
|
||||
|
||||
<modules>
|
||||
<!-- <module>remoting-hessian-burlap</module>-->
|
||||
<module>remoting-http</module>
|
||||
<!-- <module>remoting-amqp</module>-->
|
||||
<module>remoting-jms</module>
|
||||
<!-- <module>remoting-rmi</module>-->
|
||||
</modules>
|
||||
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<!-- companion modules -->
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>api</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>${maven-compiler-plugin.version}</version>
|
||||
<configuration>
|
||||
<source>${maven.compiler.source}</source>
|
||||
<target>${maven.compiler.target}</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<properties>
|
||||
<maven.compiler.source>11</maven.compiler.source>
|
||||
<maven.compiler.target>11</maven.compiler.target>
|
||||
</properties>
|
||||
|
||||
</project>
|
|
@ -0,0 +1,3 @@
|
|||
### Relevant Articles
|
||||
|
||||
- [Spring Remoting with AMQP](https://www.baeldung.com/spring-remoting-amqp)
|
|
@ -0,0 +1,21 @@
|
|||
<?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>
|
||||
<artifactId>remoting-amqp</artifactId>
|
||||
<name>remoting-amqp</name>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
<parent>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<artifactId>spring-remoting-modules</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<modules>
|
||||
<module>remoting-amqp-server</module>
|
||||
<module>remoting-amqp-client</module>
|
||||
</modules>
|
||||
|
||||
</project>
|
|
@ -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">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>remoting-amqp-client</artifactId>
|
||||
<name>remoting-amqp-client</name>
|
||||
<packaging>jar</packaging>
|
||||
<url>http://maven.apache.org</url>
|
||||
|
||||
<parent>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<artifactId>remoting-amqp</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-amqp</artifactId>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-tomcat</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<artifactId>remoting-http-api</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
|
@ -0,0 +1,46 @@
|
|||
package com.baeldung.client;
|
||||
|
||||
import com.baeldung.api.BookingException;
|
||||
import com.baeldung.api.CabBookingService;
|
||||
import org.springframework.amqp.core.*;
|
||||
import org.springframework.amqp.rabbit.connection.ConnectionFactory;
|
||||
import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
||||
import org.springframework.amqp.remoting.client.AmqpProxyFactoryBean;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
|
||||
import static java.lang.System.out;
|
||||
|
||||
@SpringBootApplication public class AmqpClient {
|
||||
|
||||
@Bean Queue queue() {
|
||||
return new Queue("remotingQueue");
|
||||
}
|
||||
|
||||
@Bean AmqpProxyFactoryBean amqpFactoryBean(AmqpTemplate amqpTemplate) {
|
||||
AmqpProxyFactoryBean factoryBean = new AmqpProxyFactoryBean();
|
||||
factoryBean.setServiceInterface(CabBookingService.class);
|
||||
factoryBean.setAmqpTemplate(amqpTemplate);
|
||||
return factoryBean;
|
||||
}
|
||||
|
||||
@Bean Exchange directExchange(Queue someQueue) {
|
||||
DirectExchange exchange = new DirectExchange("remoting.exchange");
|
||||
BindingBuilder.bind(someQueue).to(exchange).with("remoting.binding");
|
||||
return exchange;
|
||||
}
|
||||
|
||||
@Bean RabbitTemplate amqpTemplate(ConnectionFactory factory) {
|
||||
RabbitTemplate template = new RabbitTemplate(factory);
|
||||
template.setRoutingKey("remoting.binding");
|
||||
template.setExchange("remoting.exchange");
|
||||
return template;
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws BookingException {
|
||||
CabBookingService service = SpringApplication.run(AmqpClient.class, args).getBean(CabBookingService.class);
|
||||
out.println(service.bookRide("13 Seagate Blvd, Key Largo, FL 33037"));
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
# This is true to make SpringBoot to automatically register a bean of type 'org.springframework.amqp.core.AmqpAdmin'.
|
||||
# Check the org.springframework.boot.autoconfigure.amqp.RabbitAutoConfiguration javadoc for details.
|
||||
spring.rabbitmq.dynamic=true
|
||||
|
||||
# The port to which the client should connect defaults to 5672.
|
||||
spring.rabbitmq.port=32769
|
||||
|
||||
# Username and password
|
||||
spring.rabbitmq.username=guest
|
||||
spring.rabbitmq.password=guest
|
||||
|
||||
# The host, defaults to localhost.
|
||||
spring.rabbitmq.host=192.168.99.100
|
||||
|
||||
# Logging
|
||||
logging.pattern.console=%d{mm:ss.SSS} %-5p [%-31t] [%-54logger{0}] %marker%m%ex{full} - %logger - %F:%L%n
|
||||
logging.level.root=WARN
|
||||
logging.level.org.springframework.amqp=TRACE
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configuration>
|
||||
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<encoder>
|
||||
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
|
||||
</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<root level="INFO">
|
||||
<appender-ref ref="STDOUT" />
|
||||
</root>
|
||||
</configuration>
|
|
@ -0,0 +1,17 @@
|
|||
package org.baeldung;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import com.baeldung.client.AmqpClient;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(classes = AmqpClient.class)
|
||||
public class SpringContextTest {
|
||||
|
||||
@Test
|
||||
public void whenSpringContextIsBootstrapped_thenNoExceptions() {
|
||||
}
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
<?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>
|
||||
<artifactId>remoting-amqp-server</artifactId>
|
||||
<name>remoting-amqp-server</name>
|
||||
<packaging>jar</packaging>
|
||||
<url>http://maven.apache.org</url>
|
||||
|
||||
<parent>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<artifactId>remoting-amqp</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<artifactId>remoting-http-api</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-amqp</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<artifactId>remoting-http-server</artifactId>
|
||||
<version>${remoting-http-server.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<properties>
|
||||
<remoting-http-server.version>1.0-SNAPSHOT</remoting-http-server.version>
|
||||
</properties>
|
||||
|
||||
</project>
|
|
@ -0,0 +1,53 @@
|
|||
package com.baeldung.server;
|
||||
|
||||
import com.baeldung.api.CabBookingService;
|
||||
import org.springframework.amqp.core.AmqpTemplate;
|
||||
import org.springframework.amqp.core.Queue;
|
||||
import org.springframework.amqp.rabbit.connection.ConnectionFactory;
|
||||
import org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer;
|
||||
import org.springframework.amqp.remoting.service.AmqpInvokerServiceExporter;
|
||||
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;
|
||||
|
||||
@Configuration @ComponentScan @EnableAutoConfiguration
|
||||
public class AmqpServer {
|
||||
|
||||
/*
|
||||
Please note that
|
||||
- CachingConnectionFactory
|
||||
- RabbitAdmin
|
||||
- AmqpTemplate
|
||||
are automatically declared by SpringBoot.
|
||||
*/
|
||||
|
||||
@Bean CabBookingService bookingService() {
|
||||
return new CabBookingServiceImpl();
|
||||
}
|
||||
|
||||
@Bean Queue queue() {
|
||||
return new Queue("remotingQueue");
|
||||
}
|
||||
|
||||
@Bean AmqpInvokerServiceExporter exporter(CabBookingService implementation, AmqpTemplate template) {
|
||||
AmqpInvokerServiceExporter exporter = new AmqpInvokerServiceExporter();
|
||||
exporter.setServiceInterface(CabBookingService.class);
|
||||
exporter.setService(implementation);
|
||||
exporter.setAmqpTemplate(template);
|
||||
return exporter;
|
||||
}
|
||||
|
||||
@Bean SimpleMessageListenerContainer listener(ConnectionFactory factory, AmqpInvokerServiceExporter exporter, Queue queue) {
|
||||
SimpleMessageListenerContainer container = new SimpleMessageListenerContainer(factory);
|
||||
container.setMessageListener(exporter);
|
||||
container.setQueueNames(queue.getName());
|
||||
return container;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(AmqpServer.class, args);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
# This is true to make SpringBoot to automatically register a bean of type 'org.springframework.amqp.core.AmqpAdmin'.
|
||||
# Check the org.springframework.boot.autoconfigure.amqp.RabbitAutoConfiguration javadoc for details.
|
||||
spring.rabbitmq.dynamic=true
|
||||
|
||||
# The port to which the client should connect defaults to 5672.
|
||||
spring.rabbitmq.port=32769
|
||||
|
||||
# Username and password
|
||||
spring.rabbitmq.username=guest
|
||||
spring.rabbitmq.password=guest
|
||||
|
||||
# The host, defaults to localhost.
|
||||
spring.rabbitmq.host=192.168.99.100
|
||||
|
||||
# Logging
|
||||
logging.pattern.console=%d{mm:ss.SSS} %-5p [%-31t] [%-54logger{0}] %marker%m%ex{full} - %logger - %F:%L%n
|
||||
logging.level.root=WARN
|
||||
logging.level.org.springframework.amqp=TRACE
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configuration>
|
||||
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<encoder>
|
||||
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
|
||||
</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<root level="INFO">
|
||||
<appender-ref ref="STDOUT" />
|
||||
</root>
|
||||
</configuration>
|
|
@ -0,0 +1,17 @@
|
|||
package org.baeldung;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import com.baeldung.server.AmqpServer;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(classes = AmqpServer.class)
|
||||
public class SpringContextManualTest {
|
||||
|
||||
@Test
|
||||
public void whenSpringContextIsBootstrapped_thenNoExceptions() {
|
||||
}
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
## Spring Remoting with Hessian and Burlap
|
||||
|
||||
This module contains articles about Spring Remoting with Hessian and Burlap
|
||||
|
||||
### Relevant Articles
|
||||
|
||||
- [Spring Remoting with Hessian and Burlap](http://www.baeldung.com/spring-remoting-hessian-burlap)
|
||||
|
||||
### Overview
|
||||
This Maven project contains the Java source code for the Hessian and Burlap modules
|
||||
used in the [Spring Remoting](https://github.com/eugenp/tutorials/tree/master/spring-remoting)
|
||||
series of articles.
|
|
@ -0,0 +1,24 @@
|
|||
<?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>
|
||||
<artifactId>remoting-hessian-burlap</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<name>remoting-hessian-burlap</name>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
<parent>
|
||||
<!-- uses legacy spring, cannot upgrade to boot-2 -->
|
||||
<groupId>com.baeldung</groupId>
|
||||
<artifactId>parent-boot-1</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<relativePath>../../parent-boot-1</relativePath>
|
||||
</parent>
|
||||
|
||||
<modules>
|
||||
<module>remoting-hessian-burlap-server</module>
|
||||
<module>remoting-hessian-burlap-client</module>
|
||||
</modules>
|
||||
|
||||
</project>
|
|
@ -0,0 +1,79 @@
|
|||
<?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>
|
||||
<artifactId>remoting-hessian-burlap-client</artifactId>
|
||||
<name>remoting-hessian-burlap-client</name>
|
||||
|
||||
<parent>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<artifactId>remoting-hessian-burlap</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<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>remoting-http-api</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.caucho</groupId>
|
||||
<artifactId>hessian</artifactId>
|
||||
<version>${hessian.version}</version>
|
||||
</dependency>
|
||||
<!-- test -->
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>remoting-hessian-burlap-server</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.servlet</groupId>
|
||||
<artifactId>javax.servlet-api</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-tomcat</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<!-- test -->
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<configuration>
|
||||
<argLine>
|
||||
--add-opens java.base/java.lang=ALL-UNNAMED
|
||||
</argLine>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<properties>
|
||||
<hessian.version>4.0.38</hessian.version>
|
||||
</properties>
|
||||
|
||||
</project>
|
|
@ -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:8032/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"));
|
||||
}
|
||||
|
||||
}
|
|
@ -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:8032/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"));
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configuration>
|
||||
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<encoder>
|
||||
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
|
||||
</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<root level="INFO">
|
||||
<appender-ref ref="STDOUT" />
|
||||
</root>
|
||||
</configuration>
|
|
@ -0,0 +1,74 @@
|
|||
package com.baeldung.client;
|
||||
|
||||
import com.baeldung.api.Booking;
|
||||
import com.baeldung.api.BookingException;
|
||||
import com.baeldung.api.CabBookingService;
|
||||
import com.baeldung.server.Server;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import static java.lang.Thread.sleep;
|
||||
|
||||
@SpringBootTest(classes = {BurlapClient.class, HessianClient.class})
|
||||
@RunWith(SpringRunner.class)
|
||||
public class CabBookingServiceIntegrationTest {
|
||||
|
||||
static Logger log = LoggerFactory.getLogger(CabBookingServiceIntegrationTest.class);
|
||||
@Autowired @Qualifier("burlapInvoker") CabBookingService burlapClient;
|
||||
@Autowired @Qualifier("hessianInvoker") CabBookingService hessianClient;
|
||||
static Thread serverThread;
|
||||
|
||||
@BeforeClass
|
||||
public static void startServer() throws InterruptedException {
|
||||
serverThread = serverThread();
|
||||
log.info("Starting server.");
|
||||
serverThread.start();
|
||||
// increase this enough to let the server start
|
||||
sleep(6000);
|
||||
}
|
||||
|
||||
@org.junit.Test
|
||||
public void bookACabWithBurlapClient() throws InterruptedException {
|
||||
bookACab(this.burlapClient);
|
||||
}
|
||||
|
||||
@org.junit.Test
|
||||
public void bookACabWithHessianClient() throws InterruptedException {
|
||||
bookACab(this.hessianClient);
|
||||
}
|
||||
|
||||
private void bookACab(CabBookingService burlapClient) {
|
||||
Booking booking;
|
||||
try {
|
||||
booking = burlapClient.bookRide("Duomo place");
|
||||
log.info("Booking success: {}", booking);
|
||||
} catch (BookingException e) {
|
||||
log.info("Booking failed: {}", e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void stopServer() throws InterruptedException {
|
||||
serverThread.interrupt();
|
||||
serverThread.join();
|
||||
log.info("Server terminated.");
|
||||
}
|
||||
|
||||
static Thread serverThread() {
|
||||
Thread serverThread = new Thread(()-> {
|
||||
log.info("Starting Burlap and Hessian server");
|
||||
Server.main(new String[]{});
|
||||
log.info("Burlap and Hessian server terminated");
|
||||
});
|
||||
serverThread.setDaemon(true);
|
||||
return serverThread;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
package org.baeldung;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import com.baeldung.client.BurlapClient;
|
||||
import com.baeldung.client.HessianClient;
|
||||
|
||||
@SpringBootTest(classes = {BurlapClient.class, HessianClient.class})
|
||||
@RunWith(SpringRunner.class)
|
||||
public class SpringContextTest {
|
||||
|
||||
@Test
|
||||
public void whenSpringContextIsBootstrapped_thenNoExceptions() {
|
||||
}
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
application.properties=9999
|
|
@ -0,0 +1,50 @@
|
|||
<?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>
|
||||
<artifactId>remoting-hessian-burlap-server</artifactId>
|
||||
<name>remoting-hessian-burlap-server</name>
|
||||
|
||||
<parent>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<artifactId>remoting-hessian-burlap</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<artifactId>remoting-http-server</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.caucho</groupId>
|
||||
<artifactId>hessian</artifactId>
|
||||
<version>${hessian.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<configuration>
|
||||
<argLine>
|
||||
--add-opens java.base/java.lang=ALL-UNNAMED
|
||||
</argLine>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<properties>
|
||||
<hessian.version>4.0.38</hessian.version>
|
||||
</properties>
|
||||
|
||||
</project>
|
|
@ -0,0 +1,41 @@
|
|||
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;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
@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 app = new SpringApplication(Server.class);
|
||||
app.setDefaultProperties(Collections.singletonMap("server.port", "8032"));
|
||||
app.run(args);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configuration>
|
||||
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<encoder>
|
||||
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
|
||||
</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<root level="INFO">
|
||||
<appender-ref ref="STDOUT" />
|
||||
</root>
|
||||
</configuration>
|
|
@ -0,0 +1,17 @@
|
|||
package org.baeldung;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import com.baeldung.server.Server;
|
||||
|
||||
@SpringBootTest(classes = Server.class)
|
||||
@RunWith(SpringRunner.class)
|
||||
public class SpringContextTest {
|
||||
|
||||
@Test
|
||||
public void whenSpringContextIsBootstrapped_thenNoExceptions() {
|
||||
}
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
## Remoting HTTP
|
||||
|
||||
This module contains articles about Spring Remoting over HTTP
|
||||
|
||||
### Relevant Articles:
|
||||
|
||||
- [Intro to Spring Remoting with HTTP Invokers](https://www.baeldung.com/spring-remoting-http-invoker)
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
<?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>
|
||||
<artifactId>remoting-http</artifactId>
|
||||
<name>remoting-http</name>
|
||||
<packaging>pom</packaging>
|
||||
<description>Parent for all modules related to HTTP Spring Remoting.</description>
|
||||
|
||||
<parent>
|
||||
<groupId>com.ossez</groupId>
|
||||
<artifactId>spring-remoting-modules</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<modules>
|
||||
<module>remoting-http-server</module>
|
||||
<module>remoting-http-client</module>
|
||||
<module>remoting-http-api</module>
|
||||
</modules>
|
||||
|
||||
</project>
|
|
@ -0,0 +1,16 @@
|
|||
<?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>
|
||||
<artifactId>remoting-http-api</artifactId>
|
||||
<name>remoting-http-api</name>
|
||||
<description>API definition shared between client and server.</description>
|
||||
|
||||
<parent>
|
||||
<groupId>com.ossez</groupId>
|
||||
<artifactId>remoting-http</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
</project>
|
|
@ -0,0 +1,17 @@
|
|||
package com.baeldung.api;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import static java.lang.String.format;
|
||||
|
||||
public class Booking implements Serializable {
|
||||
private String bookingCode;
|
||||
|
||||
@Override public String toString() {
|
||||
return format("Ride confirmed: code '%s'.", bookingCode);
|
||||
}
|
||||
|
||||
public Booking(String bookingCode) {
|
||||
this.bookingCode = bookingCode;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
package com.baeldung.api;
|
||||
|
||||
public class BookingException extends Exception {
|
||||
public BookingException(String message) {
|
||||
super(message);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
package com.baeldung.api;
|
||||
|
||||
public interface CabBookingService {
|
||||
Booking bookRide(String pickUpLocation) throws BookingException;
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
<?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>
|
||||
<artifactId>remoting-http-client</artifactId>
|
||||
<name>remoting-http-client</name>
|
||||
<description>Shows how to invoke a remote service using Spring Remoting HTTP.</description>
|
||||
|
||||
<parent>
|
||||
<groupId>com.ossez</groupId>
|
||||
<artifactId>remoting-http</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<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>remoting-http-api</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
|
@ -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"));
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configuration>
|
||||
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<encoder>
|
||||
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
|
||||
</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<root level="INFO">
|
||||
<appender-ref ref="STDOUT" />
|
||||
</root>
|
||||
</configuration>
|
|
@ -0,0 +1,28 @@
|
|||
<?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>
|
||||
<artifactId>remoting-http-server</artifactId>
|
||||
<name>remoting-http-server</name>
|
||||
<description>Shows how to expose a service using Spring Remoting HTTP.</description>
|
||||
|
||||
<parent>
|
||||
<groupId>com.ossez</groupId>
|
||||
<artifactId>remoting-http</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>remoting-http-api</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
|
@ -0,0 +1,12 @@
|
|||
Build and launch with the following command.
|
||||
|
||||
mvn clean package tomcat7:run-war
|
||||
|
||||
Exposed service is available at following URL.
|
||||
|
||||
http://localhost:9090/spring-remoting-http-server/account
|
||||
|
||||
## References
|
||||
|
||||
<http://docs.spring.io/spring/docs/current/spring-framework-reference/htmlsingle/#remoting-httpinvoker>
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
package com.baeldung.server;
|
||||
|
||||
import com.baeldung.api.Booking;
|
||||
import com.baeldung.api.BookingException;
|
||||
import com.baeldung.api.CabBookingService;
|
||||
|
||||
import static java.lang.Math.random;
|
||||
import static java.util.UUID.randomUUID;
|
||||
|
||||
public class CabBookingServiceImpl implements CabBookingService {
|
||||
|
||||
@Override public Booking bookRide(String pickUpLocation) throws BookingException {
|
||||
if (random() < 0.3) throw new BookingException("Cab unavailable");
|
||||
return new Booking(randomUUID().toString());
|
||||
}
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
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.httpinvoker.HttpInvokerServiceExporter;
|
||||
|
||||
@Configuration
|
||||
@ComponentScan
|
||||
@EnableAutoConfiguration
|
||||
public class Server {
|
||||
|
||||
@Bean(name = "/booking") HttpInvokerServiceExporter accountService() {
|
||||
HttpInvokerServiceExporter exporter = new HttpInvokerServiceExporter();
|
||||
exporter.setService( new CabBookingServiceImpl() );
|
||||
exporter.setServiceInterface( CabBookingService.class );
|
||||
return exporter;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(Server.class, args);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configuration>
|
||||
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<encoder>
|
||||
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
|
||||
</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<root level="INFO">
|
||||
<appender-ref ref="STDOUT" />
|
||||
</root>
|
||||
</configuration>
|
|
@ -0,0 +1,17 @@
|
|||
package org.baeldung;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import com.baeldung.server.Server;
|
||||
|
||||
@SpringBootTest(classes = Server.class)
|
||||
@RunWith(SpringRunner.class)
|
||||
public class SpringContextTest {
|
||||
|
||||
@Test
|
||||
public void whenSpringContextIsBootstrapped_thenNoExceptions() {
|
||||
}
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
## Remoting JMS
|
||||
|
||||
This module contains articles about Spring Remoting with Java Message Service (JMS)
|
||||
|
||||
### Relevant Articles:
|
||||
|
||||
- [Spring Remoting with JMS and ActiveMQ](https://www.baeldung.com/spring-remoting-jms)
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
<?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>
|
||||
<artifactId>remoting-jms</artifactId>
|
||||
<name>remoting-jms</name>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
<parent>
|
||||
<groupId>com.ossez</groupId>
|
||||
<artifactId>spring-remoting-modules</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<modules>
|
||||
<module>remoting-jms-client</module>
|
||||
<module>remoting-jms-server</module>
|
||||
</modules>
|
||||
|
||||
</project>
|
|
@ -0,0 +1,33 @@
|
|||
<?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>
|
||||
<artifactId>remoting-jms-client</artifactId>
|
||||
<name>remoting-jms-client</name>
|
||||
|
||||
<parent>
|
||||
<groupId>com.ossez</groupId>
|
||||
<artifactId>remoting-jms</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-activemq</artifactId>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-tomcat</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.ossez</groupId>
|
||||
<artifactId>remoting-http-api</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
|
@ -0,0 +1,39 @@
|
|||
package com.baeldung.client;
|
||||
|
||||
import com.baeldung.api.Booking;
|
||||
import com.baeldung.api.BookingException;
|
||||
import com.baeldung.api.CabBookingService;
|
||||
import org.apache.activemq.command.ActiveMQQueue;
|
||||
import org.springframework.beans.factory.FactoryBean;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.jms.remoting.JmsInvokerProxyFactoryBean;
|
||||
|
||||
import javax.jms.ConnectionFactory;
|
||||
import javax.jms.Queue;
|
||||
|
||||
@SpringBootApplication
|
||||
public class JmsClient {
|
||||
|
||||
@Bean Queue queue() {
|
||||
return new ActiveMQQueue("remotingQueue");
|
||||
}
|
||||
|
||||
@Bean FactoryBean invoker(ConnectionFactory factory, Queue queue) {
|
||||
JmsInvokerProxyFactoryBean factoryBean = new JmsInvokerProxyFactoryBean();
|
||||
factoryBean.setConnectionFactory(factory);
|
||||
factoryBean.setServiceInterface(CabBookingService.class);
|
||||
factoryBean.setQueue(queue);
|
||||
return factoryBean;
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws BookingException {
|
||||
CabBookingService service = SpringApplication.run(JmsClient.class, args).getBean(CabBookingService.class);
|
||||
System.out.println("here");
|
||||
Booking bookingOutcome = service.bookRide("13 Seagate Blvd, Key Largo, FL 33037");
|
||||
System.out.println("there");
|
||||
System.out.println(bookingOutcome);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
spring.activemq.broker-url=tcp://127.0.0.1:61616
|
||||
spring.activemq.packages.trusted=org.springframework.remoting.support,java.lang,com.baeldung.api
|
||||
|
||||
# Logging
|
||||
logging.pattern.console=%d{mm:ss.SSS} %-5p [%-31t] [%-54logger{0}] %marker%m%ex{full} - %logger - %F:%L%n
|
||||
logging.level.root=WARN
|
||||
logging.level.org.apache.activemq=DEBUG
|
||||
logging.level.org.springframework.jms=DEBUG
|
||||
logging.level.org.springframework=WARN
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configuration>
|
||||
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<encoder>
|
||||
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
|
||||
</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<root level="INFO">
|
||||
<appender-ref ref="STDOUT" />
|
||||
</root>
|
||||
</configuration>
|
|
@ -0,0 +1,17 @@
|
|||
package org.baeldung;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import com.baeldung.client.JmsClient;
|
||||
|
||||
@SpringBootTest(classes = JmsClient.class)
|
||||
@RunWith(SpringRunner.class)
|
||||
public class SpringContextTest {
|
||||
|
||||
@Test
|
||||
public void whenSpringContextIsBootstrapped_thenNoExceptions() {
|
||||
}
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
<?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>
|
||||
<artifactId>remoting-jms-server</artifactId>
|
||||
<name>remoting-jms-server</name>
|
||||
|
||||
<parent>
|
||||
<groupId>com.ossez</groupId>
|
||||
<artifactId>remoting-jms</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-activemq</artifactId>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-tomcat</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.ossez</groupId>
|
||||
<artifactId>remoting-http-api</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
|
@ -0,0 +1,16 @@
|
|||
package com.baeldung.server;
|
||||
|
||||
import com.baeldung.api.Booking;
|
||||
import com.baeldung.api.BookingException;
|
||||
import com.baeldung.api.CabBookingService;
|
||||
|
||||
import static java.lang.Math.random;
|
||||
import static java.util.UUID.randomUUID;
|
||||
|
||||
public class CabBookingServiceImpl implements CabBookingService {
|
||||
|
||||
@Override public Booking bookRide(String pickUpLocation) throws BookingException {
|
||||
if (random() < 0.3) throw new BookingException("Cab unavailable");
|
||||
return new Booking(randomUUID().toString());
|
||||
}
|
||||
}
|
|
@ -0,0 +1,51 @@
|
|||
package com.baeldung.server;
|
||||
|
||||
import com.baeldung.api.CabBookingService;
|
||||
import org.apache.activemq.command.ActiveMQQueue;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.jms.listener.SimpleMessageListenerContainer;
|
||||
import org.springframework.jms.remoting.JmsInvokerServiceExporter;
|
||||
|
||||
import javax.jms.ConnectionFactory;
|
||||
import javax.jms.Queue;
|
||||
|
||||
@SpringBootApplication public class JmsServer {
|
||||
|
||||
/*
|
||||
This server needs to be connected to an ActiveMQ server.
|
||||
To quickly spin up an ActiveMQ server, you can use Docker.
|
||||
|
||||
docker run -p 61616:61616 -p 8161:8161 rmohr/activemq:5.14.3
|
||||
*/
|
||||
|
||||
@Bean CabBookingService bookingService() {
|
||||
return new CabBookingServiceImpl();
|
||||
}
|
||||
|
||||
@Bean Queue queue() {
|
||||
return new ActiveMQQueue("remotingQueue");
|
||||
}
|
||||
|
||||
@Bean JmsInvokerServiceExporter exporter(CabBookingService implementation) {
|
||||
JmsInvokerServiceExporter exporter = new JmsInvokerServiceExporter();
|
||||
exporter.setServiceInterface(CabBookingService.class);
|
||||
exporter.setService(implementation);
|
||||
return exporter;
|
||||
}
|
||||
|
||||
@Bean SimpleMessageListenerContainer listener(ConnectionFactory factory, JmsInvokerServiceExporter exporter) {
|
||||
SimpleMessageListenerContainer container = new SimpleMessageListenerContainer();
|
||||
container.setConnectionFactory(factory);
|
||||
container.setDestinationName("remotingQueue");
|
||||
container.setConcurrentConsumers(1);
|
||||
container.setMessageListener(exporter);
|
||||
return container;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(JmsServer.class, args);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
spring.activemq.broker-url=tcp://127.0.0.1:61616
|
||||
spring.activemq.packages.trusted=org.springframework.remoting.support,java.lang,com.baeldung.api
|
||||
|
||||
# Logging
|
||||
logging.pattern.console=%d{mm:ss.SSS} %-5p [%-31t] [%-54logger{0}] %marker%m%ex{full} - %logger - %F:%L%n
|
||||
logging.level.root=WARN
|
||||
logging.level.org.apache.activemq=DEBUG
|
||||
logging.level.org.springframework.jms=DEBUG
|
||||
logging.level.org.springframework=WARN
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configuration>
|
||||
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<encoder>
|
||||
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
|
||||
</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<root level="INFO">
|
||||
<appender-ref ref="STDOUT" />
|
||||
</root>
|
||||
</configuration>
|
|
@ -0,0 +1,23 @@
|
|||
package com.baeldung;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import com.baeldung.server.JmsServer;
|
||||
|
||||
/**
|
||||
* This Live Test requires:
|
||||
* * the `com.baeldung:remoting-http-api:jar:1.0-SNAPSHOT` artifact accessible. For that we can run `mvn clean install` in the 'spring-remoting/remoting-http/remoting-http-api' module.
|
||||
* * an ActiveMQ instance running (e.g. `docker run -p 61616:61616 -p 8161:8161 --name bael-activemq rmohr/activemq`)
|
||||
*
|
||||
*/
|
||||
@SpringBootTest(classes = JmsServer.class)
|
||||
@RunWith(SpringRunner.class)
|
||||
public class SpringContextLiveTest {
|
||||
|
||||
@Test
|
||||
public void whenSpringContextIsBootstrapped_thenNoExceptions() {
|
||||
}
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
## Remoting RMI
|
||||
|
||||
This module contains articles about Spring Remoting with Remote Method Invocation (RMI)
|
||||
|
||||
### Relevant Articles:
|
||||
|
||||
- [Spring Remoting with RMI](https://www.baeldung.com/spring-remoting-rmi)
|
|
@ -0,0 +1,21 @@
|
|||
<?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>
|
||||
<artifactId>remoting-rmi</artifactId>
|
||||
<name>remoting-rmi</name>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
<parent>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<artifactId>spring-remoting-modules</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<modules>
|
||||
<module>remoting-rmi-server</module>
|
||||
<module>remoting-rmi-client</module>
|
||||
</modules>
|
||||
|
||||
</project>
|
|
@ -0,0 +1,33 @@
|
|||
<?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>
|
||||
<artifactId>remoting-rmi-client</artifactId>
|
||||
<name>remoting-rmi-client</name>
|
||||
|
||||
<parent>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<artifactId>remoting-rmi</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-activemq</artifactId>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-tomcat</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<artifactId>remoting-http-api</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
|
@ -0,0 +1,26 @@
|
|||
package com.baeldung.client;
|
||||
|
||||
import com.baeldung.api.Booking;
|
||||
import com.baeldung.api.BookingException;
|
||||
import com.baeldung.api.CabBookingService;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.remoting.rmi.RmiProxyFactoryBean;
|
||||
|
||||
@SpringBootApplication public class RmiClient {
|
||||
|
||||
@Bean RmiProxyFactoryBean service() {
|
||||
RmiProxyFactoryBean rmiProxyFactory = new RmiProxyFactoryBean();
|
||||
rmiProxyFactory.setServiceUrl("rmi://localhost:1099/CabBookingService");
|
||||
rmiProxyFactory.setServiceInterface(CabBookingService.class);
|
||||
return rmiProxyFactory;
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws BookingException {
|
||||
CabBookingService service = SpringApplication.run(RmiClient.class, args).getBean(CabBookingService.class);
|
||||
Booking bookingOutcome = service.bookRide("13 Seagate Blvd, Key Largo, FL 33037");
|
||||
System.out.println(bookingOutcome);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configuration>
|
||||
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<encoder>
|
||||
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
|
||||
</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<root level="INFO">
|
||||
<appender-ref ref="STDOUT" />
|
||||
</root>
|
||||
</configuration>
|
|
@ -0,0 +1,23 @@
|
|||
package com.baeldung;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import com.baeldung.client.RmiClient;
|
||||
|
||||
/**
|
||||
* This Live Test requires:
|
||||
* * the `com.baeldung:remoting-http-api:jar:1.0-SNAPSHOT` artifact accessible. For that we can run `mvn clean install` in the 'spring-remoting/remoting-http/remoting-http-api' module.
|
||||
* * the 'spring-remoting\remoting-rmi\remoting-rmi-server' service running
|
||||
*
|
||||
*/
|
||||
@SpringBootTest(classes = RmiClient.class)
|
||||
@RunWith(SpringRunner.class)
|
||||
public class SpringContextLiveTest {
|
||||
|
||||
@Test
|
||||
public void whenSpringContextIsBootstrapped_thenNoExceptions() {
|
||||
}
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
<?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>
|
||||
<artifactId>remoting-rmi-server</artifactId>
|
||||
<name>remoting-rmi-server</name>
|
||||
|
||||
<parent>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<artifactId>remoting-rmi</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<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>com.baeldung</groupId>
|
||||
<artifactId>remoting-http-api</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
|
@ -0,0 +1,16 @@
|
|||
package com.baeldung.server;
|
||||
|
||||
import com.baeldung.api.Booking;
|
||||
import com.baeldung.api.BookingException;
|
||||
import com.baeldung.api.CabBookingService;
|
||||
|
||||
import static java.lang.Math.random;
|
||||
import static java.util.UUID.randomUUID;
|
||||
|
||||
public class CabBookingServiceImpl implements CabBookingService {
|
||||
|
||||
@Override public Booking bookRide(String pickUpLocation) throws BookingException {
|
||||
if (random() < 0.3) throw new BookingException("Cab unavailable");
|
||||
return new Booking(randomUUID().toString());
|
||||
}
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
package com.baeldung.server;
|
||||
|
||||
import com.baeldung.api.CabBookingService;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.remoting.rmi.RmiServiceExporter;
|
||||
|
||||
@SpringBootApplication public class RmiServer {
|
||||
|
||||
@Bean CabBookingService bookingService() {
|
||||
return new CabBookingServiceImpl();
|
||||
}
|
||||
|
||||
@Bean RmiServiceExporter exporter(CabBookingService implementation) {
|
||||
|
||||
// Expose a service via RMI. Remote obect URL is:
|
||||
// rmi://<HOST>:<PORT>/<SERVICE_NAME>
|
||||
// 1099 is the default port
|
||||
|
||||
Class<CabBookingService> serviceInterface = CabBookingService.class;
|
||||
RmiServiceExporter exporter = new RmiServiceExporter();
|
||||
exporter.setServiceInterface(serviceInterface);
|
||||
exporter.setService(implementation);
|
||||
exporter.setServiceName(serviceInterface.getSimpleName());
|
||||
exporter.setRegistryPort(1099);
|
||||
return exporter;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(RmiServer.class, args);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configuration>
|
||||
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<encoder>
|
||||
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
|
||||
</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<root level="INFO">
|
||||
<appender-ref ref="STDOUT" />
|
||||
</root>
|
||||
</configuration>
|
|
@ -0,0 +1,17 @@
|
|||
package org.baeldung;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import com.baeldung.server.RmiServer;
|
||||
|
||||
@SpringBootTest(classes = RmiServer.class)
|
||||
@RunWith(SpringRunner.class)
|
||||
public class SpringContextTest {
|
||||
|
||||
@Test
|
||||
public void whenSpringContextIsBootstrapped_thenNoExceptions() {
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue