Skip to content
This repository was archived by the owner on Nov 6, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,5 @@ install: true
script:
- ./gradlew assemble --warning-mode all
- ./gradlew check --warning-mode all
# Checks the application is running ok
- ./gradlew :app:run --warning-mode all
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
> You can do awesome stuff with Java 🙂

[![CodelyTV](https://img.shields.io/badge/codely-tv-green.svg?style=flat-square)](https://codely.tv)
[![Build Status](https://travis-ci.com/CodelyTV/cqrs-ddd-java-example.svg?branch=master)](https://travis-ci.com/CodelyTV/cqrs-ddd-java-example)
[![Build Status](https://travis-ci.org/CodelyTV/cqrs-ddd-java-example.svg?branch=master)](https://travis-ci.org/CodelyTV/cqrs-ddd-java-example)

Implementation example of a Java application following Domain-Driven Design (DDD) and Command Query Responsibility Segregation (CQRS) principles, keeping the code as simple as possible.

Expand Down
9 changes: 9 additions & 0 deletions applications/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
apply plugin: 'application'

mainClassName = 'tv.codely.Starter'

dependencies {
compile project(":src:backoffice")
compile project(":src:mooc")
}

7 changes: 7 additions & 0 deletions applications/main/tv/codely/Starter.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package tv.codely;

public class Starter {
public static void main(String[] args) {
System.out.println("In Works!");
}
}
72 changes: 47 additions & 25 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,36 +1,58 @@
apply plugin: 'java'
apply plugin: 'application'

sourceCompatibility = 1.11
targetCompatibility = 1.11

repositories {
mavenCentral()
jcenter()
buildscript {
repositories {
mavenCentral()
jcenter()
}
}

dependencies {
// Prod
implementation 'io.projectreactor:reactor-bus:2.0.8.RELEASE'
allprojects {
apply plugin: 'java'

// Test
testCompile "org.mockito:mockito-core:2.+"
testCompile 'org.junit.jupiter:junit-jupiter-api:5.+'
testRuntime 'org.junit.jupiter:junit-jupiter-engine:5.+'
}
sourceCompatibility = 11
targetCompatibility = 11

test {
useJUnitPlatform()
repositories {
mavenCentral()
}

testLogging {
events "passed", "skipped", "failed"
sourceSets {
main {
java { srcDirs = [ 'main' ] }
}
test {
java { srcDirs = [ 'test' ] }
}
}

reports {
html.enabled = true
task hello {
doLast { task ->
println "I'm $task.project.name"
}
}
}

application {
mainClassName = "tv.codely.context.video.module.video.infrastructure.VideoPublisherCliController"
subprojects {
group = "tv.codely.${rootProject.name}"

dependencies {
// Prod
implementation 'io.projectreactor:reactor-bus:2.0.8.RELEASE'

// Test
testCompile "org.mockito:mockito-core:2.+"
testCompile 'org.junit.jupiter:junit-jupiter-api:5.+'
testRuntime 'org.junit.jupiter:junit-jupiter-engine:5.+'
}

test {
useJUnitPlatform()

testLogging {
events "passed", "skipped", "failed"
}

reports {
html.enabled = true
}
}
}
3 changes: 2 additions & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#Sun Feb 24 20:05:13 CET 2019
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip
6 changes: 6 additions & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
rootProject.name = 'cqrs-ddd-java-example'

include 'applications'
include 'src:backoffice'
include 'src:mooc'
include 'src:shared'
3 changes: 3 additions & 0 deletions src/backoffice/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
dependencies {
compile project(":src:shared")
}
3 changes: 3 additions & 0 deletions src/mooc/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
dependencies {
compile project(":src:shared")
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package tv.codely.context.notification.module.push.application.create;
package tv.codely.mooc.notification.module.push.application.create;

import tv.codely.context.video.module.video.domain.VideoPublished;
import tv.codely.shared.application.DomainEventSubscriber;
import tv.codely.mooc.video.module.video.domain.VideoPublished;
import tv.codely.mooc.shared.application.DomainEventSubscriber;

public class SendPushToSubscribersOnVideoPublished implements DomainEventSubscriber<VideoPublished> {
@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package tv.codely.shared.application;
package tv.codely.mooc.shared.application;

import tv.codely.shared.domain.DomainEvent;
import tv.codely.mooc.shared.domain.DomainEvent;

public interface DomainEventSubscriber<EventType extends DomainEvent> {
Class<EventType> subscribedTo();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package tv.codely.shared.domain;
package tv.codely.mooc.shared.domain;

import java.util.LinkedList;
import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package tv.codely.shared.domain;
package tv.codely.mooc.shared.domain;

public interface DomainEvent {
String fullQualifiedEventName();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package tv.codely.shared.domain;
package tv.codely.mooc.shared.domain;

import java.util.List;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
package tv.codely.shared.infrastructure.bus;
package tv.codely.mooc.shared.infrastructure.bus;

import reactor.bus.Event;
import reactor.bus.EventBus;
import reactor.bus.selector.Selector;
import reactor.fn.Consumer;
import tv.codely.shared.application.DomainEventSubscriber;
import tv.codely.shared.domain.DomainEvent;
import tv.codely.mooc.shared.domain.DomainEvent;
import tv.codely.mooc.shared.application.DomainEventSubscriber;

import java.util.Arrays;
import java.util.List;
import java.util.Set;

import static reactor.bus.selector.Selectors.$;

public class ReactorEventBus implements tv.codely.shared.domain.EventBus {
public class ReactorEventBus implements tv.codely.mooc.shared.domain.EventBus {
private final EventBus bus;

public ReactorEventBus(final Set<DomainEventSubscriber> subscribers) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package tv.codely.context.video.module.video.application.publish;
package tv.codely.mooc.video.module.video.application.publish;

import tv.codely.context.video.module.video.domain.Video;
import tv.codely.context.video.module.video.domain.VideoDescription;
import tv.codely.context.video.module.video.domain.VideoTitle;
import tv.codely.shared.domain.EventBus;
import tv.codely.mooc.video.module.video.domain.Video;
import tv.codely.mooc.video.module.video.domain.VideoDescription;
import tv.codely.mooc.video.module.video.domain.VideoTitle;
import tv.codely.mooc.shared.domain.EventBus;

public final class VideoPublisher {
private final EventBus eventBus;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package tv.codely.context.video.module.video.domain;
package tv.codely.mooc.video.module.video.domain;

import tv.codely.shared.domain.AggregateRoot;
import tv.codely.mooc.shared.domain.AggregateRoot;

public final class Video extends AggregateRoot {
private final VideoTitle title;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package tv.codely.context.video.module.video.domain;
package tv.codely.mooc.video.module.video.domain;

public final class VideoDescription {
private final String value;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package tv.codely.context.video.module.video.domain;
package tv.codely.mooc.video.module.video.domain;

import tv.codely.shared.domain.DomainEvent;
import tv.codely.mooc.shared.domain.DomainEvent;

public final class VideoPublished implements DomainEvent {
private static final String FULL_QUALIFIED_EVENT_NAME = "codelytv.video.video.event.1.video.published";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package tv.codely.context.video.module.video.domain;
package tv.codely.mooc.video.module.video.domain;

public final class VideoTitle {
private final String value;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package tv.codely.context.video.module.video.infrastructure;
package tv.codely.mooc.video.module.video.infrastructure;

import tv.codely.context.notification.module.push.application.create.SendPushToSubscribersOnVideoPublished;
import tv.codely.context.video.module.video.application.publish.VideoPublisher;
import tv.codely.shared.application.DomainEventSubscriber;
import tv.codely.shared.domain.EventBus;
import tv.codely.shared.infrastructure.bus.ReactorEventBus;
import tv.codely.mooc.notification.module.push.application.create.SendPushToSubscribersOnVideoPublished;
import tv.codely.mooc.video.module.video.application.publish.VideoPublisher;
import tv.codely.mooc.shared.application.DomainEventSubscriber;
import tv.codely.mooc.shared.domain.EventBus;
import tv.codely.mooc.shared.infrastructure.bus.ReactorEventBus;

import java.util.Set;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package tv.codely.context.video.module.video.application.publish;
package tv.codely.mooc.video.application.publish;

import org.junit.jupiter.api.Test;
import tv.codely.context.video.module.video.domain.VideoPublished;
import tv.codely.shared.domain.EventBus;
import tv.codely.mooc.video.module.video.application.publish.VideoPublisher;
import tv.codely.mooc.video.module.video.domain.VideoPublished;
import tv.codely.mooc.shared.domain.EventBus;

import java.util.List;

Expand Down
3 changes: 3 additions & 0 deletions src/shared/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
dependencies {
// compile project('src:shared')
}