BAEL-778 - renaming the vertx-spring to spring-vertx

This commit is contained in:
slavisa-baeldung 2017-06-10 11:53:39 +01:00
parent 5cb1c71cf0
commit cc37377821
13 changed files with 106 additions and 105 deletions

37
pom.xml
View File

@ -1,5 +1,6 @@
<?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">
<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>
<groupId>com.baeldung</groupId>
<artifactId>parent-modules</artifactId>
@ -11,20 +12,20 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<gib.referenceBranch>refs/heads/master</gib.referenceBranch>
<!-- <gib.enabled>false</gib.enabled>-->
<!-- <gib.enabled>false</gib.enabled>-->
<junit.version>4.12</junit.version>
<org.hamcrest.version>1.3</org.hamcrest.version>
<org.hamcrest.version>1.3</org.hamcrest.version>
<mockito.version>1.10.19</mockito.version>
<!-- logging -->
<org.slf4j.version>1.7.21</org.slf4j.version>
<logback.version>1.1.7</logback.version>
<!-- plugins -->
<maven-surefire-plugin.version>2.19.1</maven-surefire-plugin.version>
<maven-compiler-plugin.version>3.6.0</maven-compiler-plugin.version>
<maven-surefire-plugin.version>2.19.1</maven-surefire-plugin.version>
<maven-compiler-plugin.version>3.6.0</maven-compiler-plugin.version>
</properties>
<modules>
<module>vertx-spring</module>
<module>spring-vertx</module>
<module>aws</module>
<module>akka-streams</module>
<module>algorithms</module>
@ -71,7 +72,7 @@
<module>immutables</module>
<module>jackson</module>
<!-- <module>java-cassandra</module> -->
<!-- <module>java-cassandra</module> -->
<module>vavr</module>
<module>javax-servlets</module>
<module>javaxval</module>
@ -123,8 +124,8 @@
<module>selenium-junit-testng</module>
<module>solr</module>
<module>spark-java</module>
<module>spring-5</module>
<module>spring-5-mvc</module>
<module>spring-5</module>
<module>spring-5-mvc</module>
<module>spring-akka</module>
<module>spring-amqp</module>
<module>spring-all</module>
@ -176,7 +177,7 @@
<module>spring-rest-angular</module>
<module>spring-rest-docs</module>
<module>spring-rest</module>
<module>spring-rest-simple</module>
<module>spring-rest-simple</module>
<module>spring-security-cache-control</module>
<module>spring-security-client/spring-security-jsp-authentication</module>
<module>spring-security-client/spring-security-jsp-authorize</module>
@ -243,12 +244,12 @@
<groupId>ch.qos.logback</groupId>
<artifactId>logback-core</artifactId>
<version>${logback.version}</version>
</dependency>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
<version>${org.slf4j.version}</version>
</dependency>
</dependency>
<!-- test -->
<dependency>
@ -268,8 +269,8 @@
<artifactId>hamcrest-library</artifactId>
<version>${org.hamcrest.version}</version>
<scope>test</scope>
</dependency>
<dependency>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-all</artifactId>
<version>${org.hamcrest.version}</version>
@ -281,7 +282,7 @@
<version>${mockito.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
</dependencies>
<build>
<plugins>
@ -296,7 +297,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven-surefire-plugin.version}</version>
<version>${maven-surefire-plugin.version}</version>
<configuration>
<forkCount>3</forkCount>
<reuseForks>true</reuseForks>
@ -313,12 +314,12 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven-compiler-plugin.version}</version>
<version>${maven-compiler-plugin.version}</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugin>
</plugins>
<extensions>
<!--<extension>

77
spring-vertx/pom.xml Normal file
View File

@ -0,0 +1,77 @@
<?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>
<groupId>com.baeldung</groupId>
<artifactId>vertx-spring</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>vertx-spring</name>
<description>A demo project with vertx spring integration</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.3.RELEASE</version>
<relativePath/>
<!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<vertx.version>3.4.1</vertx.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<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>io.vertx</groupId>
<artifactId>vertx-core</artifactId>
<version>${vertx.version}</version>
</dependency>
<dependency>
<groupId>io.vertx</groupId>
<artifactId>vertx-web</artifactId>
<version>${vertx.version}</version>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>

View File

@ -21,8 +21,8 @@ public class DbBootstrap implements CommandLineRunner {
public void run(String... arg0) throws Exception {
IntStream.range(0, 10)
.forEach(count -> this.articleRepository.save(new Article(new Random().nextLong(), UUID.randomUUID()
.toString())));
.forEach(count -> this.articleRepository.save(new Article(new Random().nextLong(), UUID.randomUUID()
.toString())));
}
}

View File

@ -11,13 +11,13 @@ public class ServerVerticle extends AbstractVerticle {
private void getAllArticlesHandler(RoutingContext routingContext) {
vertx.eventBus()
.<String> send(ServiceVerticle.GET_ALL_ARTICLES, "", result -> {
.<String>send(ServiceVerticle.GET_ALL_ARTICLES, "", result -> {
if (result.succeeded()) {
routingContext.response()
.putHeader("content-type", "application/json")
.setStatusCode(200)
.end(result.result()
.body());
.body());
} else {
routingContext.response()
.setStatusCode(500)

View File

@ -16,33 +16,32 @@ import io.vertx.core.json.Json;
public class ServiceVerticle extends AbstractVerticle {
public static final String GET_ALL_ARTICLES = "get.artilces.all";
private final ObjectMapper mapper = Json.mapper;
@Autowired
private ArticleService articleService;
private final ObjectMapper mapper = Json.mapper;
@Override
public void start() throws Exception {
super.start();
vertx.eventBus()
.<String> consumer(GET_ALL_ARTICLES)
.handler(getAllArticleService(articleService));
.<String>consumer(GET_ALL_ARTICLES)
.handler(getAllArticleService(articleService));
}
private Handler<Message<String>> getAllArticleService(ArticleService service) {
return msg -> vertx.<String> executeBlocking(future -> {
return msg -> vertx.<String>executeBlocking(future -> {
try {
future.complete(mapper.writeValueAsString(service.getAllArticle()));
} catch (JsonProcessingException e) {
System.out.println("Failed to serialize result");
future.fail(e);
}
} , result -> {
}, result -> {
if (result.succeeded()) {
msg.reply(result.result());
} else {
msg.reply(result.cause()
.toString());
.toString());
}
});
}

View File

@ -1,76 +0,0 @@
<?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>
<groupId>com.baeldung</groupId>
<artifactId>vertx-spring</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>vertx-spring</name>
<description>A demo project with vertx spring integration</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.3.RELEASE</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<vertx.version>3.4.1</vertx.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<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>io.vertx</groupId>
<artifactId>vertx-core</artifactId>
<version>${vertx.version}</version>
</dependency>
<dependency>
<groupId>io.vertx</groupId>
<artifactId>vertx-web</artifactId>
<version>${vertx.version}</version>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>