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

View File

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

View File

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