diff --git a/aggregates/pom.xml b/aggregates/pom.xml index 53e4425..c9e4348 100644 --- a/aggregates/pom.xml +++ b/aggregates/pom.xml @@ -4,20 +4,18 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 - org.fuin.cqrs4j.example + + org.fuin.cqrs4j.example + cqrs4j-example-root + 0.2.0-SNAPSHOT + ../pom.xml + + cqrs4j-example-aggregates - 0.2.0-SNAPSHOT + cqrs4j-example-aggregates DDD related code for all demo applications (aggregates, entities and business exceptions) - - UTF-8 - 1.8 - 1.8 - 1.8 - 0.3.1 - - @@ -31,31 +29,26 @@ org.fuin ddd-4-java - 0.2.1 org.fuin cqrs-4-java - 0.2.1 org.fuin objects4j - 0.6.9 org.slf4j slf4j-api - 1.7.25 org.glassfish - javax.json - 1.1.4 + jakarta.json @@ -63,79 +56,123 @@ junit junit - 4.13.1 test org.assertj assertj-core - 3.10.0 test org.fuin units4j - 0.8.4 test nl.jqno.equalsverifier equalsverifier - 2.4.6 test commons-io commons-io - 2.6 test org.eclipse yasson - 1.0.3 test org.hibernate.validator hibernate-validator - 6.1.0.Final test - - - jaxb-impl - com.sun.xml.bind - - - jaxb-api - javax.xml.bind - - - + - - sonatype.oss.snapshots - Sonatype OSS Snapshot Repository - https://oss.sonatype.org/content/repositories/snapshots - - false - - - always - true - - + - + + org.apache.maven.plugins + maven-compiler-plugin + + + + org.apache.maven.plugins + maven-source-plugin + + + + org.apache.maven.plugins + maven-javadoc-plugin + + + + org.apache.maven.plugins + maven-jar-plugin + + + **/* + + + + org.fuin.cqrs4j.example.shared + + + + + + + org.apache.maven.plugins + maven-jdeps-plugin + + + + + + + + + + + org.eclipse.m2e + lifecycle-mapping + 1.0.0 + + + + + + org.apache.maven.plugins + maven-jdeps-plugin + [3.1.2,) + + jdkinternals + test-jdkinternals + + + + + + + + + + + + + + + + diff --git a/aggregates/src/main/java/org/fuin/cqrs4j/example/aggregates/PersonRepository.java b/aggregates/src/main/java/org/fuin/cqrs4j/example/aggregates/PersonRepository.java index ed6dad6..ccb708f 100644 --- a/aggregates/src/main/java/org/fuin/cqrs4j/example/aggregates/PersonRepository.java +++ b/aggregates/src/main/java/org/fuin/cqrs4j/example/aggregates/PersonRepository.java @@ -12,7 +12,7 @@ */ package org.fuin.cqrs4j.example.aggregates; -import javax.annotation.concurrent.NotThreadSafe; +import org.fuin.objects4j.common.NotThreadSafe; import javax.validation.constraints.NotNull; import org.fuin.cqrs4j.example.shared.PersonId; diff --git a/java-se-cdi/README.md b/java-se-cdi/README.md index 6e9cb64..c46b9fe 100644 --- a/java-se-cdi/README.md +++ b/java-se-cdi/README.md @@ -4,7 +4,7 @@ Minimal standalone example application that uses the [ddd-4-java](https://github ## Starting the demo 1. Start an EventStore locally on your PC - * You can use the [EventStore Docker Image](https://hub.docker.com/r/eventstore/eventstore/): ```docker run --name eventstore-node -p 2113:2113 -p 1113:1113 --rm eventstore/eventstore:release-4.1.3``` + * You can use the [EventStore Docker Image](https://hub.docker.com/r/eventstore/eventstore/): ```docker run --name eventstore-node -p 2113:2113 -p 1113:1113 --rm eventstore/eventstore:release-5.0.9``` * Or simply start an instance (See [Install and run Event Store](https://eventstore.org/docs/server/index.html?tabs=tabid-1) for more information) 2. Run the [QryExampleApp](src/main/java/org/fuin/cqrs4j/example/javasecdi/qry/app/QryExampleApp.java) to make the view/read part listen to new events * You should see something like this on the console: ```INFO o.f.d.qry.handler.QryProjector - Create projection 'qry-person-stream' with events: [PersonCreatedEvent]``` @@ -12,7 +12,8 @@ Minimal standalone example application that uses the [ddd-4-java](https://github 3. Run the [CmdExampleApp](src/main/java/org/fuin/cqrs4j/example/javasecdi/cmd/app/CmdExampleApp.java) to create a [PersonCreatedEvent](src/main/java/org/fuin/cqrs4j/example/javasecdi/shared/domain/PersonCreatedEvent.java) * You should see something like this on the console: ```INFO o.f.d.cmd.app.CmdExampleApp - Updated event store...``` * There should also be an update on the 'QryExampleApp' console: ```INFO o.f.d.q.h.PersonCreatedEventHandler - Handle Person 'Peter Parker Inc.' was created``` - * If you open the [Event Store UI](http://localhost:2113/web/index.html#/projections) (User 'admin' / Password 'changeit') and open the projection details for 'qry-person-stream' it should show 'Events processed = 1' + * If you open the [Event Store UI](http://localhost:2113/web/index.html#/projections) (User 'admin' / Password 'changeit') and open the projection details for 'qry-person-stream' it should show 'Events processed = 1' + * Look at the person's aggregate event stream: ```http://localhost:2113/web/index.html#/streams/PERSON-00000000-0000-0000-0000-000000000000`` - Replace the zero UUID with the one shown in the event handler message 'Person 'Peter Parker Inc.' (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx) was created' 4. Kill the [QryExampleApp](src/main/java/org/fuin/cqrs4j/example/javasecdi/qry/app/QryExampleApp.java) 5. Stop the event store diff --git a/java-se-cdi/pom.xml b/java-se-cdi/pom.xml index 8d47def..99de25d 100644 --- a/java-se-cdi/pom.xml +++ b/java-se-cdi/pom.xml @@ -5,15 +5,15 @@ 4.0.0 - - org.fuin - pom - 1.6.0 - + + org.fuin.cqrs4j.example + cqrs4j-example-root + 0.2.0-SNAPSHOT + ../pom.xml + org.fuin.cqrs4j.example.javasecdi cqrs4j-javasecdi-example - 0.2.0-SNAPSHOT Minimal standalone example application that uses the 'ddd-4-java' and 'ddd-cqrs-4-java-example' libraries @@ -28,10 +28,7 @@ - UTF-8 - 1.8 - 1.8 - 0.3.1 + 0.4.0 @@ -41,7 +38,7 @@ org.apache.deltaspike.distribution distributions-bom - 1.9.0 + 1.9.4 import pom @@ -63,116 +60,98 @@ org.fuin ddd-4-java - 0.2.1 org.fuin cqrs-4-java - 0.2.1 org.fuin.esc esc-spi - ${esc.version} org.fuin.esc esc-esjc - ${esc.version} org.fuin.esc esc-eshttp - ${esc.version} org.apache.httpcomponents httpasyncclient - 4.1 org.apache.httpcomponents httpclient - 4.5 org.fuin ext4logback - 0.2.0 - javax.validation - validation-api - 2.0.1.Final - true + jakarta.validation + jakarta.validation-api org.apache.commons commons-lang3 - 3.7 org.slf4j slf4j-api - 1.7.25 ch.qos.logback logback-classic - 1.1.8 - javax.enterprise - cdi-api - 2.0 + jakarta.enterprise + jakarta.enterprise.cdi-api + 2.0.2 org.jboss.weld.se weld-se-core - 3.0.4.Final + 3.1.5.SP1 org.eclipse.microprofile.config microprofile-config-api - 1.3 - io.smallrye - smallrye-config - 1.3.5 + io.smallrye.config + smallrye-config - javax.json - javax.json-api - 1.1.4 + jakarta.json + jakarta.json-api org.glassfish - javax.json - 1.1.4 + jakarta.json org.eclipse yasson - 1.0.3 @@ -188,41 +167,26 @@ org.hibernate.validator hibernate-validator - 6.1.0.Final - - - jaxb-impl - com.sun.xml.bind - - - jaxb-api - javax.xml.bind - - - org.hibernate.javax.persistence - hibernate-jpa-2.1-api - 1.0.2 + jakarta.persistence + jakarta.persistence-api org.hibernate hibernate-entitymanager - 5.4.2.Final commons-io commons-io - 2.6 org.hsqldb hsqldb - 2.4.1 @@ -230,7 +194,6 @@ org.fuin.esc esc-mem - ${esc.version} test @@ -243,32 +206,144 @@ org.assertj assertj-core - 3.10.0 test org.fuin units4j - 0.8.4 test nl.jqno.equalsverifier equalsverifier - 2.4.6 test - + - + - + - + + org.apache.maven.plugins + maven-jdeps-plugin + 3.1.2 + + base + true + + + + + jdkinternals + test-jdkinternals + + + + + + + org.apache.maven.plugins + maven-jar-plugin + 3.2.0 + + + **/* + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.8.1 + + ${java.version} + + + + + org.apache.maven.plugins + maven-javadoc-plugin + 3.2.0 + + + + org.apache.maven.plugins + maven-source-plugin + 3.2.1 + + + attach-sources + + jar-no-fork + + + + + + + org.apache.maven.plugins + maven-release-plugin + 3.0.0-M1 + + + + + + + + + + org.apache.maven.plugins + maven-enforcer-plugin + 3.0.0-M3 + + + enforce-java-and-maven-version + + enforce + + + + + ${java.version} + Java 11 or later is required! + + + 3.6.0 + Please use at least Maven 3.6.0 as older versions may cause problems with Java 11+ + + + + + + + + + + + + + + + sonatype.oss.snapshots + Sonatype OSS Snapshot Repository + https://oss.sonatype.org/content/repositories/snapshots + + false + + + always + true + + + + \ No newline at end of file diff --git a/java-se-cdi/src/main/java/org/fuin/cqrs4j/example/javasecdi/cmd/domain/PersonRepository.java b/java-se-cdi/src/main/java/org/fuin/cqrs4j/example/javasecdi/cmd/domain/PersonRepository.java index 76bbde3..8bedd74 100644 --- a/java-se-cdi/src/main/java/org/fuin/cqrs4j/example/javasecdi/cmd/domain/PersonRepository.java +++ b/java-se-cdi/src/main/java/org/fuin/cqrs4j/example/javasecdi/cmd/domain/PersonRepository.java @@ -1,6 +1,6 @@ package org.fuin.cqrs4j.example.javasecdi.cmd.domain; -import javax.annotation.concurrent.NotThreadSafe; +import org.fuin.objects4j.common.NotThreadSafe; import javax.validation.constraints.NotNull; import org.fuin.cqrs4j.example.shared.PersonId; diff --git a/java-se-cdi/src/main/java/org/fuin/cqrs4j/example/javasecdi/qry/app/QryProjectionAdminEventStoreFactory.java b/java-se-cdi/src/main/java/org/fuin/cqrs4j/example/javasecdi/qry/app/QryProjectionAdminEventStoreFactory.java index b347319..73948b5 100644 --- a/java-se-cdi/src/main/java/org/fuin/cqrs4j/example/javasecdi/qry/app/QryProjectionAdminEventStoreFactory.java +++ b/java-se-cdi/src/main/java/org/fuin/cqrs4j/example/javasecdi/qry/app/QryProjectionAdminEventStoreFactory.java @@ -40,8 +40,10 @@ public class QryProjectionAdminEventStoreFactory { config.getEventStorePassword()); credentialsProvider.setCredentials(AuthScope.ANY, credentials); final SimpleSerializerDeserializerRegistry registry = new SimpleSerializerDeserializerRegistry(); - final ProjectionAdminEventStore es = new ESHttpEventStore(threadFactory, new URL(url), ESEnvelopeType.JSON, registry, registry, - credentialsProvider); + + final ProjectionAdminEventStore es = new ESHttpEventStore.Builder().threadFactory(threadFactory).url(new URL(url)) + .envelopeType(ESEnvelopeType.JSON).serDesRegistry(registry).credentialsProvider(credentialsProvider).build(); + es.open(); return es; } catch (final MalformedURLException ex) { diff --git a/java-se-cdi/src/main/java/org/fuin/cqrs4j/example/javasecdi/shared/app/SharedEventStoreFactory.java b/java-se-cdi/src/main/java/org/fuin/cqrs4j/example/javasecdi/shared/app/SharedEventStoreFactory.java index 12b3473..b324c9d 100644 --- a/java-se-cdi/src/main/java/org/fuin/cqrs4j/example/javasecdi/shared/app/SharedEventStoreFactory.java +++ b/java-se-cdi/src/main/java/org/fuin/cqrs4j/example/javasecdi/shared/app/SharedEventStoreFactory.java @@ -21,20 +21,22 @@ public class SharedEventStoreFactory { /** * Creates an event store.
*
- * CAUTION: The returned event store instance is NOT thread safe. + * CAUTION: The returned event store instance is NOT thread safe. * - * @param es Native event store API. - * @param registry Serialization registry. + * @param es + * Native event store API. + * @param registry + * Serialization registry. * * @return Dependent scope event store. - */ + */ @Produces @RequestScoped - public EventStore createEventStore(final com.github.msemys.esjc.EventStore es, - final SerDeserializerRegistry registry) { + public EventStore createEventStore(final com.github.msemys.esjc.EventStore es, final SerDeserializerRegistry registry) { + + final EventStore eventstore = new ESJCEventStore.Builder().eventStore(es).serDesRegistry(registry) + .targetContentType(EnhancedMimeType.create("application", "json", Charset.forName("utf-8"))).build(); - final EventStore eventstore = new ESJCEventStore(es, registry, registry, - EnhancedMimeType.create("application", "json", Charset.forName("utf-8"))); eventstore.open(); return eventstore; @@ -43,7 +45,8 @@ public class SharedEventStoreFactory { /** * Closes the event store when the context is disposed. * - * @param es Event store to close. + * @param es + * Event store to close. */ public void closeEventStore(@Disposes final EventStore es) { es.close(); diff --git a/pom.xml b/pom.xml index 1ab4f78..719be38 100644 --- a/pom.xml +++ b/pom.xml @@ -1,20 +1,371 @@ - 4.0.0 + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> + 4.0.0 - org.fuin.cqrs4j.example - cqrs4j-example-root - 0.2.0-SNAPSHOT - pom + org.fuin.cqrs4j.example + cqrs4j-example-root + 0.2.0-SNAPSHOT + pom + + + 11 + ${java.version} + true + UTF-8 + UTF-8 + 0.4.0 + + + + shared + aggregates + java-se-cdi + quarkus + spring-boot + + + + + + + + org.fuin + ddd-4-java + 0.3.0 + + + + org.fuin + cqrs-4-java + 0.3.0 + + + + org.fuin + objects4j + 0.7.0 + + + + org.fuin.esc + esc-api + ${esc.version} + + + + org.fuin.esc + esc-spi + ${esc.version} + + + + org.fuin.esc + esc-esjc + ${esc.version} + + + + org.fuin.esc + esc-eshttp + ${esc.version} + + + + org.fuin.esc + esc-mem + ${esc.version} + + + + org.apache.httpcomponents + httpasyncclient + 4.1.4 + + + + org.apache.httpcomponents + httpclient + 4.5.13 + + + + org.fuin + ext4logback + 0.2.0 + + + + ch.qos.logback + logback-classic + 1.2.3 + + + + org.apache.commons + commons-lang3 + 3.11 + + + + org.slf4j + slf4j-api + 1.7.25 + + + + jakarta.validation + jakarta.validation-api + 2.0.2 + + + + jakarta.json.bind + jakarta.json.bind-api + 1.0.2 + + + + jakarta.persistence + jakarta.persistence-api + 2.2.3 + + + + org.eclipse.microprofile.config + microprofile-config-api + 1.3 + + + + io.smallrye.config + smallrye-config + 1.10.0 + + + + jakarta.json + jakarta.json-api + 1.1.6 + + + + org.hibernate + hibernate-entitymanager + 5.4.26.Final + + + + org.hsqldb + hsqldb + 2.5.1 + + + + junit + junit + 4.13.1 + + + + org.assertj + assertj-core + 3.18.1 + + + + org.fuin + units4j + 0.9.0 + + + + nl.jqno.equalsverifier + equalsverifier + 3.5 + + + + commons-io + commons-io + 2.8.0 + + + + org.hibernate.validator + hibernate-validator + 6.1.7.Final + + + + org.glassfish + jakarta.json + 1.1.6 + + + + org.eclipse + yasson + 1.0.8 + + + + jakarta.mail + jakarta.mail-api + 1.6.4 + + + + com.sun.mail + jakarta.mail + 1.6.4 + + + + + + + + + + + + + + org.apache.maven.plugins + maven-jdeps-plugin + 3.1.2 + + base + true + + + + + jdkinternals + test-jdkinternals + + + + + + + org.apache.maven.plugins + maven-jar-plugin + 3.2.0 + + + **/* + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.8.1 + + ${java.version} + + + + + org.apache.maven.plugins + maven-javadoc-plugin + 3.2.0 + + + + org.apache.maven.plugins + maven-source-plugin + 3.2.1 + + + attach-sources + + jar-no-fork + + + + + + + org.apache.maven.plugins + maven-release-plugin + 3.0.0-M1 + + + + org.apache.maven.plugins + maven-surefire-plugin + 2.22.2 + + + + org.apache.maven.plugins + maven-failsafe-plugin + 2.22.2 + + + + io.fabric8 + docker-maven-plugin + 0.34.1 + + + + + + + + + + org.apache.maven.plugins + maven-enforcer-plugin + 3.0.0-M3 + + + enforce-java-and-maven-version + + enforce + + + + + ${java.version} + Java 11 or later is required! + + + 3.6.0 + Please use at least Maven 3.6.0 as older versions may cause problems with Java 11+ + + + + + + + + + + + + + + + sonatype.oss.snapshots + Sonatype OSS Snapshot Repository + https://oss.sonatype.org/content/repositories/snapshots + + false + + + always + true + + + + - - shared - aggregates - java-se-cdi - quarkus - spring-boot - diff --git a/quarkus/command/pom.xml b/quarkus/command/pom.xml index 1a3ebb6..663404e 100644 --- a/quarkus/command/pom.xml +++ b/quarkus/command/pom.xml @@ -6,35 +6,14 @@ 4.0.0 - org.fuin.cqrs4j.example.quarkus + + org.fuin.cqrs4j.example.quarkus + cqrs4j-quarkus-example-root + 0.2.0-SNAPSHOT + ../pom.xml + + cqrs4j-quarkus-example-command - 0.2.0-SNAPSHOT - - - true - 1.8 - 1.8 - UTF-8 - UTF-8 - 0.3.1 - 1.2.0.Final - - - - - - - - io.quarkus - quarkus-universe-bom - ${quarkus.version} - pom - import - - - - - @@ -90,25 +69,16 @@ org.fuin.esc esc-esjc - ${esc.version} - - - ch.qos.logback - logback-classic - - org.fuin cqrs-4-java - 0.2.1 - javax.mail - mail - 1.4.7 + jakarta.mail + jakarta.mail-api @@ -134,7 +104,6 @@ io.quarkus quarkus-maven-plugin - ${quarkus.version} @@ -145,13 +114,13 @@ + org.apache.maven.plugins maven-compiler-plugin - 3.8.1 + org.apache.maven.plugins maven-surefire-plugin - 2.22.1 org.jboss.logmanager.LogManager @@ -160,8 +129,8 @@ + org.apache.maven.plugins maven-failsafe-plugin - 2.22.2 @@ -180,12 +149,11 @@ io.fabric8 docker-maven-plugin - 0.31.0 - eventstore/eventstore:release-4.1.3 + eventstore/eventstore:release-${eventstore.version} bridge @@ -242,21 +210,4 @@ - - - - sonatype.oss.snapshots - Sonatype OSS Snapshot Repository - https://oss.sonatype.org/content/repositories/snapshots - - false - - - always - true - - - - - diff --git a/quarkus/command/src/main/java/org/fuin/cqrs4j/example/quarkus/command/api/ConstraintViolationExceptionMapper.java b/quarkus/command/src/main/java/org/fuin/cqrs4j/example/quarkus/command/api/ConstraintViolationExceptionMapper.java index 07dcebb..c715f45 100644 --- a/quarkus/command/src/main/java/org/fuin/cqrs4j/example/quarkus/command/api/ConstraintViolationExceptionMapper.java +++ b/quarkus/command/src/main/java/org/fuin/cqrs4j/example/quarkus/command/api/ConstraintViolationExceptionMapper.java @@ -16,7 +16,7 @@ import java.util.ArrayList; import java.util.List; import java.util.Set; -import javax.annotation.Nullable; +import org.fuin.objects4j.common.Nullable; import javax.validation.ConstraintViolation; import javax.validation.ConstraintViolationException; import javax.ws.rs.core.Context; diff --git a/quarkus/pom.xml b/quarkus/pom.xml index 600d85b..bda321a 100644 --- a/quarkus/pom.xml +++ b/quarkus/pom.xml @@ -4,11 +4,50 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 + + org.fuin.cqrs4j.example + cqrs4j-example-root + 0.2.0-SNAPSHOT + ../pom.xml + + org.fuin.cqrs4j.example.quarkus cqrs4j-quarkus-example-root - 0.2.0-SNAPSHOT pom + + 1.10.5.Final + 5.0.9 + + + + + + + + io.quarkus + quarkus-universe-bom + ${quarkus.version} + pom + import + + + + jakarta.enterprise + jakarta.enterprise.cdi-api + 2.0.2 + + + + org.jboss.weld.se + weld-se-core + 3.1.5.SP1 + + + + + + shared query diff --git a/quarkus/query/README.md b/quarkus/query/README.md index 00e39b6..099ac44 100644 --- a/quarkus/query/README.md +++ b/quarkus/query/README.md @@ -16,6 +16,36 @@ Make sure you installed everything as described [here](../../../../). ## Overview ![Overview](https://raw.github.com/fuinorg/ddd-cqrs-4-java-example/master/quarkus/query/doc/cdi-view.png) +## Running test in IDE +In case you want to run the integration test inside your IDE (Eclipse or other), you need to start the Eventstore and MariaDB before. + +1. Start the Eventstore Docker container: + +``` +docker run -d --name eventstore-node \ +-p 2113:2113 \ +-p 1113:1113 \ +--rm \ +eventstore/eventstore:release-5.0.9 +``` + +2. Start the MariaDB Docker container: + +``` +docker run -d --name mariadb \ +-p 3306:3306 \ +-e MYSQL_INITDB_SKIP_TZINFO=1 \ +-e MYSQL_ROOT_PASSWORD=xyz \ +-e MYSQL_DATABASE=querydb \ +-e MYSQL_USER=mary \ +-e MYSQL_PASSWORD=abc \ +--rm \ +mariadb:10.4 +``` + +3. Run the test: [QryPersonResourceIT.java](src/test/java/org/fuin/cqrs4j/example/quarkus/query/api/QryPersonResourceIT.java) + +4. Run `docker ps` to see the CONTAINER IDs and stop the Eventstore and MariaDB with `docker stop ` # TODO ... (Does currently not work) diff --git a/quarkus/query/pom.xml b/quarkus/query/pom.xml index 81a2e38..2d784ae 100644 --- a/quarkus/query/pom.xml +++ b/quarkus/query/pom.xml @@ -1,287 +1,235 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" + xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> - 4.0.0 + 4.0.0 - org.fuin.cqrs4j.example.quarkus - cqrs4j-quarkus-example-query - 0.2.0-SNAPSHOT + + org.fuin.cqrs4j.example.quarkus + cqrs4j-quarkus-example-root + 0.2.0-SNAPSHOT + ../pom.xml + - - true - 1.8 - 1.8 - UTF-8 - UTF-8 - 0.3.1 - 1.2.0.Final - + cqrs4j-quarkus-example-query - + - + - - io.quarkus - quarkus-universe-bom - ${quarkus.version} - pom - import - + + io.quarkus + quarkus-resteasy + - + + io.quarkus + quarkus-resteasy-jsonb + - + + io.quarkus + quarkus-resteasy-jackson + - + + io.quarkus + quarkus-scheduler + - + + io.quarkus + quarkus-hibernate-orm + - - io.quarkus - quarkus-resteasy - + + io.quarkus + quarkus-jdbc-mariadb + - - io.quarkus - quarkus-resteasy-jsonb - + + jakarta.security.jacc + jakarta.security.jacc-api + - - io.quarkus - quarkus-resteasy-jackson - + + org.fuin.cqrs4j.example + cqrs4j-example-aggregates + 0.2.0-SNAPSHOT + - - io.quarkus - quarkus-scheduler - + + org.fuin.cqrs4j.example.quarkus + cqrs4j-quarkus-example-shared + 0.2.0-SNAPSHOT + - - io.quarkus - quarkus-hibernate-orm - - - - - io.quarkus - quarkus-jdbc-mariadb - - - - jakarta.security.jacc - jakarta.security.jacc-api - + + org.fuin.esc + esc-eshttp + - - org.fuin.cqrs4j.example - cqrs4j-example-aggregates - 0.2.0-SNAPSHOT - + - - org.fuin.cqrs4j.example.quarkus - cqrs4j-quarkus-example-shared - 0.2.0-SNAPSHOT - + + io.quarkus + quarkus-junit5 + test + - - org.fuin.esc - esc-eshttp - ${esc.version} - - - ch.qos.logback - logback-classic - - - + + io.rest-assured + rest-assured + test + - + + org.awaitility + awaitility + test + - - io.quarkus - quarkus-junit5 - test - + - - io.rest-assured - rest-assured - test - + - - org.awaitility - awaitility - test - + - + + io.quarkus + quarkus-maven-plugin + ${quarkus.version} + + + + build + + + + - + + org.apache.maven.plugins + maven-compiler-plugin + - + + org.apache.maven.plugins + maven-surefire-plugin + + + org.jboss.logmanager.LogManager + + + - - io.quarkus - quarkus-maven-plugin - ${quarkus.version} - - - - build - - - - + + org.apache.maven.plugins + maven-failsafe-plugin + + + + integration-test + verify + + + + org.jboss.logmanager.LogManager + + + + + - - maven-compiler-plugin - 3.8.1 - + + io.fabric8 + docker-maven-plugin + - - maven-surefire-plugin - 2.22.1 - - - org.jboss.logmanager.LogManager - - - + + + eventstore/eventstore:release-${eventstore.version} + + + bridge + + + 1113:1113 + 2113:2113 + + + false + + + + http://localhost:2113/web/index.html#/ + GET + + + + + - - maven-failsafe-plugin - 2.22.2 - - - - integration-test - verify - - - - org.jboss.logmanager.LogManager - - - - - + + mariadb:10.4 + + + bridge + + + 3306:3306 + + + false + + + 1 + xyz + querydb + mary + abc + + + + + + - - io.fabric8 - docker-maven-plugin - 0.31.0 - + + - - - eventstore/eventstore:release-4.1.3 - - - bridge - - - 1113:1113 - 2113:2113 - - - false - - - - http://localhost:2113/web/index.html#/ - GET - - - - - + + + start-images + pre-integration-test + + start + + + + stop-images + post-integration-test + + stop + + + - - mariadb:10.4 - - - bridge - - - 3306:3306 - - - false - - - 1 - xyz - querydb - mary - abc - - - - - - + - - + - - - start-images - pre-integration-test - - start - - - - stop-images - post-integration-test - - stop - - - + - - - - - - - - - native - - native - - - - - - - - sonatype.oss.snapshots - Sonatype OSS Snapshot Repository - https://oss.sonatype.org/content/repositories/snapshots - - false - - - always - true - - - - + + + native + + native + + + diff --git a/quarkus/query/src/main/resources/application.properties b/quarkus/query/src/main/resources/application.properties index 588ba79..01e9aa0 100644 --- a/quarkus/query/src/main/resources/application.properties +++ b/quarkus/query/src/main/resources/application.properties @@ -1,14 +1,9 @@ # Configuration file -#quarkus.datasource.url=jdbc:postgresql://localhost:5432/querydb -#quarkus.datasource.driver=org.postgresql.Driver -#quarkus.datasource.username=postgres -#quarkus.datasource.password=abc - -quarkus.datasource.url=jdbc:mariadb://localhost:3306/querydb -quarkus.datasource.driver=org.mariadb.jdbc.Driver +quarkus.datasource.db-kind=mariadb quarkus.datasource.username=mary quarkus.datasource.password=abc +quarkus.datasource.jdbc.url=jdbc:mariadb://localhost:3306/querydb quarkus.hibernate-orm.database.generation=drop-and-create diff --git a/quarkus/shared/pom.xml b/quarkus/shared/pom.xml index 6c9feed..af4bd8f 100644 --- a/quarkus/shared/pom.xml +++ b/quarkus/shared/pom.xml @@ -4,37 +4,17 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 - org.fuin.cqrs4j.example.quarkus + + org.fuin.cqrs4j.example.quarkus + cqrs4j-quarkus-example-root + 0.2.0-SNAPSHOT + ../pom.xml + + cqrs4j-quarkus-example-shared - 0.2.0-SNAPSHOT cqrs4j-quarkus-example-shared Quarkus CQRS Shared Code for Demo Application - - UTF-8 - 1.8 - 1.8 - 1.8 - 0.3.1 - 1.2.0.Final - - - - - - - - io.quarkus - quarkus-universe-bom - ${quarkus.version} - pom - import - - - - - - @@ -48,31 +28,26 @@ org.fuin ddd-4-java - 0.2.1 org.fuin cqrs-4-java - 0.2.1 org.fuin objects4j - 0.6.9 org.fuin.esc esc-esjc - ${esc.version} org.fuin.esc esc-eshttp - ${esc.version} @@ -98,22 +73,11 @@ org.hibernate.validator hibernate-validator - - - jaxb-impl - com.sun.xml.bind - - - jaxb-api - javax.xml.bind - - org.glassfish - javax.json - 1.1.4 + jakarta.json @@ -143,14 +107,12 @@ org.fuin units4j - 0.8.3 test nl.jqno.equalsverifier equalsverifier - 2.4.6 test @@ -162,21 +124,82 @@ - + - - sonatype.oss.snapshots - Sonatype OSS Snapshot Repository - https://oss.sonatype.org/content/repositories/snapshots - - false - - - always - true - - + - + + org.apache.maven.plugins + maven-compiler-plugin + + + + org.apache.maven.plugins + maven-source-plugin + + + + org.apache.maven.plugins + maven-javadoc-plugin + + + + org.apache.maven.plugins + maven-jar-plugin + + + **/* + + + + org.fuin.cqrs4j.example.shared + + + + + + + org.apache.maven.plugins + maven-jdeps-plugin + + + + + + + + + + + org.eclipse.m2e + lifecycle-mapping + 1.0.0 + + + + + + org.apache.maven.plugins + maven-jdeps-plugin + [3.1.2,) + + jdkinternals + test-jdkinternals + + + + + + + + + + + + + + + + diff --git a/quarkus/shared/src/main/java/org/fuin/cqrs4j/example/quarkus/shared/EventStoreFactory.java b/quarkus/shared/src/main/java/org/fuin/cqrs4j/example/quarkus/shared/EventStoreFactory.java index 5ad29cb..94e20e7 100644 --- a/quarkus/shared/src/main/java/org/fuin/cqrs4j/example/quarkus/shared/EventStoreFactory.java +++ b/quarkus/shared/src/main/java/org/fuin/cqrs4j/example/quarkus/shared/EventStoreFactory.java @@ -43,20 +43,22 @@ public class EventStoreFactory { /** * Creates an ESJC event store.
*
- * CAUTION: The returned event store instance is NOT thread safe. + * CAUTION: The returned event store instance is NOT thread safe. * - * @param es Native event store API. - * @param registry Serialization registry. + * @param es + * Native event store API. + * @param registry + * Serialization registry. * * @return Dependent scope event store. - */ + */ @Produces @RequestScoped - public IESJCEventStore createEventStore(final com.github.msemys.esjc.EventStore es, - final SerDeserializerRegistry registry) { + public IESJCEventStore createEventStore(final com.github.msemys.esjc.EventStore es, final SerDeserializerRegistry registry) { + + final IESJCEventStore eventstore = new ESJCEventStore.Builder().eventStore(es).serDesRegistry(registry) + .targetContentType(EnhancedMimeType.create("application", "json", Charset.forName("utf-8"))).build(); - final IESJCEventStore eventstore = new ESJCEventStore(es, registry, registry, - EnhancedMimeType.create("application", "json", Charset.forName("utf-8"))); eventstore.open(); return eventstore; @@ -65,7 +67,8 @@ public class EventStoreFactory { /** * Closes the ESJC event store when the context is disposed. * - * @param es Event store to close. + * @param es + * Event store to close. */ public void closeEventStore(@Disposes final IESJCEventStore es) { es.close(); @@ -92,8 +95,10 @@ public class EventStoreFactory { config.getEventStorePassword()); credentialsProvider.setCredentials(AuthScope.ANY, credentials); final ThreadFactory threadFactory = Executors.defaultThreadFactory(); - final IESHttpEventStore eventStore = new ESHttpEventStore(threadFactory, config.getEventStoreURL(), ESEnvelopeType.JSON, registry, - registry, credentialsProvider); + + final IESHttpEventStore eventStore = new ESHttpEventStore.Builder().threadFactory(threadFactory).url(config.getEventStoreURL()) + .envelopeType(ESEnvelopeType.JSON).serDesRegistry(registry).credentialsProvider(credentialsProvider).build(); + eventStore.open(); return eventStore; @@ -108,5 +113,5 @@ public class EventStoreFactory { public void closeEventStore(@Disposes final IESHttpEventStore es) { es.close(); } - + } diff --git a/shared/pom.xml b/shared/pom.xml index c53c7cd..53a45ad 100644 --- a/shared/pom.xml +++ b/shared/pom.xml @@ -1,166 +1,197 @@ - 4.0.0 + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> + 4.0.0 - org.fuin.cqrs4j.example - cqrs4j-example-shared - 0.2.0-SNAPSHOT - cqrs4j-example-shared - Shared code for all demo applications and client & server + + org.fuin.cqrs4j.example + cqrs4j-example-root + 0.2.0-SNAPSHOT + ../pom.xml + - - UTF-8 - 1.8 - 1.8 - 1.8 - 0.3.1 - + cqrs4j-example-shared + cqrs4j-example-shared + Shared code for all demo applications and client & server - + - + - - org.fuin - ddd-4-java - 0.2.1 - + + org.fuin + ddd-4-java + - - org.fuin - cqrs-4-java - 0.2.1 - + + org.fuin + cqrs-4-java + - - org.fuin - objects4j - 0.6.9 - + + org.fuin + objects4j + - - org.fuin.esc - esc-api - ${esc.version} - + + org.fuin.esc + esc-api + - - org.fuin.esc - esc-spi - ${esc.version} - + + org.fuin.esc + esc-spi + - - org.slf4j - slf4j-api - 1.7.25 - + + org.slf4j + slf4j-api + - - javax.validation - validation-api - 2.0.1.Final - + + jakarta.validation + jakarta.validation-api + - - javax.json.bind - javax.json.bind-api - 1.0 - + + jakarta.json.bind + jakarta.json.bind-api + - - jakarta.persistence - jakarta.persistence-api - 2.2.3 - + + jakarta.persistence + jakarta.persistence-api + - + - - junit - junit - 4.13.1 - test - + + junit + junit + test + - - org.assertj - assertj-core - 3.10.0 - test - + + org.assertj + assertj-core + test + - - org.fuin - units4j - 0.8.3 - test - + + org.fuin + units4j + test + - - nl.jqno.equalsverifier - equalsverifier - 2.4.6 - test - + + nl.jqno.equalsverifier + equalsverifier + test + - - commons-io - commons-io - 2.6 - test - + + commons-io + commons-io + test + - - org.hibernate.validator - hibernate-validator - 6.1.0.Final - test - - - jaxb-impl - com.sun.xml.bind - - - jaxb-api - javax.xml.bind - - - + + org.hibernate.validator + hibernate-validator + test + - + org.glassfish - javax.json - 1.1.4 - test - + jakarta.json + test + - - org.eclipse - yasson - 1.0.3 - test - + + org.eclipse + yasson + test + - + - + - - sonatype.oss.snapshots - Sonatype OSS Snapshot Repository - https://oss.sonatype.org/content/repositories/snapshots - - false - - - always - true - - + - + + org.apache.maven.plugins + maven-compiler-plugin + + + + org.apache.maven.plugins + maven-source-plugin + + + + org.apache.maven.plugins + maven-javadoc-plugin + + + + org.apache.maven.plugins + maven-jar-plugin + + + **/* + + + + org.fuin.cqrs4j.example.shared + + + + + + + org.apache.maven.plugins + maven-jdeps-plugin + + + + + + + + + + + org.eclipse.m2e + lifecycle-mapping + 1.0.0 + + + + + + org.apache.maven.plugins + maven-jdeps-plugin + [3.1.2,) + + jdkinternals + test-jdkinternals + + + + + + + + + + + + + + + + diff --git a/shared/src/main/java/org/fuin/cqrs4j/example/shared/CreatePersonCommand.java b/shared/src/main/java/org/fuin/cqrs4j/example/shared/CreatePersonCommand.java index 1964e19..f47bae1 100644 --- a/shared/src/main/java/org/fuin/cqrs4j/example/shared/CreatePersonCommand.java +++ b/shared/src/main/java/org/fuin/cqrs4j/example/shared/CreatePersonCommand.java @@ -17,7 +17,6 @@ */ package org.fuin.cqrs4j.example.shared; -import javax.annotation.concurrent.Immutable; import javax.json.bind.annotation.JsonbProperty; import javax.validation.constraints.NotNull; @@ -26,6 +25,7 @@ import org.fuin.ddd4j.ddd.DomainEventExpectedEntityIdPath; import org.fuin.ddd4j.ddd.EventType; import org.fuin.esc.spi.SerializedDataType; import org.fuin.objects4j.common.Contract; +import org.fuin.objects4j.common.Immutable; /** * A new person should be created in the system. diff --git a/shared/src/main/java/org/fuin/cqrs4j/example/shared/PersonCreatedEvent.java b/shared/src/main/java/org/fuin/cqrs4j/example/shared/PersonCreatedEvent.java index cf923ea..a4d95a6 100644 --- a/shared/src/main/java/org/fuin/cqrs4j/example/shared/PersonCreatedEvent.java +++ b/shared/src/main/java/org/fuin/cqrs4j/example/shared/PersonCreatedEvent.java @@ -17,7 +17,7 @@ */ package org.fuin.cqrs4j.example.shared; -import javax.annotation.concurrent.Immutable; +import org.fuin.objects4j.common.Immutable; import javax.json.bind.annotation.JsonbProperty; import javax.validation.constraints.NotNull; diff --git a/shared/src/main/java/org/fuin/cqrs4j/example/shared/PersonId.java b/shared/src/main/java/org/fuin/cqrs4j/example/shared/PersonId.java index d060e8f..2c6c787 100644 --- a/shared/src/main/java/org/fuin/cqrs4j/example/shared/PersonId.java +++ b/shared/src/main/java/org/fuin/cqrs4j/example/shared/PersonId.java @@ -19,7 +19,7 @@ package org.fuin.cqrs4j.example.shared; import java.util.UUID; -import javax.annotation.concurrent.Immutable; +import org.fuin.objects4j.common.Immutable; import javax.json.bind.adapter.JsonbAdapter; import javax.validation.constraints.NotNull; diff --git a/shared/src/main/java/org/fuin/cqrs4j/example/shared/PersonName.java b/shared/src/main/java/org/fuin/cqrs4j/example/shared/PersonName.java index ae100b8..21d0480 100644 --- a/shared/src/main/java/org/fuin/cqrs4j/example/shared/PersonName.java +++ b/shared/src/main/java/org/fuin/cqrs4j/example/shared/PersonName.java @@ -23,7 +23,7 @@ import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; -import javax.annotation.concurrent.Immutable; +import org.fuin.objects4j.common.Immutable; import javax.json.bind.adapter.JsonbAdapter; import javax.validation.Constraint; import javax.validation.ConstraintValidator; diff --git a/shared/src/test/java/org/fuin/cqrs4j/example/shared/CreatePersonCommandTest.java b/shared/src/test/java/org/fuin/cqrs4j/example/shared/CreatePersonCommandTest.java index 4cf338e..cf60db2 100644 --- a/shared/src/test/java/org/fuin/cqrs4j/example/shared/CreatePersonCommandTest.java +++ b/shared/src/test/java/org/fuin/cqrs4j/example/shared/CreatePersonCommandTest.java @@ -92,7 +92,7 @@ public final class CreatePersonCommandTest { // VERIFY assertThat(copy.getEventId().asBaseType()).isEqualTo(UUID.fromString("109a77b2-1de2-46fc-aee1-97fa7740a552")); - assertThat(copy.getTimestamp()).isEqualTo(ZonedDateTime.parse("2019-11-17T10:27:13.183+01:00[Europe/Berlin]")); + assertThat(copy.getEventTimestamp()).isEqualTo(ZonedDateTime.parse("2019-11-17T10:27:13.183+01:00[Europe/Berlin]")); assertThat(copy.getAggregateRootId().asString()).isEqualTo(PERSON_UUID); assertThat(copy.getName().asString()).isEqualTo("Peter Parker"); diff --git a/spring-boot/command/pom.xml b/spring-boot/command/pom.xml index afc67a6..e6cae01 100644 --- a/spring-boot/command/pom.xml +++ b/spring-boot/command/pom.xml @@ -2,28 +2,20 @@ + 4.0.0 + - org.springframework.boot - spring-boot-starter-parent - 2.2.0.RELEASE - + org.fuin.cqrs4j.example.spring + cqrs4j-spring-example-root + 0.2.0-SNAPSHOT + ../pom.xml - org.fuin.cqrs4j.example.spring cqrs4j-spring-example-command - 0.2.0-SNAPSHOT cqrs4j-spring-example-command Spring Boot CQRS Command Demo Application - - UTF-8 - 1.8 - 1.8 - 1.8 - 0.3.1 - - @@ -59,19 +51,16 @@ org.fuin cqrs-4-java - 0.2.1 org.fuin.esc esc-spi - ${esc.version} org.fuin.esc esc-esjc - ${esc.version} @@ -157,12 +146,11 @@ io.fabric8 docker-maven-plugin - 0.31.0 - eventstore/eventstore:release-4.1.3 + eventstore/eventstore:release-${eventstore.version} bridge diff --git a/spring-boot/pom.xml b/spring-boot/pom.xml index 1f3cec9..b48af95 100644 --- a/spring-boot/pom.xml +++ b/spring-boot/pom.xml @@ -3,11 +3,161 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 + + org.springframework.boot + spring-boot-starter-parent + 2.2.12.RELEASE + + + org.fuin.cqrs4j.example.spring cqrs4j-spring-example-root 0.2.0-SNAPSHOT pom + + 11 + ${java.version} + true + UTF-8 + UTF-8 + 0.4.0 + 5.0.9 + + + + + + + + org.fuin + ddd-4-java + 0.3.0 + + + + org.fuin + cqrs-4-java + 0.3.0 + + + + org.fuin + objects4j + 0.7.0 + + + + org.fuin.esc + esc-api + ${esc.version} + + + + org.fuin.esc + esc-spi + ${esc.version} + + + + org.fuin.esc + esc-esjc + ${esc.version} + + + + org.fuin.esc + esc-eshttp + ${esc.version} + + + + org.fuin.esc + esc-mem + ${esc.version} + + + + org.glassfish + jakarta.json + 1.1.6 + + + + org.eclipse + yasson + 1.0.8 + + + + junit + junit + 4.13.1 + + + + org.assertj + assertj-core + 3.18.1 + + + + org.fuin + units4j + 0.9.0 + + + + nl.jqno.equalsverifier + equalsverifier + 3.5 + + + + commons-io + commons-io + 2.8.0 + + + + + + + + + + + + + + io.fabric8 + docker-maven-plugin + 0.34.1 + + + + + + + + + + + + sonatype.oss.snapshots + Sonatype OSS Snapshot Repository + https://oss.sonatype.org/content/repositories/snapshots + + false + + + always + true + + + + + shared query diff --git a/spring-boot/query/README.md b/spring-boot/query/README.md index 1dfc0ec..fe0dbdd 100644 --- a/spring-boot/query/README.md +++ b/spring-boot/query/README.md @@ -16,6 +16,37 @@ Make sure you installed everything as described [here](../../../../). ## Overview ![Overview](https://raw.github.com/fuinorg/ddd-cqrs-4-java-example/master/spring-boot/query/doc/spring-view.png) +## Running test in IDE +In case you want to run the integration test inside your IDE (Eclipse or other), you need to start the Eventstore and MariaDB before. + +1. Start the Eventstore Docker container: + +``` +docker run -d --name eventstore-node \ +-p 2113:2113 \ +-p 1113:1113 \ +--rm \ +eventstore/eventstore:release-5.0.9 +``` + +2. Start the MariaDB Docker container: + +``` +docker run -d --name mariadb \ +-p 3306:3306 \ +-e MYSQL_INITDB_SKIP_TZINFO=1 \ +-e MYSQL_ROOT_PASSWORD=xyz \ +-e MYSQL_DATABASE=querydb \ +-e MYSQL_USER=mary \ +-e MYSQL_PASSWORD=abc \ +--rm \ +mariadb:10.4 +``` + +3. Run the test: [PersonControllerIT.java](src/test/java/org/fuin/cqrs4j/example/spring/query/api/PersonControllerIT.java) + +4. Run `docker ps` to see the CONTAINER IDs and stop the Eventstore and MariaDB with `docker stop ` + # TODO ... **Issues** diff --git a/spring-boot/query/pom.xml b/spring-boot/query/pom.xml index b3402cd..f8eb0bc 100644 --- a/spring-boot/query/pom.xml +++ b/spring-boot/query/pom.xml @@ -2,28 +2,20 @@ + 4.0.0 + - org.springframework.boot - spring-boot-starter-parent - 2.2.0.RELEASE - + org.fuin.cqrs4j.example.spring + cqrs4j-spring-example-root + 0.2.0-SNAPSHOT + ../pom.xml - org.fuin.cqrs4j.example.spring cqrs4j-spring-example-query - 0.2.0-SNAPSHOT cqrs4j-spring-example-query Spring Boot CQRS Query Demo Application - - UTF-8 - 1.8 - 1.8 - 1.8 - 0.3.1 - - @@ -63,25 +55,21 @@ org.fuin cqrs-4-java - 0.2.1 org.fuin.esc esc-spi - ${esc.version} org.fuin.esc esc-esjc - ${esc.version} org.fuin.esc esc-eshttp - ${esc.version} @@ -167,12 +155,11 @@ io.fabric8 docker-maven-plugin - 0.31.0 - eventstore/eventstore:release-4.1.3 + eventstore/eventstore:release-${eventstore.version} bridge @@ -245,21 +232,4 @@ - - - - sonatype.oss.snapshots - Sonatype OSS Snapshot Repository - https://oss.sonatype.org/content/repositories/snapshots - - false - - - always - true - - - - - diff --git a/spring-boot/query/src/main/java/org/fuin/cqrs4j/example/spring/query/views/personlist/PersonListEventChunkHandler.java b/spring-boot/query/src/main/java/org/fuin/cqrs4j/example/spring/query/views/personlist/PersonListEventChunkHandler.java index 1652a5b..2119141 100644 --- a/spring-boot/query/src/main/java/org/fuin/cqrs4j/example/spring/query/views/personlist/PersonListEventChunkHandler.java +++ b/spring-boot/query/src/main/java/org/fuin/cqrs4j/example/spring/query/views/personlist/PersonListEventChunkHandler.java @@ -2,7 +2,7 @@ package org.fuin.cqrs4j.example.spring.query.views.personlist; import java.util.Set; -import javax.annotation.concurrent.NotThreadSafe; +import org.fuin.objects4j.common.NotThreadSafe; import org.fuin.cqrs4j.ProjectionService; import org.fuin.cqrs4j.example.shared.SharedUtils; diff --git a/spring-boot/query/src/main/java/org/fuin/cqrs4j/example/spring/query/views/personlist/PersonListEventDispatcher.java b/spring-boot/query/src/main/java/org/fuin/cqrs4j/example/spring/query/views/personlist/PersonListEventDispatcher.java index 6e794b2..61b8965 100644 --- a/spring-boot/query/src/main/java/org/fuin/cqrs4j/example/spring/query/views/personlist/PersonListEventDispatcher.java +++ b/spring-boot/query/src/main/java/org/fuin/cqrs4j/example/spring/query/views/personlist/PersonListEventDispatcher.java @@ -3,7 +3,7 @@ package org.fuin.cqrs4j.example.spring.query.views.personlist; import java.util.List; import java.util.Set; -import javax.annotation.concurrent.NotThreadSafe; +import org.fuin.objects4j.common.NotThreadSafe; import javax.validation.constraints.NotNull; import org.fuin.cqrs4j.EventDispatcher; diff --git a/spring-boot/query/src/main/java/org/fuin/cqrs4j/example/spring/query/views/personlist/PersonListProjector.java b/spring-boot/query/src/main/java/org/fuin/cqrs4j/example/spring/query/views/personlist/PersonListProjector.java index 967e008..246673c 100644 --- a/spring-boot/query/src/main/java/org/fuin/cqrs4j/example/spring/query/views/personlist/PersonListProjector.java +++ b/spring-boot/query/src/main/java/org/fuin/cqrs4j/example/spring/query/views/personlist/PersonListProjector.java @@ -9,7 +9,7 @@ import java.util.concurrent.Semaphore; import java.util.concurrent.atomic.AtomicBoolean; import javax.annotation.PreDestroy; -import javax.annotation.concurrent.ThreadSafe; +import org.fuin.objects4j.common.ThreadSafe; import org.fuin.ddd4j.ddd.EventType; import org.fuin.esc.api.TypeName; diff --git a/spring-boot/query/src/test/java/org/fuin/cqrs4j/example/spring/query/api/PersonControllerIT.java b/spring-boot/query/src/test/java/org/fuin/cqrs4j/example/spring/query/api/PersonControllerIT.java index 9a83b95..d97d2af 100644 --- a/spring-boot/query/src/test/java/org/fuin/cqrs4j/example/spring/query/api/PersonControllerIT.java +++ b/spring-boot/query/src/test/java/org/fuin/cqrs4j/example/spring/query/api/PersonControllerIT.java @@ -91,6 +91,8 @@ public class PersonControllerIT { // TEST & VERIFY + // given().pathParam("id", personId.asString()).when().get("/persons/{id}").then().log().all(true); + final PersonListEntry person = given().pathParam("id", personId.asString()).when().get("/persons/{id}").then() .statusCode(200).extract().as(PersonListEntry.class); assertThat(person.getId(), is(equalTo(personId))); diff --git a/spring-boot/shared/pom.xml b/spring-boot/shared/pom.xml index b56029b..e65b964 100644 --- a/spring-boot/shared/pom.xml +++ b/spring-boot/shared/pom.xml @@ -5,26 +5,16 @@ 4.0.0 - org.springframework.boot - spring-boot-starter-parent - 2.2.0.RELEASE - + org.fuin.cqrs4j.example.spring + cqrs4j-spring-example-root + 0.2.0-SNAPSHOT + ../pom.xml - org.fuin.cqrs4j.example.spring cqrs4j-spring-example-shared - 0.2.0-SNAPSHOT cqrs4j-spring-example-shared Spring Boot CQRS Shared Code for Demo Application - - UTF-8 - 1.8 - 1.8 - 1.8 - 0.3.1 - - @@ -48,37 +38,31 @@ org.fuin ddd-4-java - 0.2.1 org.fuin cqrs-4-java - 0.2.1 org.fuin objects4j - 0.6.9 org.fuin.esc esc-spi - ${esc.version} org.fuin.esc esc-esjc - ${esc.version} org.fuin.esc esc-eshttp - ${esc.version} @@ -93,14 +77,12 @@ org.glassfish - javax.json - 1.1.4 + jakarta.json org.eclipse yasson - 1.0.3 @@ -125,21 +107,18 @@ org.fuin units4j - 0.8.4 test nl.jqno.equalsverifier equalsverifier - 2.4.6 test commons-io commons-io - 2.6 test diff --git a/spring-boot/shared/src/main/java/org/fuin/cqrs4j/example/spring/shared/BeanFactory.java b/spring-boot/shared/src/main/java/org/fuin/cqrs4j/example/spring/shared/BeanFactory.java index 7f081da..2c53fef 100644 --- a/spring-boot/shared/src/main/java/org/fuin/cqrs4j/example/spring/shared/BeanFactory.java +++ b/spring-boot/shared/src/main/java/org/fuin/cqrs4j/example/spring/shared/BeanFactory.java @@ -30,77 +30,81 @@ import com.github.msemys.esjc.EventStoreBuilder; @Component public class BeanFactory { - /** - * Creates a Jsonb instance. - * - * @return Fully configured instance. - */ - @Bean - public Jsonb createJsonb() { - final JsonbConfig config = new JsonbConfig().withAdapters(SharedUtils.JSONB_ADAPTERS) - .withPropertyVisibilityStrategy(new FieldAccessStrategy()); - final Jsonb jsonb = JsonbBuilder.create(config); - return jsonb; - } + /** + * Creates a Jsonb instance. + * + * @return Fully configured instance. + */ + @Bean + public Jsonb createJsonb() { + final JsonbConfig config = new JsonbConfig().withAdapters(SharedUtils.JSONB_ADAPTERS) + .withPropertyVisibilityStrategy(new FieldAccessStrategy()); + final Jsonb jsonb = JsonbBuilder.create(config); + return jsonb; + } - /** - * Creates a TCP based event store connection. - * - * @param config Configuration to use. - * - * @return New event store instance. - */ - @Bean(destroyMethod = "shutdown") - public com.github.msemys.esjc.EventStore getEventStore(final Config config) { - return EventStoreBuilder.newBuilder() - .singleNodeAddress(config.getEventStoreHost(), config.getEventStoreTcpPort()) - .executor(Executors.newFixedThreadPool(10)) - .userCredentials(config.getEventStoreUser(), config.getEventStorePassword()).build(); - } + /** + * Creates a TCP based event store connection. + * + * @param config + * Configuration to use. + * + * @return New event store instance. + */ + @Bean(destroyMethod = "shutdown") + public com.github.msemys.esjc.EventStore getEventStore(final Config config) { + return EventStoreBuilder.newBuilder().singleNodeAddress(config.getEventStoreHost(), config.getEventStoreTcpPort()) + .executor(Executors.newFixedThreadPool(10)).userCredentials(config.getEventStoreUser(), config.getEventStorePassword()) + .build(); + } - /** - * Creates an event store connection. - * - * @param config Configuration to use. - * - * @return New event store instance. - */ - @Bean(destroyMethod = "close") - public IESJCEventStore getESJCEventStore(final com.github.msemys.esjc.EventStore es) { + /** + * Creates an event store connection. + * + * @param config + * Configuration to use. + * + * @return New event store instance. + */ + @Bean(destroyMethod = "close") + public IESJCEventStore getESJCEventStore(final com.github.msemys.esjc.EventStore es) { - final SerDeserializerRegistry registry = SharedUtils.createRegistry(); - final IESJCEventStore eventstore = new ESJCEventStore(es, registry, registry, - EnhancedMimeType.create("application", "json", Charset.forName("utf-8"))); - eventstore.open(); - return eventstore; + final SerDeserializerRegistry registry = SharedUtils.createRegistry(); - } + final IESJCEventStore eventstore = new ESJCEventStore.Builder().eventStore(es).serDesRegistry(registry) + .targetContentType(EnhancedMimeType.create("application", "json", Charset.forName("utf-8"))).build(); + eventstore.open(); + return eventstore; + + } + + /** + * Creates a HTTP based event store connection. + * + * @param config + * Configuration to use. + * + * @return New event store instance. + */ + @Bean(destroyMethod = "close") + public IESHttpEventStore getESHttpEventStore(final Config config) { + final String url = config.getEventStoreProtocol() + "://" + config.getEventStoreHost() + ":" + config.getEventStoreHttpPort(); + try { + final CredentialsProvider credentialsProvider = new BasicCredentialsProvider(); + final UsernamePasswordCredentials credentials = new UsernamePasswordCredentials(config.getEventStoreUser(), + config.getEventStorePassword()); + credentialsProvider.setCredentials(AuthScope.ANY, credentials); + final SerDeserializerRegistry registry = SharedUtils.createRegistry(); + + final ESHttpEventStore es = new ESHttpEventStore.Builder().threadFactory(Executors.defaultThreadFactory()).url(new URL(url)) + .envelopeType(ESEnvelopeType.JSON).serDesRegistry(registry).credentialsProvider(credentialsProvider).build(); + + es.open(); + return es; + } catch (final MalformedURLException ex) { + throw new RuntimeException("Failed to create URL: " + url, ex); + } + } - /** - * Creates a HTTP based event store connection. - * - * @param config Configuration to use. - * - * @return New event store instance. - */ - @Bean(destroyMethod = "close") - public IESHttpEventStore getESHttpEventStore(final Config config) { - final String url = config.getEventStoreProtocol() + "://" + config.getEventStoreHost() + ":" - + config.getEventStoreHttpPort(); - try { - final CredentialsProvider credentialsProvider = new BasicCredentialsProvider(); - final UsernamePasswordCredentials credentials = new UsernamePasswordCredentials(config.getEventStoreUser(), - config.getEventStorePassword()); - credentialsProvider.setCredentials(AuthScope.ANY, credentials); - final SerDeserializerRegistry registry = SharedUtils.createRegistry(); - final ESHttpEventStore es = new ESHttpEventStore(Executors.defaultThreadFactory(), new URL(url), - ESEnvelopeType.JSON, registry, registry, credentialsProvider); - es.open(); - return es; - } catch (final MalformedURLException ex) { - throw new RuntimeException("Failed to create URL: " + url, ex); - } - } - } diff --git a/spring-boot/shared/src/main/java/org/fuin/cqrs4j/example/spring/shared/GlobalExceptionHandler.java b/spring-boot/shared/src/main/java/org/fuin/cqrs4j/example/spring/shared/GlobalExceptionHandler.java index 69529cc..ba826ac 100644 --- a/spring-boot/shared/src/main/java/org/fuin/cqrs4j/example/spring/shared/GlobalExceptionHandler.java +++ b/spring-boot/shared/src/main/java/org/fuin/cqrs4j/example/spring/shared/GlobalExceptionHandler.java @@ -16,7 +16,7 @@ import java.util.ArrayList; import java.util.List; import java.util.Set; -import javax.annotation.Nullable; +import org.fuin.objects4j.common.Nullable; import javax.validation.ConstraintViolation; import javax.validation.ConstraintViolationException;