Merge remote-tracking branch 'eugenp/master'
This commit is contained in:
commit
344147c9b5
3
.gitignore
vendored
3
.gitignore
vendored
@ -77,4 +77,5 @@ apache-avro/src/main/java/com/baeldung/avro/model/
|
||||
jta/transaction-logs/
|
||||
software-security/sql-injection-samples/derby.log
|
||||
spring-soap/src/main/java/com/baeldung/springsoap/gen/
|
||||
/report-*.json
|
||||
/report-*.json
|
||||
transaction.log
|
@ -42,7 +42,7 @@
|
||||
<dependency>
|
||||
<groupId>com.github.dpaukov</groupId>
|
||||
<artifactId>combinatoricslib3</artifactId>
|
||||
<version>3.3.0</version>
|
||||
<version>${combinatoricslib3.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
@ -83,6 +83,7 @@
|
||||
<org.assertj.core.version>3.9.0</org.assertj.core.version>
|
||||
<commons-codec.version>1.11</commons-codec.version>
|
||||
<guava.version>27.0.1-jre</guava.version>
|
||||
<combinatoricslib3.version>3.3.0</combinatoricslib3.version>
|
||||
</properties>
|
||||
|
||||
</project>
|
@ -5,3 +5,5 @@
|
||||
- [Converting Between Roman and Arabic Numerals in Java](http://www.baeldung.com/java-convert-roman-arabic)
|
||||
- [Practical Java Examples of the Big O Notation](http://www.baeldung.com/java-algorithm-complexity)
|
||||
- [Checking If a List Is Sorted in Java](https://www.baeldung.com/java-check-if-list-sorted)
|
||||
- [Checking if a Java Graph has a Cycle](https://www.baeldung.com/java-graph-has-a-cycle)
|
||||
- [A Guide to the Folding Technique](https://www.baeldung.com/folding-hashing-technique)
|
||||
|
@ -17,7 +17,7 @@
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>4.10</version>
|
||||
<version>${junit.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
@ -3,37 +3,28 @@
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>2.1.3.RELEASE</version>
|
||||
<relativePath /> <!-- lookup parent from repository -->
|
||||
</parent>
|
||||
<groupId>org.baeldung.examples.olingo2</groupId>
|
||||
<artifactId>olingo2-sample</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<name>olingo2-sample</name>
|
||||
<description>Sample Olingo 2 Project</description>
|
||||
|
||||
<properties>
|
||||
<java.version>1.8</java.version>
|
||||
<olingo2.version>2.0.11</olingo2.version>
|
||||
</properties>
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>2.1.3.RELEASE</version>
|
||||
<relativePath /> <!-- lookup parent from repository -->
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-jersey</artifactId>
|
||||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-jpa</artifactId>
|
||||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>com.h2database</groupId>
|
||||
<artifactId>h2</artifactId>
|
||||
@ -90,4 +81,9 @@
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<properties>
|
||||
<java.version>1.8</java.version>
|
||||
<olingo2.version>2.0.11</olingo2.version>
|
||||
</properties>
|
||||
|
||||
</project>
|
||||
|
@ -49,6 +49,7 @@
|
||||
<version>${com.datastax.spark.spark-cassandra-connector-java.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
@ -78,6 +79,7 @@
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<properties>
|
||||
<org.apache.spark.spark-core.version>2.3.0</org.apache.spark.spark-core.version>
|
||||
<org.apache.spark.spark-sql.version>2.3.0</org.apache.spark.spark-sql.version>
|
||||
|
@ -1,3 +1,4 @@
|
||||
### Relevant Articles:
|
||||
- [Introduction to AutoValue](http://www.baeldung.com/introduction-to-autovalue)
|
||||
- [Introduction to AutoFactory](http://www.baeldung.com/autofactory)
|
||||
- [Google AutoService](https://www.baeldung.com/google-autoservice)
|
||||
|
@ -65,7 +65,6 @@
|
||||
<properties>
|
||||
<main.class>com.baeldung.bootique.App</main.class>
|
||||
<bootique-bom.version>0.23</bootique-bom.version>
|
||||
|
||||
<maven-shade-plugin.version>2.4.3</maven-shade-plugin.version>
|
||||
</properties>
|
||||
|
||||
|
@ -6,4 +6,5 @@
|
||||
- [Template Engines in Groovy](https://www.baeldung.com/groovy-template-engines)
|
||||
- [Groovy def Keyword](https://www.baeldung.com/groovy-def-keyword)
|
||||
- [Pattern Matching in Strings in Groovy](https://www.baeldung.com/groovy-pattern-matching)
|
||||
- [Working with XML in Groovy](https://www.baeldung.com/groovy-xml)
|
||||
- [Working with XML in Groovy](https://www.baeldung.com/groovy-xml)
|
||||
- [Integrating Groovy into Java Applications](https://www.baeldung.com/groovy-java-applications)
|
||||
|
@ -157,20 +157,19 @@
|
||||
</repositories>
|
||||
|
||||
<pluginRepositories>
|
||||
<pluginRepository>
|
||||
<id>bintray</id>
|
||||
<name>Groovy Bintray</name>
|
||||
<url>https://dl.bintray.com/groovy/maven</url>
|
||||
<releases>
|
||||
<!-- avoid automatic updates -->
|
||||
<updatePolicy>never</updatePolicy>
|
||||
</releases>
|
||||
<snapshots>
|
||||
<enabled>false</enabled>
|
||||
</snapshots>
|
||||
</pluginRepository>
|
||||
</pluginRepositories>
|
||||
|
||||
<pluginRepository>
|
||||
<id>bintray</id>
|
||||
<name>Groovy Bintray</name>
|
||||
<url>https://dl.bintray.com/groovy/maven</url>
|
||||
<releases>
|
||||
<!-- avoid automatic updates -->
|
||||
<updatePolicy>never</updatePolicy>
|
||||
</releases>
|
||||
<snapshots>
|
||||
<enabled>false</enabled>
|
||||
</snapshots>
|
||||
</pluginRepository>
|
||||
</pluginRepositories>
|
||||
|
||||
<properties>
|
||||
<junit.platform.version>1.0.0</junit.platform.version>
|
||||
|
@ -3,3 +3,4 @@
|
||||
- [Multi-Module Maven Application with Java Modules](https://www.baeldung.com/maven-multi-module-project-java-jpms)
|
||||
- [Guide to Java FileChannel](https://www.baeldung.com/java-filechannel)
|
||||
- [Understanding the NumberFormatException in Java](https://www.baeldung.com/java-number-format-exception)
|
||||
- [Will an Error Be Caught by Catch Block in Java?](https://www.baeldung.com/java-error-catch)
|
||||
|
@ -5,3 +5,4 @@
|
||||
- [Guide to Java 10](http://www.baeldung.com/java-10-overview)
|
||||
- [Copy a List to Another List in Java](http://www.baeldung.com/java-copy-list-to-another)
|
||||
- [Deep Dive Into the New Java JIT Compiler – Graal](https://www.baeldung.com/graal-java-jit-compiler)
|
||||
- [Copying Sets in Java](https://www.baeldung.com/java-copy-sets)
|
||||
|
@ -6,3 +6,4 @@
|
||||
- [Anonymous Classes in Java](http://www.baeldung.com/)
|
||||
- [How to Delay Code Execution in Java](https://www.baeldung.com/java-delay-code-execution)
|
||||
- [Run JAR Application With Command Line Arguments](https://www.baeldung.com/java-run-jar-with-arguments)
|
||||
- [Java 8 Stream skip() vs limit()](https://www.baeldung.com/java-stream-skip-vs-limit)
|
||||
|
@ -9,7 +9,6 @@
|
||||
<name>core-java-8-2</name>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
|
||||
<parent>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<artifactId>parent-java</artifactId>
|
||||
@ -17,14 +16,6 @@
|
||||
<relativePath>../../parent-java</relativePath>
|
||||
</parent>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<maven.compiler.source>1.8</maven.compiler.source>
|
||||
<maven.compiler.target>1.8</maven.compiler.target>
|
||||
<icu.version>64.2</icu.version>
|
||||
<assertj.version>3.12.2</assertj.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.ibm.icu</groupId>
|
||||
@ -51,6 +42,13 @@
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
|
||||
</build>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<maven.compiler.source>1.8</maven.compiler.source>
|
||||
<maven.compiler.target>1.8</maven.compiler.target>
|
||||
<icu.version>64.2</icu.version>
|
||||
<assertj.version>3.12.2</assertj.version>
|
||||
</properties>
|
||||
</project>
|
||||
|
@ -40,3 +40,4 @@
|
||||
- [Java 8 Predicate Chain](https://www.baeldung.com/java-predicate-chain)
|
||||
- [Method References in Java](https://www.baeldung.com/java-method-references)
|
||||
- [Creating a Custom Annotation in Java](https://www.baeldung.com/java-custom-annotation)
|
||||
- [The Difference Between Collection.stream().forEach() and Collection.forEach()](https://www.baeldung.com/java-collection-stream-foreach)
|
||||
|
@ -10,3 +10,4 @@
|
||||
- [Initializing HashSet at the Time of Construction](http://www.baeldung.com/java-initialize-hashset)
|
||||
- [Guide to EnumSet](https://www.baeldung.com/java-enumset)
|
||||
- [Set Operations in Java](https://www.baeldung.com/java-set-operations)
|
||||
- [Copying Sets in Java](https://www.baeldung.com/java-copy-sets)
|
||||
|
@ -14,30 +14,31 @@
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.google.guava</groupId>
|
||||
<artifactId>guava</artifactId>
|
||||
<version>${guava.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-collections4</artifactId>
|
||||
<version>${commons-collections4.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.code.gson</groupId>
|
||||
<artifactId>gson</artifactId>
|
||||
<version>2.8.5</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-lang</groupId>
|
||||
<artifactId>commons-lang</artifactId>
|
||||
<version>2.6</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.guava</groupId>
|
||||
<artifactId>guava</artifactId>
|
||||
<version>${guava.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-collections4</artifactId>
|
||||
<version>${commons-collections4.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.code.gson</groupId>
|
||||
<artifactId>gson</artifactId>
|
||||
<version>${gson.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-lang</groupId>
|
||||
<artifactId>commons-lang</artifactId>
|
||||
<version>${commons-lang.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<properties>
|
||||
<commons-collections4.version>4.3</commons-collections4.version>
|
||||
<guava.version>27.1-jre</guava.version>
|
||||
<gson.version>2.8.5</gson.version>
|
||||
</properties>
|
||||
</project>
|
@ -14,15 +14,11 @@
|
||||
<relativePath>../../parent-java</relativePath>
|
||||
</parent>
|
||||
|
||||
<properties>
|
||||
<commons-lang3.version>3.9</commons-lang3.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>4.12</version>
|
||||
<version>${junit.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
@ -32,4 +28,8 @@
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<properties>
|
||||
<commons-lang3.version>3.9</commons-lang3.version>
|
||||
</properties>
|
||||
|
||||
</project>
|
||||
|
@ -11,6 +11,14 @@
|
||||
<version>1.0</version>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.baeldung.servicemodule</groupId>
|
||||
<artifactId>servicemodule</artifactId>
|
||||
<version>1.0</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
@ -19,12 +27,4 @@
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.baeldung.servicemodule</groupId>
|
||||
<artifactId>servicemodule</artifactId>
|
||||
<version>1.0</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
@ -2,17 +2,18 @@
|
||||
<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">
|
||||
<parent>
|
||||
<artifactId>com.baeldung.decoupling-pattern2</artifactId>
|
||||
<groupId>decoupling-pattern2</groupId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>com.baeldung.consumermodule</groupId>
|
||||
<artifactId>consumermodule</artifactId>
|
||||
<version>1.0</version>
|
||||
|
||||
<parent>
|
||||
<artifactId>com.baeldung.decoupling-pattern2</artifactId>
|
||||
<groupId>decoupling-pattern2</groupId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.baeldung.servicemodule</groupId>
|
||||
|
@ -6,3 +6,4 @@
|
||||
- [Generic Constructors in Java](https://www.baeldung.com/java-generic-constructors)
|
||||
- [Cannot Reference “X” Before Supertype Constructor Has Been Called](https://www.baeldung.com/java-cannot-reference-x-before-supertype-constructor-error)
|
||||
- [Anonymous Classes in Java](https://www.baeldung.com/java-anonymous-classes)
|
||||
- [Raw Types in Java](https://www.baeldung.com/raw-types-java)
|
||||
|
@ -1,3 +1,3 @@
|
||||
## Relevant articles:
|
||||
|
||||
- [Determine File Creating Date in Java](https://www.baeldung.com/file-creation-date-java)
|
||||
- [Determine File Creating Date in Java](https://www.baeldung.com/java-file-creation-date)
|
||||
|
@ -8,9 +8,9 @@
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<parent>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<artifactId>parent-java</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<relativePath>../../parent-java</relativePath>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<artifactId>parent-java</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<relativePath>../../parent-java</relativePath>
|
||||
</parent>
|
||||
</project>
|
@ -2,4 +2,5 @@
|
||||
|
||||
## Core Java Optional
|
||||
|
||||
### Relevant Articles:
|
||||
### Relevant Articles:
|
||||
- [Java Optional as Return Type](https://www.baeldung.com/java-optional-return)
|
||||
|
@ -1,22 +1,14 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>com.baeldung.core-java-modules</groupId>
|
||||
<artifactId>core-java-modules</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>core-java-optional</artifactId>
|
||||
<version>0.1.0-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<maven.compiler.source>1.8</maven.compiler.source>
|
||||
<maven.compiler.target>1.8</maven.compiler.target>
|
||||
<hibernate.core.version>5.4.0.Final</hibernate.core.version>
|
||||
<h2database.version>1.4.197</h2database.version>
|
||||
<jackson.databind.version>2.9.8</jackson.databind.version>
|
||||
</properties>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>core-java-optional</artifactId>
|
||||
<version>0.1.0-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<parent>
|
||||
<groupId>com.baeldung.core-java-modules</groupId>
|
||||
<artifactId>core-java-modules</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
@ -50,4 +42,13 @@
|
||||
</plugins>
|
||||
|
||||
</build>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<maven.compiler.source>1.8</maven.compiler.source>
|
||||
<maven.compiler.target>1.8</maven.compiler.target>
|
||||
<hibernate.core.version>5.4.0.Final</hibernate.core.version>
|
||||
<h2database.version>1.4.197</h2database.version>
|
||||
<jackson.databind.version>2.9.8</jackson.databind.version>
|
||||
</properties>
|
||||
</project>
|
@ -13,7 +13,6 @@
|
||||
<relativePath>../../parent-java</relativePath>
|
||||
</parent>
|
||||
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>commons-io</groupId>
|
||||
|
@ -1,15 +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>
|
||||
<groupId>com.baeldung.entitymodule</groupId>
|
||||
<artifactId>entitymodule</artifactId>
|
||||
<version>1.0</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<parent>
|
||||
<groupId>com.baeldung.multimodulemavenproject</groupId>
|
||||
<artifactId>multimodulemavenproject</artifactId>
|
||||
<version>1.0</version>
|
||||
</parent>
|
||||
<groupId>com.baeldung.entitymodule</groupId>
|
||||
<artifactId>entitymodule</artifactId>
|
||||
<version>1.0</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
|
@ -1,15 +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>
|
||||
<groupId>com.baeldung.mainappmodule</groupId>
|
||||
<artifactId>mainappmodule</artifactId>
|
||||
<version>1.0</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<parent>
|
||||
<groupId>com.baeldung.multimodulemavenproject</groupId>
|
||||
<artifactId>multimodulemavenproject</artifactId>
|
||||
<version>1.0</version>
|
||||
</parent>
|
||||
<groupId>com.baeldung.mainappmodule</groupId>
|
||||
<artifactId>mainappmodule</artifactId>
|
||||
<version>1.0</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
|
@ -14,18 +14,25 @@
|
||||
<relativePath>../../</relativePath>
|
||||
</parent>
|
||||
|
||||
<modules>
|
||||
<module>entitymodule</module>
|
||||
<module>daomodule</module>
|
||||
<module>userdaomodule</module>
|
||||
<module>mainappmodule</module>
|
||||
</modules>
|
||||
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>4.12</version>
|
||||
<version>${junit.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.assertj</groupId>
|
||||
<artifactId>assertj-core</artifactId>
|
||||
<version>3.12.2</version>
|
||||
<version>${assertj-core.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
@ -49,14 +56,8 @@
|
||||
</pluginManagement>
|
||||
</build>
|
||||
|
||||
<modules>
|
||||
<module>entitymodule</module>
|
||||
<module>daomodule</module>
|
||||
<module>userdaomodule</module>
|
||||
<module>mainappmodule</module>
|
||||
</modules>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<assertj-core.version>3.12.2</assertj-core.version>
|
||||
</properties>
|
||||
</project>
|
||||
|
@ -1,24 +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>
|
||||
<groupId>com.baeldung.userdaomodule</groupId>
|
||||
<artifactId>userdaomodule</artifactId>
|
||||
<version>1.0</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<parent>
|
||||
<groupId>com.baeldung.multimodulemavenproject</groupId>
|
||||
<artifactId>multimodulemavenproject</artifactId>
|
||||
<version>1.0</version>
|
||||
</parent>
|
||||
<groupId>com.baeldung.userdaomodule</groupId>
|
||||
<artifactId>userdaomodule</artifactId>
|
||||
<version>1.0</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
@ -33,6 +25,15 @@
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>9</maven.compiler.source>
|
||||
<maven.compiler.target>9</maven.compiler.target>
|
||||
|
@ -18,9 +18,10 @@
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
<version>1.7.25</version>
|
||||
<version>${org.slf4j.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<finalName>pre-jpms</finalName>
|
||||
<plugins>
|
||||
@ -65,9 +66,9 @@
|
||||
</archive>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
@ -9,4 +9,4 @@ The "REST With Spring" Classes: http://bit.ly/restwithspring
|
||||
- [Mapping Multiple JSON Fields to a Single Java Field](https://www.baeldung.com/json-multiple-fields-single-java-field)
|
||||
- [How to Process YAML with Jackson](https://www.baeldung.com/jackson-yaml)
|
||||
- [Working with Tree Model Nodes in Jackson](https://www.baeldung.com/jackson-json-node-tree-model)
|
||||
|
||||
- [Converting JSON to CSV in Java](https://www.baeldung.com/java-converting-json-to-csv)
|
||||
|
@ -26,21 +26,21 @@
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.dataformat</groupId>
|
||||
<artifactId>jackson-dataformat-yaml</artifactId>
|
||||
<version>2.9.8</version>
|
||||
<version>${jackson.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- CSV -->
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.dataformat</groupId>
|
||||
<artifactId>jackson-dataformat-csv</artifactId>
|
||||
<version>2.9.8</version>
|
||||
<version>${jackson.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Allow use of LocalDate -->
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.datatype</groupId>
|
||||
<artifactId>jackson-datatype-jsr310</artifactId>
|
||||
<version>2.9.8</version>
|
||||
<version>${jackson.version}</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
|
@ -0,0 +1,126 @@
|
||||
package com.baeldung.jackson.json.compare;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Comparator;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.node.NumericNode;
|
||||
import com.fasterxml.jackson.databind.node.TextNode;
|
||||
|
||||
public class JsonCompareUnitTest {
|
||||
|
||||
@Test
|
||||
public void givenTwoSameJsonDataObjects_whenCompared_thenAreEqual() throws IOException {
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
|
||||
String s1 = "{\"employee\": {\"id\": \"1212\",\"fullName\": \"John Miles\", \"age\": 34 }}";
|
||||
String s2 = "{\"employee\": {\"id\": \"1212\",\"age\": 34, \"fullName\": \"John Miles\" }}";
|
||||
|
||||
JsonNode actualObj1 = mapper.readTree(s1);
|
||||
JsonNode actualObj2 = mapper.readTree(s2);
|
||||
|
||||
assertEquals(actualObj1, actualObj2);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenTwoSameNestedJsonDataObjects_whenCompared_thenEqual() throws IOException {
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
|
||||
String s1 = "{\"employee\": {\"id\": \"1212\",\"fullName\": \"John Miles\",\"age\": 34, \"contact\":{\"email\": \"john@xyz.com\",\"phone\": \"9999999999\"} }}";
|
||||
String s2 = "{\"employee\": {\"id\": \"1212\",\"fullName\": \"John Miles\",\"age\": 34, \"contact\":{\"email\": \"john@xyz.com\",\"phone\": \"9999999999\"} }}";
|
||||
|
||||
JsonNode actualObj1 = mapper.readTree(s1);
|
||||
JsonNode actualObj2 = mapper.readTree(s2);
|
||||
|
||||
assertEquals(actualObj1, actualObj2);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenTwoSameListJsonDataObjects_whenCompared_thenEqual() throws IOException {
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
|
||||
String s1 = "{\"employee\": {\"id\": \"1212\",\"fullName\": \"John Miles\",\"age\": 34, \"skills\":[\"Java\", \"C++\", \"Python\"] }}";
|
||||
String s2 = "{\"employee\": {\"id\": \"1212\",\"fullName\": \"John Miles\",\"age\": 34, \"skills\":[\"Java\", \"C++\", \"Python\"] }}";
|
||||
|
||||
JsonNode actualObj1 = mapper.readTree(s1);
|
||||
JsonNode actualObj2 = mapper.readTree(s2);
|
||||
|
||||
assertEquals(actualObj1, actualObj2);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenTwoJsonDataObjects_whenComparedUsingCustomNumericNodeComparator_thenEqual() throws IOException {
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
|
||||
String s1 = "{\"name\": \"John\",\"score\":5.0}";
|
||||
String s2 = "{\"name\": \"John\",\"score\":5}";
|
||||
JsonNode actualObj1 = mapper.readTree(s1);
|
||||
JsonNode actualObj2 = mapper.readTree(s2);
|
||||
|
||||
NumericNodeComparator cmp = new NumericNodeComparator();
|
||||
|
||||
assertNotEquals(actualObj1, actualObj2);
|
||||
assertTrue(actualObj1.equals(cmp, actualObj2));
|
||||
|
||||
}
|
||||
|
||||
public class NumericNodeComparator implements Comparator<JsonNode> {
|
||||
@Override
|
||||
public int compare(JsonNode o1, JsonNode o2) {
|
||||
if (o1.equals(o2)) {
|
||||
return 0;
|
||||
}
|
||||
if ((o1 instanceof NumericNode) && (o2 instanceof NumericNode)) {
|
||||
Double d1 = ((NumericNode) o1).asDouble();
|
||||
Double d2 = ((NumericNode) o2).asDouble();
|
||||
if (d1.compareTo(d2) == 0) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenTwoJsonDataObjects_whenComparedUsingCustomTextNodeComparator_thenEqual() throws IOException {
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
|
||||
String s1 = "{\"name\": \"JOHN\",\"score\":5}";
|
||||
String s2 = "{\"name\": \"John\",\"score\":5}";
|
||||
JsonNode actualObj1 = mapper.readTree(s1);
|
||||
JsonNode actualObj2 = mapper.readTree(s2);
|
||||
|
||||
TextNodeComparator cmp = new TextNodeComparator();
|
||||
|
||||
assertNotEquals(actualObj1, actualObj2);
|
||||
assertTrue(actualObj1.equals(cmp, actualObj2));
|
||||
|
||||
}
|
||||
|
||||
public class TextNodeComparator implements Comparator<JsonNode> {
|
||||
@Override
|
||||
public int compare(JsonNode o1, JsonNode o2) {
|
||||
if (o1.equals(o2)) {
|
||||
return 0;
|
||||
}
|
||||
if ((o1 instanceof TextNode) && (o2 instanceof TextNode)) {
|
||||
String s1 = ((TextNode) o1).asText();
|
||||
String s2 = ((TextNode) o2).asText();
|
||||
if (s1.equalsIgnoreCase(s2)) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
@ -10,4 +10,7 @@
|
||||
- [Converting a List to String in Java](http://www.baeldung.com/java-list-to-string)
|
||||
- [How to Convert List to Map in Java](http://www.baeldung.com/java-list-to-map)
|
||||
- [Array to String Conversions](https://www.baeldung.com/java-array-to-string)
|
||||
- [Converting a Collection to ArrayList in Java](https://www.baeldung.com/java-convert-collection-arraylist)
|
||||
- [Converting a Collection to ArrayList in Java](https://www.baeldung.com/java-convert-collection-arraylist)
|
||||
- [Java 8 Collectors toMap](https://www.baeldung.com/java-collectors-tomap)
|
||||
- [Converting Iterable to Collection in Java](https://www.baeldung.com/java-iterable-to-collection)
|
||||
- [Converting Iterator to List](https://www.baeldung.com/java-convert-iterator-to-list)
|
||||
|
@ -25,7 +25,7 @@
|
||||
<dependency>
|
||||
<groupId>commons-validator</groupId>
|
||||
<artifactId>commons-validator</artifactId>
|
||||
<version>1.6</version>
|
||||
<version>${commons-validator.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- test scoped -->
|
||||
@ -63,6 +63,7 @@
|
||||
<!-- testing -->
|
||||
<assertj.version>3.6.1</assertj.version>
|
||||
<joda-time.version>2.10</joda-time.version>
|
||||
<commons-validator.version>1.6</commons-validator.version>
|
||||
<maven.compiler.source>1.9</maven.compiler.source>
|
||||
<maven.compiler.target>1.9</maven.compiler.target>
|
||||
</properties>
|
||||
|
@ -42,7 +42,7 @@
|
||||
<dependency>
|
||||
<groupId>com.github.dpaukov</groupId>
|
||||
<artifactId>combinatoricslib3</artifactId>
|
||||
<version>3.3.0</version>
|
||||
<version>${combinatoricslib3.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
@ -63,6 +63,7 @@
|
||||
<org.assertj.core.version>3.9.0</org.assertj.core.version>
|
||||
<commons-codec.version>1.11</commons-codec.version>
|
||||
<guava.version>27.0.1-jre</guava.version>
|
||||
<combinatoricslib3.version>3.3.0</combinatoricslib3.version>
|
||||
</properties>
|
||||
|
||||
</project>
|
@ -1,3 +1,4 @@
|
||||
### Relevant Articles:
|
||||
- [Guide to Stream.reduce()](https://www.baeldung.com/java-stream-reduce)
|
||||
|
||||
- [How to Break from Java Stream forEach](https://www.baeldung.com/java-break-stream-foreach)
|
||||
- [Java IntStream Conversions](https://www.baeldung.com/java-intstream-convert)
|
||||
|
@ -34,6 +34,7 @@
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<finalName>${project.artifactId}</finalName>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
@ -78,7 +79,6 @@
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
<finalName>${project.artifactId}</finalName>
|
||||
</build>
|
||||
|
||||
<properties>
|
||||
|
3
kotlin-quasar/README.md
Normal file
3
kotlin-quasar/README.md
Normal file
@ -0,0 +1,3 @@
|
||||
### Relevant Articles
|
||||
|
||||
- [Introduction to Quasar in Kotlin](https://www.baeldung.com/kotlin-quasar)
|
@ -45,6 +45,27 @@
|
||||
<artifactId>junit</artifactId>
|
||||
<version>4.12</version>
|
||||
</dependency>
|
||||
<!-- logging -->
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
<version>${org.slf4j.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ch.qos.logback</groupId>
|
||||
<artifactId>logback-classic</artifactId>
|
||||
<version>${logback.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ch.qos.logback</groupId>
|
||||
<artifactId>logback-core</artifactId>
|
||||
<version>${logback.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>jcl-over-slf4j</artifactId>
|
||||
<version>${org.slf4j.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
@ -116,5 +137,7 @@
|
||||
<properties>
|
||||
<quasar.version>0.8.0</quasar.version>
|
||||
<kotlin.version>1.3.31</kotlin.version>
|
||||
<org.slf4j.version>1.7.21</org.slf4j.version>
|
||||
<logback.version>1.1.7</logback.version>
|
||||
</properties>
|
||||
</project>
|
||||
|
@ -0,0 +1,157 @@
|
||||
package com.baeldung.quasar
|
||||
|
||||
import co.paralleluniverse.actors.Actor
|
||||
import co.paralleluniverse.actors.ActorRef
|
||||
import co.paralleluniverse.actors.behaviors.*
|
||||
import co.paralleluniverse.fibers.Suspendable
|
||||
import co.paralleluniverse.strands.SuspendableCallable
|
||||
import org.junit.Test
|
||||
import org.slf4j.LoggerFactory
|
||||
import java.lang.Exception
|
||||
|
||||
class ActorsBehaviorTest {
|
||||
companion object {
|
||||
private val LOG = LoggerFactory.getLogger(ActorsBehaviorTest::class.java)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun requestReplyHelper() {
|
||||
data class TestMessage(val input: Int) : RequestMessage<Int>()
|
||||
|
||||
val actor = object : Actor<TestMessage, Void>("requestReplyActor", null) {
|
||||
@Suspendable
|
||||
override fun doRun(): Void? {
|
||||
while (true) {
|
||||
val msg = receive()
|
||||
LOG.info("Processing message: {}", msg)
|
||||
|
||||
RequestReplyHelper.reply(msg, msg.input * 100)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
val actorRef = actor.spawn()
|
||||
|
||||
val result = RequestReplyHelper.call(actorRef, TestMessage(50))
|
||||
LOG.info("Received reply: {}", result)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun server() {
|
||||
val actor = ServerActor(object : AbstractServerHandler<Int, String, Float>() {
|
||||
@Suspendable
|
||||
override fun handleCall(from: ActorRef<*>?, id: Any?, m: Int?): String {
|
||||
LOG.info("Called with message: {} from {} with ID {}", m, from, id)
|
||||
return m.toString() ?: "None"
|
||||
}
|
||||
|
||||
@Suspendable
|
||||
override fun handleCast(from: ActorRef<*>?, id: Any?, m: Float?) {
|
||||
LOG.info("Cast message: {} from {} with ID {}", m, from, id)
|
||||
}
|
||||
})
|
||||
|
||||
val server = actor.spawn()
|
||||
|
||||
LOG.info("Call result: {}", server.call(5))
|
||||
server.cast(2.5f)
|
||||
|
||||
server.shutdown()
|
||||
}
|
||||
|
||||
interface Summer {
|
||||
fun sum(a: Int, b: Int) : Int
|
||||
}
|
||||
|
||||
@Test
|
||||
fun proxyServer() {
|
||||
val actor = ProxyServerActor(false, object : Summer {
|
||||
@Synchronized
|
||||
override fun sum(a: Int, b: Int): Int {
|
||||
Exception().printStackTrace()
|
||||
LOG.info("Adding together {} and {}", a, b)
|
||||
return a + b
|
||||
}
|
||||
})
|
||||
|
||||
val summerActor = actor.spawn()
|
||||
|
||||
val result = (summerActor as Summer).sum(1, 2)
|
||||
LOG.info("Result: {}", result)
|
||||
|
||||
summerActor.shutdown()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun eventSource() {
|
||||
val actor = EventSourceActor<String>()
|
||||
val eventSource = actor.spawn()
|
||||
|
||||
eventSource.addHandler { msg ->
|
||||
LOG.info("Sent message: {}", msg)
|
||||
}
|
||||
|
||||
val name = "Outside Value"
|
||||
eventSource.addHandler { msg ->
|
||||
LOG.info("Also Sent message: {} {}", msg, name)
|
||||
}
|
||||
|
||||
eventSource.send("Hello")
|
||||
|
||||
eventSource.shutdown()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun finiteStateMachine() {
|
||||
val actor = object : FiniteStateMachineActor() {
|
||||
@Suspendable
|
||||
override fun initialState(): SuspendableCallable<SuspendableCallable<*>> {
|
||||
LOG.info("Starting")
|
||||
return SuspendableCallable { lockedState() }
|
||||
}
|
||||
|
||||
@Suspendable
|
||||
fun lockedState() : SuspendableCallable<SuspendableCallable<*>> {
|
||||
return receive {msg ->
|
||||
when (msg) {
|
||||
"PUSH" -> {
|
||||
LOG.info("Still locked")
|
||||
lockedState()
|
||||
}
|
||||
"COIN" -> {
|
||||
LOG.info("Unlocking...")
|
||||
unlockedState()
|
||||
}
|
||||
else -> TERMINATE
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Suspendable
|
||||
fun unlockedState() : SuspendableCallable<SuspendableCallable<*>> {
|
||||
return receive {msg ->
|
||||
when (msg) {
|
||||
"PUSH" -> {
|
||||
LOG.info("Locking")
|
||||
lockedState()
|
||||
}
|
||||
"COIN" -> {
|
||||
LOG.info("Unlocked")
|
||||
unlockedState()
|
||||
}
|
||||
else -> TERMINATE
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
val actorRef = actor.spawn()
|
||||
|
||||
listOf("PUSH", "COIN", "COIN", "PUSH", "PUSH").forEach {
|
||||
LOG.info(it)
|
||||
actorRef.sendSync(it)
|
||||
}
|
||||
|
||||
actorRef.shutdown()
|
||||
}
|
||||
}
|
298
kotlin-quasar/src/test/kotlin/com/baeldung/quasar/ActorsTest.kt
Normal file
298
kotlin-quasar/src/test/kotlin/com/baeldung/quasar/ActorsTest.kt
Normal file
@ -0,0 +1,298 @@
|
||||
package com.baeldung.quasar
|
||||
|
||||
import co.paralleluniverse.actors.*
|
||||
import co.paralleluniverse.fibers.Suspendable
|
||||
import co.paralleluniverse.strands.channels.Channels
|
||||
import org.junit.Assert
|
||||
import org.junit.Test
|
||||
import org.slf4j.LoggerFactory
|
||||
import java.util.concurrent.TimeUnit
|
||||
|
||||
class ActorsTest {
|
||||
companion object {
|
||||
private val LOG = LoggerFactory.getLogger(ActorsTest::class.java)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun createNoopActor() {
|
||||
val actor = object : Actor<Int, String>("noopActor", MailboxConfig(5, Channels.OverflowPolicy.THROW)) {
|
||||
@Suspendable
|
||||
override fun doRun(): String {
|
||||
return "Hello"
|
||||
}
|
||||
}
|
||||
|
||||
actor.spawn()
|
||||
|
||||
println("Noop Actor: ${actor.get()}")
|
||||
}
|
||||
|
||||
@Test
|
||||
fun registerActor() {
|
||||
val actor = object : Actor<Int, String>("registerActor", null) {
|
||||
@Suspendable
|
||||
override fun doRun(): String {
|
||||
return "Hello"
|
||||
}
|
||||
}
|
||||
|
||||
val actorRef = actor.spawn()
|
||||
actor.register()
|
||||
|
||||
val retrievedRef = ActorRegistry.getActor<ActorRef<Int>>("registerActor")
|
||||
|
||||
Assert.assertEquals(actorRef, retrievedRef)
|
||||
actor.join()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun registerActorNewName() {
|
||||
val actor = object : Actor<Int, String>(null, null) {
|
||||
@Suspendable
|
||||
override fun doRun(): String {
|
||||
return "Hello"
|
||||
}
|
||||
}
|
||||
|
||||
val actorRef = actor.spawn()
|
||||
actor.register("renamedActor")
|
||||
|
||||
val retrievedRef = ActorRegistry.getActor<ActorRef<Int>>("renamedActor")
|
||||
|
||||
Assert.assertEquals(actorRef, retrievedRef)
|
||||
actor.join()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun retrieveUnknownActor() {
|
||||
val retrievedRef = ActorRegistry.getActor<ActorRef<Int>>("unknownActor", 1, TimeUnit.SECONDS)
|
||||
|
||||
Assert.assertNull(retrievedRef)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun createSimpleActor() {
|
||||
val actor = object : Actor<Int, Void?>("simpleActor", null) {
|
||||
@Suspendable
|
||||
override fun doRun(): Void? {
|
||||
val msg = receive()
|
||||
LOG.info("SimpleActor Received Message: {}", msg)
|
||||
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
val actorRef = actor.spawn()
|
||||
|
||||
actorRef.send(1)
|
||||
|
||||
actor.join()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun createLoopingActor() {
|
||||
val actor = object : Actor<Int, Void?>("loopingActor", null) {
|
||||
@Suspendable
|
||||
override fun doRun(): Void? {
|
||||
while (true) {
|
||||
val msg = receive()
|
||||
|
||||
if (msg > 0) {
|
||||
LOG.info("LoopingActor Received Message: {}", msg)
|
||||
} else {
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
val actorRef = actor.spawn()
|
||||
|
||||
actorRef.send(3)
|
||||
actorRef.send(2)
|
||||
actorRef.send(1)
|
||||
actorRef.send(0)
|
||||
|
||||
actor.join()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun actorBacklog() {
|
||||
val actor = object : Actor<Int, String>("backlogActor", MailboxConfig(1, Channels.OverflowPolicy.THROW)) {
|
||||
@Suspendable
|
||||
override fun doRun(): String {
|
||||
TimeUnit.MILLISECONDS.sleep(500);
|
||||
LOG.info("Backlog Actor Received: {}", receive())
|
||||
|
||||
try {
|
||||
receive()
|
||||
} catch (e: Throwable) {
|
||||
LOG.info("==== Exception throws by receive() ====")
|
||||
e.printStackTrace()
|
||||
}
|
||||
|
||||
return "No Exception"
|
||||
}
|
||||
}
|
||||
|
||||
val actorRef = actor.spawn()
|
||||
|
||||
actorRef.send(1)
|
||||
actorRef.send(2)
|
||||
|
||||
try {
|
||||
LOG.info("Backlog Actor: {}", actor.get())
|
||||
} catch (e: Exception) {
|
||||
// Expected
|
||||
LOG.info("==== Exception throws by get() ====")
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun actorBacklogTrySend() {
|
||||
val actor = object : Actor<Int, String>("backlogTrySendActor", MailboxConfig(1, Channels.OverflowPolicy.THROW)) {
|
||||
@Suspendable
|
||||
override fun doRun(): String {
|
||||
TimeUnit.MILLISECONDS.sleep(500);
|
||||
LOG.info("Backlog TrySend Actor Received: {}", receive())
|
||||
|
||||
return "No Exception"
|
||||
}
|
||||
}
|
||||
|
||||
val actorRef = actor.spawn()
|
||||
|
||||
LOG.info("Backlog TrySend 1: {}", actorRef.trySend(1))
|
||||
LOG.info("Backlog TrySend 1: {}", actorRef.trySend(2))
|
||||
|
||||
actor.join()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun actorTimeoutReceive() {
|
||||
val actor = object : Actor<Int, String>("TimeoutReceiveActor", MailboxConfig(1, Channels.OverflowPolicy.THROW)) {
|
||||
@Suspendable
|
||||
override fun doRun(): String {
|
||||
LOG.info("Timeout Actor Received: {}", receive(500, TimeUnit.MILLISECONDS))
|
||||
|
||||
return "Finished"
|
||||
}
|
||||
}
|
||||
|
||||
val actorRef = actor.spawn()
|
||||
|
||||
TimeUnit.MILLISECONDS.sleep(300)
|
||||
actorRef.trySend(1)
|
||||
|
||||
actor.join()
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
fun actorNonBlockingReceive() {
|
||||
val actor = object : Actor<Int, String>("NonBlockingReceiveActor", MailboxConfig(1, Channels.OverflowPolicy.THROW)) {
|
||||
@Suspendable
|
||||
override fun doRun(): String {
|
||||
LOG.info("NonBlocking Actor Received #1: {}", tryReceive())
|
||||
TimeUnit.MILLISECONDS.sleep(500)
|
||||
LOG.info("NonBlocking Actor Received #2: {}", tryReceive())
|
||||
|
||||
return "Finished"
|
||||
}
|
||||
}
|
||||
|
||||
val actorRef = actor.spawn()
|
||||
|
||||
TimeUnit.MILLISECONDS.sleep(300)
|
||||
actorRef.trySend(1)
|
||||
|
||||
actor.join()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun evenActor() {
|
||||
val actor = object : Actor<Int, Void?>("EvenActor", null) {
|
||||
@Suspendable
|
||||
override fun filterMessage(m: Any?): Int? {
|
||||
return when (m) {
|
||||
is Int -> {
|
||||
if (m % 2 == 0) {
|
||||
m * 10
|
||||
} else {
|
||||
null
|
||||
}
|
||||
}
|
||||
else -> super.filterMessage(m)
|
||||
}
|
||||
}
|
||||
|
||||
@Suspendable
|
||||
override fun doRun(): Void? {
|
||||
while (true) {
|
||||
val msg = receive()
|
||||
|
||||
if (msg > 0) {
|
||||
LOG.info("EvenActor Received Message: {}", msg)
|
||||
} else {
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
val actorRef = actor.spawn()
|
||||
|
||||
actorRef.send(3)
|
||||
actorRef.send(2)
|
||||
actorRef.send(1)
|
||||
actorRef.send(0)
|
||||
|
||||
actor.join()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun watchingActors() {
|
||||
val watched = object : Actor<Int, Void?>("WatchedActor", null) {
|
||||
@Suspendable
|
||||
override fun doRun(): Void? {
|
||||
LOG.info("WatchedActor Starting")
|
||||
receive(500, TimeUnit.MILLISECONDS)
|
||||
LOG.info("WatchedActor Finishing")
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
val watcher = object : Actor<Int, Void?>("WatcherActor", null) {
|
||||
@Suspendable
|
||||
override fun doRun(): Void? {
|
||||
LOG.info("WatcherActor Listening")
|
||||
try {
|
||||
LOG.info("WatcherActor received Message: {}", receive(2, TimeUnit.SECONDS))
|
||||
} catch (e: Exception) {
|
||||
LOG.info("WatcherActor Received Exception", e)
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
@Suspendable
|
||||
override fun handleLifecycleMessage(m: LifecycleMessage?): Int? {
|
||||
LOG.info("WatcherActor Received Lifecycle Message: {}", m)
|
||||
return super.handleLifecycleMessage(m)
|
||||
}
|
||||
}
|
||||
|
||||
val watcherRef = watcher.spawn()
|
||||
TimeUnit.MILLISECONDS.sleep(200)
|
||||
|
||||
val watchedRef = watched.spawn()
|
||||
watcher.link(watchedRef)
|
||||
|
||||
watched.join()
|
||||
watcher.join()
|
||||
}
|
||||
}
|
@ -0,0 +1,135 @@
|
||||
package com.baeldung.quasar
|
||||
|
||||
import co.paralleluniverse.fibers.Suspendable
|
||||
import co.paralleluniverse.kotlin.fiber
|
||||
import co.paralleluniverse.strands.channels.Channels
|
||||
import co.paralleluniverse.strands.channels.Topic
|
||||
import co.paralleluniverse.strands.channels.reactivestreams.ReactiveStreams
|
||||
import org.junit.Test
|
||||
import org.reactivestreams.Subscriber
|
||||
import org.reactivestreams.Subscription
|
||||
import org.slf4j.LoggerFactory
|
||||
import java.util.concurrent.TimeUnit
|
||||
|
||||
class ReactiveStreamsTest {
|
||||
companion object {
|
||||
private val LOG = LoggerFactory.getLogger(ReactiveStreamsTest::class.java)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun publisher() {
|
||||
val inputChannel = Channels.newChannel<String>(1);
|
||||
|
||||
val publisher = ReactiveStreams.toPublisher(inputChannel)
|
||||
publisher.subscribe(object : Subscriber<String> {
|
||||
@Suspendable
|
||||
override fun onComplete() {
|
||||
LOG.info("onComplete")
|
||||
}
|
||||
|
||||
@Suspendable
|
||||
override fun onSubscribe(s: Subscription) {
|
||||
LOG.info("onSubscribe: {}", s)
|
||||
s.request(2)
|
||||
}
|
||||
|
||||
@Suspendable
|
||||
override fun onNext(t: String?) {
|
||||
LOG.info("onNext: {}", t)
|
||||
}
|
||||
|
||||
@Suspendable
|
||||
override fun onError(t: Throwable?) {
|
||||
LOG.info("onError: {}", t)
|
||||
}
|
||||
})
|
||||
|
||||
inputChannel.send("Hello")
|
||||
inputChannel.send("World")
|
||||
|
||||
TimeUnit.SECONDS.sleep(1)
|
||||
|
||||
inputChannel.close()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun publisherTopic() {
|
||||
val inputTopic = Topic<String>()
|
||||
|
||||
val publisher = ReactiveStreams.toPublisher(inputTopic)
|
||||
publisher.subscribe(object : Subscriber<String> {
|
||||
@Suspendable
|
||||
override fun onComplete() {
|
||||
LOG.info("onComplete 1")
|
||||
}
|
||||
|
||||
@Suspendable
|
||||
override fun onSubscribe(s: Subscription) {
|
||||
LOG.info("onSubscribe 1: {}", s)
|
||||
s.request(2)
|
||||
}
|
||||
|
||||
@Suspendable
|
||||
override fun onNext(t: String?) {
|
||||
LOG.info("onNext 1: {}", t)
|
||||
}
|
||||
|
||||
@Suspendable
|
||||
override fun onError(t: Throwable?) {
|
||||
LOG.info("onError 1: {}", t)
|
||||
}
|
||||
})
|
||||
publisher.subscribe(object : Subscriber<String> {
|
||||
@Suspendable
|
||||
override fun onComplete() {
|
||||
LOG.info("onComplete 2")
|
||||
}
|
||||
|
||||
@Suspendable
|
||||
override fun onSubscribe(s: Subscription) {
|
||||
LOG.info("onSubscribe 2: {}", s)
|
||||
s.request(2)
|
||||
}
|
||||
|
||||
@Suspendable
|
||||
override fun onNext(t: String?) {
|
||||
LOG.info("onNext 2: {}", t)
|
||||
}
|
||||
|
||||
@Suspendable
|
||||
override fun onError(t: Throwable?) {
|
||||
LOG.info("onError 2: {}", t)
|
||||
}
|
||||
})
|
||||
|
||||
inputTopic.send("Hello")
|
||||
inputTopic.send("World")
|
||||
|
||||
TimeUnit.SECONDS.sleep(1)
|
||||
|
||||
inputTopic.close()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun subscribe() {
|
||||
val inputChannel = Channels.newChannel<String>(10);
|
||||
val publisher = ReactiveStreams.toPublisher(inputChannel)
|
||||
|
||||
val channel = ReactiveStreams.subscribe(10, Channels.OverflowPolicy.THROW, publisher)
|
||||
|
||||
fiber @Suspendable {
|
||||
while (!channel.isClosed) {
|
||||
val message = channel.receive()
|
||||
LOG.info("Received: {}", message)
|
||||
}
|
||||
LOG.info("Stopped receiving messages")
|
||||
}
|
||||
|
||||
inputChannel.send("Hello")
|
||||
inputChannel.send("World")
|
||||
|
||||
TimeUnit.SECONDS.sleep(1)
|
||||
|
||||
inputChannel.close()
|
||||
}
|
||||
}
|
@ -5,3 +5,6 @@
|
||||
- [Guide to Classgraph Library](https://www.baeldung.com/classgraph)
|
||||
- [Create a Java Command Line Program with Picocli](https://www.baeldung.com/java-picocli-create-command-line-program)
|
||||
- [Guide to Java Parallel Collectors Library](https://www.baeldung.com/java-parallel-collectors)
|
||||
- [Templating with Handlebars](https://www.baeldung.com/handlebars)
|
||||
- [A Guide to Crawler4j](https://www.baeldung.com/crawler4j)
|
||||
- [Decode an OkHttp JSON Response](https://www.baeldung.com/okhttp-json-response)
|
||||
|
@ -5,11 +5,13 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>libraries2</artifactId>
|
||||
<name>libraries2</name>
|
||||
|
||||
<parent>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<artifactId>parent-modules</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>jboss-public-repository-group</id>
|
||||
@ -25,6 +27,7 @@
|
||||
</snapshots>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.mapdb</groupId>
|
||||
@ -34,7 +37,7 @@
|
||||
<dependency>
|
||||
<groupId>com.pivovarit</groupId>
|
||||
<artifactId>parallel-collectors</artifactId>
|
||||
<version>1.1.0</version>
|
||||
<version>${parallel-collectors.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.assertj</groupId>
|
||||
@ -96,22 +99,22 @@
|
||||
<dependency>
|
||||
<groupId>com.squareup.okhttp3</groupId>
|
||||
<artifactId>okhttp</artifactId>
|
||||
<version>3.14.2</version>
|
||||
<version>${okhttp.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-databind</artifactId>
|
||||
<version>2.9.9</version>
|
||||
<version>${jackson.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.code.gson</groupId>
|
||||
<artifactId>gson</artifactId>
|
||||
<version>2.8.5</version>
|
||||
<version>${gson.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.squareup.okhttp3</groupId>
|
||||
<artifactId>mockwebserver</artifactId>
|
||||
<version>3.14.2</version>
|
||||
<version>${mockwebserver.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
@ -122,7 +125,7 @@
|
||||
<dependency>
|
||||
<groupId>com.github.jknack</groupId>
|
||||
<artifactId>handlebars</artifactId>
|
||||
<version>4.1.2</version>
|
||||
<version>${handlebars.version}</version>
|
||||
</dependency>
|
||||
<!-- Benchmarking -->
|
||||
<dependency>
|
||||
@ -141,6 +144,7 @@
|
||||
<version>${mesos.library.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<properties>
|
||||
<mapdb.version>3.0.7</mapdb.version>
|
||||
<assertj.version>3.6.2</assertj.version>
|
||||
@ -156,5 +160,10 @@
|
||||
<la4j.version>0.6.0</la4j.version>
|
||||
<jmh.version>1.19</jmh.version>
|
||||
<mesos.library.version>0.28.3</mesos.library.version>
|
||||
<parallel-collectors.version>1.1.0</parallel-collectors.version>
|
||||
<okhttp.version>3.14.2</okhttp.version>
|
||||
<gson.version>2.8.5</gson.version>
|
||||
<mockwebserver.version>3.14.2</mockwebserver.version>
|
||||
<handlebars.version>4.1.2</handlebars.version>
|
||||
</properties>
|
||||
</project>
|
||||
|
7
libraries-http/README.md
Normal file
7
libraries-http/README.md
Normal file
@ -0,0 +1,7 @@
|
||||
|
||||
### Relevant Articles:
|
||||
|
||||
- [A Guide to OkHttp](http://www.baeldung.com/guide-to-okhttp)
|
||||
- [A Guide to Google-Http-Client](http://www.baeldung.com/google-http-client)
|
||||
- [Asynchronous HTTP with async-http-client in Java](http://www.baeldung.com/async-http-client)
|
||||
- [WebSockets with AsyncHttpClient](http://www.baeldung.com/async-http-client-websockets)
|
81
libraries-http/pom.xml
Normal file
81
libraries-http/pom.xml
Normal file
@ -0,0 +1,81 @@
|
||||
<?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>libraries-http</artifactId>
|
||||
<name>libraries-http</name>
|
||||
|
||||
<parent>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<artifactId>parent-modules</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.assertj</groupId>
|
||||
<artifactId>assertj-core</artifactId>
|
||||
<version>${assertj.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Dependencies for response decoder with okhttp -->
|
||||
<dependency>
|
||||
<groupId>com.squareup.okhttp3</groupId>
|
||||
<artifactId>okhttp</artifactId>
|
||||
<version>${com.squareup.okhttp3.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Dependencies for google http client -->
|
||||
<dependency>
|
||||
<groupId>com.google.http-client</groupId>
|
||||
<artifactId>google-http-client</artifactId>
|
||||
<version>${googleclient.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.http-client</groupId>
|
||||
<artifactId>google-http-client-jackson2</artifactId>
|
||||
<version>${googleclient.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.http-client</groupId>
|
||||
<artifactId>google-http-client-gson</artifactId>
|
||||
<version>${googleclient.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- https://mvnrepository.com/artifact/org.asynchttpclient/async-http-client -->
|
||||
<dependency>
|
||||
<groupId>org.asynchttpclient</groupId>
|
||||
<artifactId>async-http-client</artifactId>
|
||||
<version>${async.http.client.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-databind</artifactId>
|
||||
<version>${jackson.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.google.code.gson</groupId>
|
||||
<artifactId>gson</artifactId>
|
||||
<version>2.8.5</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.squareup.okhttp3</groupId>
|
||||
<artifactId>mockwebserver</artifactId>
|
||||
<version>${com.squareup.okhttp3.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<properties>
|
||||
<assertj.version>3.6.2</assertj.version>
|
||||
<com.squareup.okhttp3.version>3.14.2</com.squareup.okhttp3.version>
|
||||
<googleclient.version>1.23.0</googleclient.version>
|
||||
<async.http.client.version>2.2.0</async.http.client.version>
|
||||
</properties>
|
||||
</project>
|
13
libraries-http/src/main/resources/logback.xml
Normal file
13
libraries-http/src/main/resources/logback.xml
Normal file
@ -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>
|
@ -19,6 +19,9 @@ import okhttp3.Response;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* Execute <code>spring-rest</code> module before running this live test
|
||||
*/
|
||||
public class OkHttpFileUploadingLiveTest {
|
||||
|
||||
private static final String BASE_URL = "http://localhost:" + APPLICATION_PORT + "/spring-rest";
|
@ -17,6 +17,9 @@ import okhttp3.Response;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* Execute <code>spring-rest</code> module before running this live test
|
||||
*/
|
||||
public class OkHttpGetLiveTest {
|
||||
|
||||
private static final String BASE_URL = "http://localhost:" + APPLICATION_PORT + "/spring-rest";
|
@ -20,6 +20,9 @@ import org.junit.Test;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* Execute <code>spring-rest</code> module before running this live test
|
||||
*/
|
||||
public class OkHttpMiscLiveTest {
|
||||
|
||||
private static final String BASE_URL = "http://localhost:" + APPLICATION_PORT + "/spring-rest";
|
@ -20,6 +20,9 @@ import okhttp3.Response;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* Execute <code>spring-rest</code> module before running this live test
|
||||
*/
|
||||
public class OkHttpPostingLiveTest {
|
||||
|
||||
private static final String BASE_URL = "http://localhost:" + APPLICATION_PORT + "/spring-rest";
|
@ -36,14 +36,11 @@
|
||||
- [Introduction To Docx4J](http://www.baeldung.com/docx4j)
|
||||
- [Introduction to StreamEx](http://www.baeldung.com/streamex)
|
||||
- [Introduction to BouncyCastle with Java](http://www.baeldung.com/java-bouncy-castle)
|
||||
- [A Guide to Google-Http-Client](http://www.baeldung.com/google-http-client)
|
||||
- [Interact with Google Sheets from Java](http://www.baeldung.com/google-sheets-java-client)
|
||||
- [A Docker Guide for Java](http://www.baeldung.com/docker-java-api)
|
||||
- [Introduction To OpenCSV](http://www.baeldung.com/opencsv)
|
||||
- [Introduction to Akka Actors in Java](http://www.baeldung.com/akka-actors-java)
|
||||
- [Asynchronous HTTP with async-http-client in Java](http://www.baeldung.com/async-http-client)
|
||||
- [Introduction to Smooks](http://www.baeldung.com/smooks)
|
||||
- [WebSockets with AsyncHttpClient](http://www.baeldung.com/async-http-client-websockets)
|
||||
- [A Guide to Infinispan in Java](http://www.baeldung.com/infinispan)
|
||||
- [Introduction to OpenCSV](http://www.baeldung.com/opencsv)
|
||||
- [A Guide to Unirest](http://www.baeldung.com/unirest)
|
||||
|
@ -18,23 +18,12 @@
|
||||
<artifactId>akka-actor_2.12</artifactId>
|
||||
<version>${typesafe-akka.version}</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>com.typesafe.akka</groupId>
|
||||
<artifactId>akka-testkit_2.12</artifactId>
|
||||
<version>${typesafe-akka.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- https://mvnrepository.com/artifact/org.asynchttpclient/async-http-client -->
|
||||
<dependency>
|
||||
<groupId>org.asynchttpclient</groupId>
|
||||
<artifactId>async-http-client</artifactId>
|
||||
<version>${async.http.client.version}</version>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/org.beykery/neuroph/2.92 -->
|
||||
<dependency>
|
||||
<groupId>org.beykery</groupId>
|
||||
@ -875,7 +864,6 @@
|
||||
<kafka.version>2.0.0</kafka.version>
|
||||
<smooks.version>1.7.0</smooks.version>
|
||||
<docker.version>3.0.14</docker.version>
|
||||
<async.http.client.version>2.2.0</async.http.client.version>
|
||||
<infinispan.version>9.1.5.Final</infinispan.version>
|
||||
<opencsv.version>4.1</opencsv.version>
|
||||
<unirest.version>1.4.9</unirest.version>
|
||||
|
@ -1,14 +1,15 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>com.baeldung.multimodule-maven-project</groupId>
|
||||
<artifactId>multimodule-maven-project</artifactId>
|
||||
<version>1.0</version>
|
||||
</parent>
|
||||
<groupId>com.baeldung.daomodule</groupId>
|
||||
<artifactId>daomodule</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
<version>1.0</version>
|
||||
<name>daomodule</name>
|
||||
|
||||
<parent>
|
||||
<groupId>com.baeldung.multimodule-maven-project</groupId>
|
||||
<artifactId>multimodule-maven-project</artifactId>
|
||||
<version>1.0</version>
|
||||
</parent>
|
||||
</project>
|
||||
|
@ -1,16 +1,18 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>com.baeldung.multimodule-maven-project</groupId>
|
||||
<artifactId>multimodule-maven-project</artifactId>
|
||||
<version>1.0</version>
|
||||
</parent>
|
||||
<groupId>com.baeldung.entitymodule</groupId>
|
||||
<artifactId>entitymodule</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
<version>1.0</version>
|
||||
<name>entitymodule</name>
|
||||
|
||||
<parent>
|
||||
<groupId>com.baeldung.multimodule-maven-project</groupId>
|
||||
<artifactId>multimodule-maven-project</artifactId>
|
||||
<version>1.0</version>
|
||||
</parent>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>11</maven.compiler.source>
|
||||
<maven.compiler.target>11</maven.compiler.target>
|
||||
|
@ -1,16 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>com.baeldung.multimodule-maven-project</groupId>
|
||||
<artifactId>multimodule-maven-project</artifactId>
|
||||
<version>1.0</version>
|
||||
</parent>
|
||||
<groupId>com.baeldung.mainappmodule</groupId>
|
||||
<artifactId>mainappmodule</artifactId>
|
||||
<version>1.0</version>
|
||||
<packaging>jar</packaging>
|
||||
<name>mainappmodule</name>
|
||||
|
||||
<parent>
|
||||
<groupId>com.baeldung.multimodule-maven-project</groupId>
|
||||
<artifactId>multimodule-maven-project</artifactId>
|
||||
<version>1.0</version>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
|
@ -6,12 +6,20 @@
|
||||
<version>1.0</version>
|
||||
<packaging>pom</packaging>
|
||||
<name>multimodule-maven-project</name>
|
||||
|
||||
<parent>
|
||||
<groupId>com.baeldung.maven-java-11</groupId>
|
||||
<artifactId>maven-java-11</artifactId>
|
||||
<version>1.0</version>
|
||||
</parent>
|
||||
|
||||
<modules>
|
||||
<module>entitymodule</module>
|
||||
<module>daomodule</module>
|
||||
<module>userdaomodule</module>
|
||||
<module>mainappmodule</module>
|
||||
</modules>
|
||||
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
@ -45,13 +53,6 @@
|
||||
</pluginManagement>
|
||||
</build>
|
||||
|
||||
<modules>
|
||||
<module>entitymodule</module>
|
||||
<module>daomodule</module>
|
||||
<module>userdaomodule</module>
|
||||
<module>mainappmodule</module>
|
||||
</modules>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
@ -1,16 +1,18 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>com.baeldung.multimodule-maven-project</groupId>
|
||||
<artifactId>multimodule-maven-project</artifactId>
|
||||
<version>1.0</version>
|
||||
</parent>
|
||||
<groupId>com.baeldung.userdaomodule</groupId>
|
||||
<artifactId>userdaomodule</artifactId>
|
||||
<version>1.0</version>
|
||||
<packaging>jar</packaging>
|
||||
<name>userdaomodule</name>
|
||||
|
||||
<parent>
|
||||
<groupId>com.baeldung.multimodule-maven-project</groupId>
|
||||
<artifactId>multimodule-maven-project</artifactId>
|
||||
<version>1.0</version>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.baeldung.entitymodule</groupId>
|
||||
|
@ -6,14 +6,17 @@
|
||||
<version>1.0</version>
|
||||
<packaging>pom</packaging>
|
||||
<name>maven-java-11</name>
|
||||
|
||||
<parent>
|
||||
<artifactId>parent-modules</artifactId>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
<artifactId>parent-modules</artifactId>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<modules>
|
||||
<module>multimodule-maven-project</module>
|
||||
</modules>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<maven.compiler.source>11</maven.compiler.source>
|
||||
|
@ -4,12 +4,13 @@
|
||||
<groupId>com.baeldung</groupId>
|
||||
<artifactId>maven</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<name>maven</name>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
<modules>
|
||||
<module>custom-rule</module>
|
||||
<module>maven-enforcer</module>
|
||||
</modules>
|
||||
<name>maven</name>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
|
@ -11,19 +11,19 @@
|
||||
<dependency>
|
||||
<groupId>commons-io</groupId>
|
||||
<artifactId>commons-io</artifactId>
|
||||
<version>2.3</version>
|
||||
<version>${commons-io.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-collections4</artifactId>
|
||||
<version>4.0</version>
|
||||
<version>${commons-collections4.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
<version>3.0</version>
|
||||
<version>${commons-lang3.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
@ -35,7 +35,7 @@
|
||||
<dependency>
|
||||
<groupId>commons-beanutils</groupId>
|
||||
<artifactId>commons-beanutils</artifactId>
|
||||
<version>1.9.1-SNAPSHOT</version>
|
||||
<version>${commons-beanutils.version}</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
@ -71,6 +71,10 @@
|
||||
|
||||
<properties>
|
||||
<commons-compress-version>1.15</commons-compress-version>
|
||||
<commons-io.version>2.3</commons-io.version>
|
||||
<commons-collections4.version>4.0</commons-collections4.version>
|
||||
<commons-lang3.version>3.0</commons-lang3.version>
|
||||
<commons-beanutils.version>1.9.1</commons-beanutils.version>
|
||||
</properties>
|
||||
|
||||
</project>
|
@ -6,10 +6,6 @@
|
||||
<artifactId>versions-maven-plugin</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<name>versions-maven-plugin</name>
|
||||
|
||||
<properties>
|
||||
<commons-compress-version>1.15</commons-compress-version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
|
||||
@ -73,5 +69,9 @@
|
||||
</snapshots>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<properties>
|
||||
<commons-compress-version>1.15</commons-compress-version>
|
||||
</properties>
|
||||
|
||||
</project>
|
3
morphia/README.md
Normal file
3
morphia/README.md
Normal file
@ -0,0 +1,3 @@
|
||||
### Relevant Articles:
|
||||
|
||||
- [Intro to Morphia](http://www.baeldung.com/intro-to-morphia)
|
43
morphia/pom.xml
Normal file
43
morphia/pom.xml
Normal file
@ -0,0 +1,43 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
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.morphia</groupId>
|
||||
<artifactId>morphia</artifactId>
|
||||
<name>morphia</name>
|
||||
|
||||
<parent>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<artifactId>parent-modules</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
<relativePath>..</relativePath>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>dev.morphia.morphia</groupId>
|
||||
<artifactId>core</artifactId>
|
||||
<version>${morphia.version}</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<pluginManagement>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<version>${spring-boot-maven-plugin.version}</version>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</pluginManagement>
|
||||
</build>
|
||||
|
||||
<properties>
|
||||
<spring-boot-maven-plugin.version>1.4.2.RELEASE</spring-boot-maven-plugin.version>
|
||||
<morphia.version>1.5.3</morphia.version>
|
||||
</properties>
|
||||
|
||||
</project>
|
@ -0,0 +1,31 @@
|
||||
package com.baeldung.morphia.domain;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import dev.morphia.annotations.Entity;
|
||||
import dev.morphia.annotations.Id;
|
||||
|
||||
@Entity
|
||||
public class Author {
|
||||
|
||||
@Id
|
||||
private String name;
|
||||
private List<String> books;
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public List<String> getBooks() {
|
||||
return books;
|
||||
}
|
||||
|
||||
public void setBooks(List<String> books) {
|
||||
this.books = books;
|
||||
}
|
||||
|
||||
}
|
116
morphia/src/main/java/com/baeldung/morphia/domain/Book.java
Normal file
116
morphia/src/main/java/com/baeldung/morphia/domain/Book.java
Normal file
@ -0,0 +1,116 @@
|
||||
package com.baeldung.morphia.domain;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import dev.morphia.annotations.Embedded;
|
||||
import dev.morphia.annotations.Entity;
|
||||
import dev.morphia.annotations.Field;
|
||||
import dev.morphia.annotations.Id;
|
||||
import dev.morphia.annotations.Index;
|
||||
import dev.morphia.annotations.IndexOptions;
|
||||
import dev.morphia.annotations.Indexes;
|
||||
import dev.morphia.annotations.Property;
|
||||
import dev.morphia.annotations.Reference;
|
||||
import dev.morphia.annotations.Validation;
|
||||
|
||||
@Entity("Books")
|
||||
@Indexes({ @Index(fields = @Field("title"), options = @IndexOptions(name = "book_title")) })
|
||||
@Validation("{ price : { $gt : 0 } }")
|
||||
public class Book {
|
||||
@Id
|
||||
private String isbn;
|
||||
@Property
|
||||
private String title;
|
||||
private String author;
|
||||
@Embedded
|
||||
private Publisher publisher;
|
||||
@Property("price")
|
||||
private double cost;
|
||||
@Reference
|
||||
private Set<Book> companionBooks;
|
||||
|
||||
public Book() {
|
||||
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public String getAuthor() {
|
||||
return author;
|
||||
}
|
||||
|
||||
public double getCost() {
|
||||
return cost;
|
||||
}
|
||||
|
||||
public void addCompanionBooks(Book book) {
|
||||
if (companionBooks != null)
|
||||
this.companionBooks.add(book);
|
||||
}
|
||||
|
||||
public Book(String isbn, String title, String author, double cost, Publisher publisher) {
|
||||
this.isbn = isbn;
|
||||
this.title = title;
|
||||
this.author = author;
|
||||
this.cost = cost;
|
||||
this.publisher = publisher;
|
||||
this.companionBooks = new HashSet<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Book [isbn=" + isbn + ", title=" + title + ", author=" + author + ", publisher=" + publisher + ", cost=" + cost + "]";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((author == null) ? 0 : author.hashCode());
|
||||
long temp;
|
||||
temp = Double.doubleToLongBits(cost);
|
||||
result = prime * result + (int) (temp ^ (temp >>> 32));
|
||||
result = prime * result + ((isbn == null) ? 0 : isbn.hashCode());
|
||||
result = prime * result + ((publisher == null) ? 0 : publisher.hashCode());
|
||||
result = prime * result + ((title == null) ? 0 : title.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
Book other = (Book) obj;
|
||||
if (author == null) {
|
||||
if (other.author != null)
|
||||
return false;
|
||||
} else if (!author.equals(other.author))
|
||||
return false;
|
||||
if (Double.doubleToLongBits(cost) != Double.doubleToLongBits(other.cost))
|
||||
return false;
|
||||
if (isbn == null) {
|
||||
if (other.isbn != null)
|
||||
return false;
|
||||
} else if (!isbn.equals(other.isbn))
|
||||
return false;
|
||||
if (publisher == null) {
|
||||
if (other.publisher != null)
|
||||
return false;
|
||||
} else if (!publisher.equals(other.publisher))
|
||||
return false;
|
||||
if (title == null) {
|
||||
if (other.title != null)
|
||||
return false;
|
||||
} else if (!title.equals(other.title))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,70 @@
|
||||
package com.baeldung.morphia.domain;
|
||||
|
||||
import org.bson.types.ObjectId;
|
||||
|
||||
import dev.morphia.annotations.Entity;
|
||||
import dev.morphia.annotations.Id;
|
||||
|
||||
@Entity
|
||||
public class Publisher {
|
||||
|
||||
@Id
|
||||
private ObjectId id;
|
||||
private String name;
|
||||
|
||||
public Publisher() {
|
||||
|
||||
}
|
||||
|
||||
public Publisher(ObjectId id, String name) {
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public ObjectId getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(ObjectId id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Catalog [id=" + id + ", name=" + name + "]";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((name == null) ? 0 : name.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
Publisher other = (Publisher) obj;
|
||||
if (name == null) {
|
||||
if (other.name != null)
|
||||
return false;
|
||||
} else if (!name.equals(other.name))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
13
morphia/src/main/resources/logback.xml
Normal file
13
morphia/src/main/resources/logback.xml
Normal file
@ -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,130 @@
|
||||
package com.baeldung.morphia;
|
||||
|
||||
import static dev.morphia.aggregation.Group.grouping;
|
||||
import static dev.morphia.aggregation.Group.push;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import org.bson.types.ObjectId;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import com.baeldung.morphia.domain.Author;
|
||||
import com.baeldung.morphia.domain.Book;
|
||||
import com.baeldung.morphia.domain.Publisher;
|
||||
import com.mongodb.MongoClient;
|
||||
|
||||
import dev.morphia.Datastore;
|
||||
import dev.morphia.Morphia;
|
||||
import dev.morphia.query.Query;
|
||||
import dev.morphia.query.UpdateOperations;
|
||||
|
||||
@Ignore
|
||||
public class MorphiaIntegrationTest {
|
||||
|
||||
private static Datastore datastore;
|
||||
private static ObjectId id = new ObjectId();
|
||||
|
||||
@BeforeClass
|
||||
public static void setUp() {
|
||||
Morphia morphia = new Morphia();
|
||||
morphia.mapPackage("com.baeldung.morphia");
|
||||
datastore = morphia.createDatastore(new MongoClient(), "library");
|
||||
datastore.ensureIndexes();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenDataSource_whenCreateEntity_thenEntityCreated() {
|
||||
Publisher publisher = new Publisher(id, "Awsome Publisher");
|
||||
Book book = new Book("9781565927186", "Learning Java", "Tom Kirkman", 3.95, publisher);
|
||||
Book companionBook = new Book("9789332575103", "Java Performance Companion", "Tom Kirkman", 1.95, publisher);
|
||||
book.addCompanionBooks(companionBook);
|
||||
datastore.save(companionBook);
|
||||
datastore.save(book);
|
||||
|
||||
List<Book> books = datastore.createQuery(Book.class)
|
||||
.field("title")
|
||||
.contains("Learning Java")
|
||||
.find()
|
||||
.toList();
|
||||
assertEquals(books.size(), 1);
|
||||
assertEquals(books.get(0), book);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenDocument_whenUpdated_thenUpdateReflected() {
|
||||
Publisher publisher = new Publisher(id, "Awsome Publisher");
|
||||
Book book = new Book("9781565927186", "Learning Java", "Tom Kirkman", 3.95, publisher);
|
||||
datastore.save(book);
|
||||
Query<Book> query = datastore.createQuery(Book.class)
|
||||
.field("title")
|
||||
.contains("Learning Java");
|
||||
UpdateOperations<Book> updates = datastore.createUpdateOperations(Book.class)
|
||||
.inc("price", 1);
|
||||
datastore.update(query, updates);
|
||||
List<Book> books = datastore.createQuery(Book.class)
|
||||
.field("title")
|
||||
.contains("Learning Java")
|
||||
.find()
|
||||
.toList();
|
||||
assertEquals(books.get(0)
|
||||
.getCost(), 4.95);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenDocument_whenDeleted_thenDeleteReflected() {
|
||||
Publisher publisher = new Publisher(id, "Awsome Publisher");
|
||||
Book book = new Book("9781565927186", "Learning Java", "Tom Kirkman", 3.95, publisher);
|
||||
datastore.save(book);
|
||||
Query<Book> query = datastore.createQuery(Book.class)
|
||||
.field("title")
|
||||
.contains("Learning Java");
|
||||
datastore.delete(query);
|
||||
List<Book> books = datastore.createQuery(Book.class)
|
||||
.field("title")
|
||||
.contains("Learning Java")
|
||||
.find()
|
||||
.toList();
|
||||
assertEquals(books.size(), 0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenDocument_whenAggregated_thenResultsCollected() {
|
||||
Publisher publisher = new Publisher(id, "Awsome Publisher");
|
||||
datastore.save(new Book("9781565927186", "Learning Java", "Tom Kirkman", 3.95, publisher));
|
||||
datastore.save(new Book("9781449313142", "Learning Perl", "Mark Pence", 2.95, publisher));
|
||||
datastore.save(new Book("9787564100476", "Learning Python", "Mark Pence", 5.95, publisher));
|
||||
datastore.save(new Book("9781449368814", "Learning Scala", "Mark Pence", 6.95, publisher));
|
||||
datastore.save(new Book("9781784392338", "Learning Go", "Jonathan Sawyer", 8.95, publisher));
|
||||
|
||||
Iterator<Author> authors = datastore.createAggregation(Book.class)
|
||||
.group("author", grouping("books", push("title")))
|
||||
.out(Author.class);
|
||||
|
||||
assertTrue(authors.hasNext());
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenDocument_whenProjected_thenOnlyProjectionReceived() {
|
||||
Publisher publisher = new Publisher(id, "Awsome Publisher");
|
||||
Book book = new Book("9781565927186", "Learning Java", "Tom Kirkman", 3.95, publisher);
|
||||
datastore.save(book);
|
||||
List<Book> books = datastore.createQuery(Book.class)
|
||||
.field("title")
|
||||
.contains("Learning Java")
|
||||
.project("title", true)
|
||||
.find()
|
||||
.toList();
|
||||
assertEquals(books.size(), 1);
|
||||
assertEquals("Learning Java", books.get(0)
|
||||
.getTitle());
|
||||
assertEquals(null, books.get(0)
|
||||
.getAuthor());
|
||||
}
|
||||
|
||||
}
|
@ -23,6 +23,7 @@
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.wso2.msf4j</groupId>
|
||||
|
@ -18,11 +18,6 @@
|
||||
<artifactId>optaplanner-core</artifactId>
|
||||
<version>7.9.0.Final</version>
|
||||
</dependency>
|
||||
|
||||
<!--<dependency>-->
|
||||
<!--<groupId></groupId>-->
|
||||
<!--<artifactId></artifactId>-->
|
||||
<!--</dependency>-->
|
||||
</dependencies>
|
||||
|
||||
</project>
|
@ -1,9 +1,9 @@
|
||||
<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">
|
||||
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>parent-boot-2</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<name>parent-boot-2</name>
|
||||
<name>parent-boot-2</name>
|
||||
<packaging>pom</packaging>
|
||||
<description>Parent for all Spring Boot 2 modules</description>
|
||||
|
||||
@ -13,7 +13,7 @@
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<dependencyManagement>
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
@ -28,7 +28,7 @@
|
||||
<dependency>
|
||||
<groupId>io.rest-assured</groupId>
|
||||
<artifactId>rest-assured</artifactId>
|
||||
</dependency>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
@ -36,22 +36,22 @@
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<pluginManagement>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<version>${spring-boot.version}</version>
|
||||
<configuration>
|
||||
<mainClass>${start-class}</mainClass>
|
||||
<!-- this is necessary as we're not using the Boot parent -->
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</pluginManagement>
|
||||
</build>
|
||||
|
||||
<build>
|
||||
<pluginManagement>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<version>${spring-boot.version}</version>
|
||||
<configuration>
|
||||
<mainClass>${start-class}</mainClass>
|
||||
<!-- this is necessary as we're not using the Boot parent -->
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</pluginManagement>
|
||||
</build>
|
||||
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>thin-jar</id>
|
||||
@ -75,9 +75,9 @@
|
||||
</profiles>
|
||||
|
||||
<properties>
|
||||
<rest-assured.version>3.1.0</rest-assured.version>
|
||||
<rest-assured.version>3.3.0</rest-assured.version>
|
||||
<!-- plugins -->
|
||||
<thin.version>1.0.21.RELEASE</thin.version>
|
||||
<spring-boot.version>2.1.3.RELEASE</spring-boot.version>
|
||||
<thin.version>1.0.22.RELEASE</thin.version>
|
||||
<spring-boot.version>2.1.6.RELEASE</spring-boot.version>
|
||||
</properties>
|
||||
</project>
|
||||
|
@ -13,13 +13,6 @@
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<properties>
|
||||
<rest-assured.version>3.1.0</rest-assured.version>
|
||||
<!-- plugins -->
|
||||
<thin.version>1.0.21.RELEASE</thin.version>
|
||||
<spring-boot.version>2.2.0.M3</spring-boot.version>
|
||||
</properties>
|
||||
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
@ -31,6 +24,7 @@
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>io.rest-assured</groupId>
|
||||
@ -88,4 +82,11 @@
|
||||
</build>
|
||||
</profile>
|
||||
</profiles>
|
||||
|
||||
<properties>
|
||||
<rest-assured.version>3.1.0</rest-assured.version>
|
||||
<!-- plugins -->
|
||||
<thin.version>1.0.21.RELEASE</thin.version>
|
||||
<spring-boot.version>2.2.0.M3</spring-boot.version>
|
||||
</properties>
|
||||
</project>
|
||||
|
@ -48,6 +48,7 @@
|
||||
<version>${grep4j.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<maven.compiler.source>1.8</maven.compiler.source>
|
||||
|
@ -19,13 +19,13 @@
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>4.12</version>
|
||||
<version>${junit.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.assertj</groupId>
|
||||
<artifactId>assertj-core</artifactId>
|
||||
<version>3.12.1</version>
|
||||
<version>${assertj-core.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
@ -34,6 +34,7 @@
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<maven.compiler.source>11</maven.compiler.source>
|
||||
<maven.compiler.target>11</maven.compiler.target>
|
||||
<assertj-core.version>3.12.1</assertj-core.version>
|
||||
</properties>
|
||||
|
||||
</project>
|
||||
|
3
persistence-modules/elasticsearch/README.md
Normal file
3
persistence-modules/elasticsearch/README.md
Normal file
@ -0,0 +1,3 @@
|
||||
### Relevant Articles
|
||||
|
||||
- [Jest – Elasticsearch Java Client](https://www.baeldung.com/elasticsearch-jest)
|
@ -20,12 +20,16 @@
|
||||
<dependency>
|
||||
<groupId>io.searchbox</groupId>
|
||||
<artifactId>jest</artifactId>
|
||||
<version>6.3.1</version>
|
||||
<version>${jest.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-databind</artifactId>
|
||||
<version>2.9.6</version>
|
||||
<version>${jackson.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<properties>
|
||||
<jest.version>6.3.1</jest.version>
|
||||
</properties>
|
||||
</project>
|
||||
|
@ -3,3 +3,4 @@
|
||||
|
||||
- [Persisting Maps with Hibernate](https://www.baeldung.com/hibernate-persisting-maps)
|
||||
- [Difference Between @Size, @Length, and @Column(length=value)](https://www.baeldung.com/jpa-size-length-column-differences)
|
||||
- [Hibernate Validator Specific Constraints](https://www.baeldung.com/hibernate-validator-constraints)
|
||||
|
@ -2,6 +2,9 @@
|
||||
<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">
|
||||
<artifactId>hibernate-mapping</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>com.baeldung</groupId>
|
||||
@ -10,10 +13,6 @@
|
||||
<relativePath>..</relativePath>
|
||||
</parent>
|
||||
|
||||
<artifactId>hibernate-mapping</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.hibernate</groupId>
|
||||
@ -45,12 +44,12 @@
|
||||
<dependency>
|
||||
<groupId>javax.money</groupId>
|
||||
<artifactId>money-api</artifactId>
|
||||
<version>1.0.3</version>
|
||||
<version>${money-api.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.javamoney</groupId>
|
||||
<artifactId>moneta</artifactId>
|
||||
<version>1.3</version>
|
||||
<version>${moneta.version}</version>
|
||||
<type>pom</type>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
@ -70,6 +69,8 @@
|
||||
<assertj-core.version>3.8.0</assertj-core.version>
|
||||
<hibernate-validator.version>6.0.16.Final</hibernate-validator.version>
|
||||
<org.glassfish.javax.el.version>3.0.1-b11</org.glassfish.javax.el.version>
|
||||
<money-api.version>1.0.3</money-api.version>
|
||||
<moneta.version>1.3</moneta.version>
|
||||
</properties>
|
||||
|
||||
</project>
|
||||
|
@ -19,31 +19,31 @@
|
||||
<dependency>
|
||||
<groupId>org.hibernate.ogm</groupId>
|
||||
<artifactId>hibernate-ogm-mongodb</artifactId>
|
||||
<version>5.4.0.Final</version>
|
||||
<version>${hibernate.version}</version>
|
||||
</dependency>
|
||||
<!-- Neo4j -->
|
||||
<dependency>
|
||||
<groupId>org.hibernate.ogm</groupId>
|
||||
<artifactId>hibernate-ogm-neo4j</artifactId>
|
||||
<version>5.4.0.Final</version>
|
||||
<version>${hibernate.version}</version>
|
||||
</dependency>
|
||||
<!-- Narayana JTA -->
|
||||
<dependency>
|
||||
<groupId>org.jboss.narayana.jta</groupId>
|
||||
<artifactId>narayana-jta</artifactId>
|
||||
<version>5.5.23.Final</version>
|
||||
<version>${narayana-jta.version}</version>
|
||||
</dependency>
|
||||
<!-- Testing -->
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>4.12</version>
|
||||
<version>${junit.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.easytesting</groupId>
|
||||
<artifactId>fest-assert</artifactId>
|
||||
<version>1.4</version>
|
||||
<version>${fest-assert.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
@ -57,4 +57,10 @@
|
||||
</resource>
|
||||
</resources>
|
||||
</build>
|
||||
|
||||
<properties>
|
||||
<hibernate.version>5.4.0.Final</hibernate.version>
|
||||
<fest-assert.version>1.4</fest-assert.version>
|
||||
<narayana-jta.version>5.5.23.Final</narayana-jta.version>
|
||||
</properties>
|
||||
</project>
|
@ -33,3 +33,4 @@
|
||||
- [Hibernate Aggregate Functions](https://www.baeldung.com/hibernate-aggregate-functions)
|
||||
- [Hibernate Query Plan Cache](https://www.baeldung.com/hibernate-query-plan-cache)
|
||||
- [TransactionRequiredException Error](https://www.baeldung.com/jpa-transaction-required-exception)
|
||||
- [Enabling Transaction Locks in Spring Data JPA](https://www.baeldung.com/java-jpa-transaction-locks)
|
||||
|
@ -60,7 +60,7 @@
|
||||
<dependency>
|
||||
<groupId>org.hibernate</groupId>
|
||||
<artifactId>hibernate-testing</artifactId>
|
||||
<version>5.2.2.Final</version>
|
||||
<version>${hibernate.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
@ -70,7 +70,7 @@
|
||||
<dependency>
|
||||
<groupId>net.bytebuddy</groupId>
|
||||
<artifactId>byte-buddy</artifactId>
|
||||
<version>1.9.5</version>
|
||||
<version>${byte-buddy.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
@ -91,7 +91,7 @@
|
||||
<dependency>
|
||||
<groupId>javax.xml.bind</groupId>
|
||||
<artifactId>jaxb-api</artifactId>
|
||||
<version>2.3.0</version>
|
||||
<version>${jaxb-api.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
@ -120,6 +120,8 @@
|
||||
<assertj-core.version>3.8.0</assertj-core.version>
|
||||
<openjdk-jmh.version>1.21</openjdk-jmh.version>
|
||||
<geodb.version>0.9</geodb.version>
|
||||
<byte-buddy.version>1.9.5</byte-buddy.version>
|
||||
<jaxb-api.version>2.3.0</jaxb-api.version>
|
||||
</properties>
|
||||
|
||||
</project>
|
||||
|
@ -34,7 +34,7 @@
|
||||
<dependency>
|
||||
<groupId>javax.persistence</groupId>
|
||||
<artifactId>javax.persistence-api</artifactId>
|
||||
<version>2.2</version>
|
||||
<version>${javax.persistence-api.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!--Runtime JPA implementation-->
|
||||
@ -104,10 +104,12 @@
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<properties>
|
||||
<hibernate.version>5.4.0.Final</hibernate.version>
|
||||
<eclipselink.version>2.7.4-RC1</eclipselink.version>
|
||||
<postgres.version>42.2.5</postgres.version>
|
||||
<javax.persistence-api.version>2.2</javax.persistence-api.version>
|
||||
</properties>
|
||||
|
||||
</project>
|
@ -22,8 +22,6 @@
|
||||
<version>${flapdoodle.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>org.mongodb</groupId>
|
||||
<artifactId>mongo-java-driver</artifactId>
|
||||
|
@ -2,6 +2,10 @@
|
||||
<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">
|
||||
<artifactId>jpa-hibernate-cascade-type</artifactId>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
|
||||
<parent>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<artifactId>parent-modules</artifactId>
|
||||
@ -9,10 +13,6 @@
|
||||
<relativePath>../../</relativePath>
|
||||
</parent>
|
||||
|
||||
<artifactId>jpa-hibernate-cascade-type</artifactId>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.hibernate</groupId>
|
||||
|
@ -29,7 +29,7 @@
|
||||
<dependency>
|
||||
<groupId>net.ttddyy</groupId>
|
||||
<artifactId>datasource-proxy</artifactId>
|
||||
<version>1.4.1</version>
|
||||
<version>${datasource-proxy.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
@ -42,4 +42,8 @@
|
||||
<artifactId>spring-oxm</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<properties>
|
||||
<datasource-proxy.version>1.4.1</datasource-proxy.version>
|
||||
</properties>
|
||||
</project>
|
@ -37,14 +37,14 @@
|
||||
<dependency>
|
||||
<groupId>org.testcontainers</groupId>
|
||||
<artifactId>postgresql</artifactId>
|
||||
<version>1.10.6</version>
|
||||
<version>${testcontainers.postgresql.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.postgresql</groupId>
|
||||
<artifactId>postgresql</artifactId>
|
||||
<version>42.2.5</version>
|
||||
<version>${postgresql.version}</version>
|
||||
</dependency>
|
||||
<!-- Test containers only dependencies -->
|
||||
|
||||
@ -66,7 +66,7 @@
|
||||
<dependency>
|
||||
<groupId>com.google.guava</groupId>
|
||||
<artifactId>guava</artifactId>
|
||||
<version>21.0</version>
|
||||
<version>${guava.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- JUnit Jupiter dependencies -->
|
||||
@ -92,6 +92,9 @@
|
||||
|
||||
<properties>
|
||||
<start-class>com.baeldung.boot.Application</start-class>
|
||||
<testcontainers.postgresql.version>1.10.6</testcontainers.postgresql.version>
|
||||
<postgresql.version>42.2.5</postgresql.version>
|
||||
<guava.version>21.0</guava.version>
|
||||
</properties>
|
||||
|
||||
</project>
|
@ -21,7 +21,7 @@
|
||||
<dependency>
|
||||
<groupId>org.springframework.data</groupId>
|
||||
<artifactId>spring-data-releasetrain</artifactId>
|
||||
<version>Lovelace-SR3</version>
|
||||
<version>Lovelace-SR9</version>
|
||||
<type>pom</type>
|
||||
</dependency>
|
||||
|
||||
@ -95,7 +95,7 @@
|
||||
</build>
|
||||
|
||||
<properties>
|
||||
<org.springframework.data.version>2.1.2.RELEASE</org.springframework.data.version>
|
||||
<org.springframework.data.version>2.1.9.RELEASE</org.springframework.data.version>
|
||||
<querydsl.version>4.1.4</querydsl.version>
|
||||
<mysema.maven.version>1.1.3</mysema.maven.version>
|
||||
<mongodb-reactivestreams.version>1.9.2</mongodb-reactivestreams.version>
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user