• Stars
    star
    255
  • Rank 159,729 (Top 4 %)
  • Language
    Java
  • Created about 10 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

DDD(Domain Driven Design) base package for java

DDD Base

"Building Status"

Domain Driven Design base package for Java.

How to use it in Java?

Please refer https://jitpack.io/#linux-china/ddd-base/1.1.1

Features

  • Annotations
  • Base classes for entity, domain event etc
  • Domain event: follow CloudEvents specification and CloudEvent convert support
  • DDD Reactive: https://www.reactive-streams.org/

Components

  • Data: Entity, VO and Aggregate
  • Behaviour: Repository, Service, Factory and Specification
  • Event: Follow CloudEvents spec
  • Infrastructure
  • CQRS interfaces for command & query

Reactive

DDD + Reactive(RSocket) to make context map easy.

Code Structure

Please visit src/test/java for code structure

If you use Kotlin to develop application, the structure will be different, please add entity, vo and repository in the same kt file.

Events

Please extend DomainEvent or DomainEventBuilder, then use ApplicationEventPublisher to publish the event. please refer https://spring.io/blog/2015/02/11/better-application-events-in-spring-framework-4-2

Attention: Spring framework 5.2 will add reactive support: spring-projects/spring-framework#21831

Event extensions(JavaScript Object):

  • Distributed Tracing extension(traceparent, tracestate): embeds context from Distributed Tracing so that distributed systems can include traces that span an event-driven system.
  • Dataref(dataref): reference another location where this information is stored
  • Partitioning(partitionkey): This extension defines an attribute for use by message brokers and their clients that support partitioning of events, typically for the purpose of scaling.
  • Sequence(sequence): describe the position of an event in the ordered sequence of events produced by a unique event source
  • Sampling(sampledrate): Sampling
  • Multi-tenant(tenantId): Multi-tenant system support

CloudEvents JSONSchema: https://github.com/cloudevents/spec/blob/v0.3/spec.json

How to create event class

  • Extend CloudEvent class:
public class LoginEvent extends CloudEvent<String> {

    public LoginEvent(String email, String ip) {
        setData(email);
        setContentType("text/plain");
        setExtension("ip", ip);
    }
}
  • Create an event directly
CloudEvent<String> loginEvent = new CloudEvent<String>("text/plain", "[email protected]");
  • Event Builder or reactive processor
CloudEvent<String> loginEvent = CloudEventBuilder.<String>newInstance().contentType("text/plain").data("[email protected]").build();
@Component
public class MyListener {

    @EventListener
    public Mono<Void> handleContextRefresh(ContextRefreshedEvent event) {
        //...
    }

    @EventListener
    public Flux<MyBusinessResponseEvent> handleBusinessEvent(MyBusinessEvent event) {
        //...
    }

    @EventListener
    public CompletableFuture<Void> handleBusinessEvent(MyOtherBusinessEvent event) {
        //...
    }
}

ObjectMapper

  • ObjectMapper creation
ObjectMapper objectMapper = new ObjectMapper();
objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
objectMapper.enable(SerializationFeature.INDENT_OUTPUT);
  • write as String
objectMapper.writeValueAsString(loginEvent);
  • read from json text
objectMapper.readValue(jsonText, new TypeReference<CloudEvent<String>>() {});

References

More Repositories

1

jenv

Java enVironment Manager
Shell
603
star
2

chatgpt-spring-boot-starter

Spring Boot ChatGPT Starter
Java
481
star
3

spring-boot-dubbo

Spring Boot with Dubbo support
Java
278
star
4

dubbo3

Dubbo3: distributed RPC framework from Alibaba Dubbo2
Java
255
star
5

awesome-rsocket

Awesome RSocket
190
star
6

mybatis-r2dbc

MyBatis R2DBC Adapter
Java
131
star
7

weixin-robot-java

ๅพฎไฟกๅ…ฌๅ…ฑๅนณๅฐๆœบๅ™จไบบJava SDK
Java
119
star
8

plantuml-gist

PlantUML with Github Gist and Gitlab Support
Java
96
star
9

dx

A tool and task runner for writing better scripts with Deno
TypeScript
93
star
10

zookeeper-intellij

IntelliJ IDEA ZooKeeper Plugin
Java
62
star
11

spring-boot-starter-redisson

Spring Boot starter for Redisson
Java
58
star
12

h2-functions-4-mysql

H2 functions for MySQL
Java
57
star
13

spring-boot-starter-okhttp3

Spring Boot Starter for OkHttp3
Java
55
star
14

spring-boot-starter-httpclient

Spring Boot Starter for HttpClient
Java
54
star
15

vitest-jetbrains-plugin

Vitest JetBrains plugin
Kotlin
52
star
16

spring-boot-rsocket-demo

Spring Boot RSocket Demo with RPC style
Java
42
star
17

spring-boot-thymeleaf3-bootstrap4-angular4

Spring Boot Kotlin Application Template for Thymeleaf3, BootStrap4 and Angularjs 4
TypeScript
42
star
18

toolchains-maven-plugin

Toolchains Maven Plugin with JDK auto download
Java
36
star
19

xtermjs-spring-boot-starter

Web terminal to manage your Spring Boot app
Java
30
star
20

spring-cloud-function-demo

Spring cloud function with RSocket
Java
24
star
21

spring-boot-starter-wechatmp

Spring Boot with Wechat Support
Java
23
star
22

ngrok-spring-boot-starter

Easy to expose a local Spring Boot Application to the internet by ngrok
Java
23
star
23

smarty4j

Smarty Template Engine for Java
Java
22
star
24

spring-boot-starter-oss

Spring Boot Start with Aliyun OSS
Java
19
star
25

reactive-demo

Reactive Demo with Reactor, RxJava and reactive-stream
Java
19
star
26

jetbrains-just-plugin

JetBrains Just Command Runner Plugin
Kotlin
19
star
27

cli-completion

CLI completion for bash, zsh, fish and powershell
Rust
18
star
28

spring-boot-microservices

Spring Boot MicroServices
Java
18
star
29

spring-boot-starter-shell

Spring Shell with Spring Boot Driven
Java
17
star
30

chrome_js_api_stub

Chrome JavaScript API Stub to assistant extension development in IDE
JavaScript
16
star
31

rsocket-load-balancing

RSocket load balancing based on Spring Cloud Service Registry
Java
15
star
32

kotlin-wasm-demo

Kotlin WebAssembly Demo
Kotlin
15
star
33

spring-boot-kotlin-microservices

Spring Boot MicroServices with Kotlin
Kotlin
14
star
34

task-keeper

A cli to manage tasks from different task runners or package managers
Rust
13
star
35

open2internet-spring-boot-starter

Expose local Spring Boot Application to internet for demonstration, testing and debuging
Java
13
star
36

ali-oss-shell

Aliyun OSS Shell
Java
12
star
37

easy-random-junit5-extension

JUnit 5 extension for easy-random
Java
12
star
38

rocker-template-demo

Rocker template demo with Spring Boot
Java
12
star
39

mail-catcher

MailCatcher runs a super simple SMTP server which catches any message sent to it to display in a web interface
Java
12
star
40

kotlin-platform-bom

Kotlin Platform BOM
Just
11
star
41

axum-demo

Axum demo
Rust
11
star
42

rsocket-deno

๐Ÿฆ•RSocket Deno module
TypeScript
11
star
43

r2dbc-demo

R2DBC demo
Java
11
star
44

oh-my-zsh-spring-boot-plugin

oh-my-zsh Spring Boot plugin
10
star
45

team

Team Instruction
10
star
46

java-error-messages-wizard

Java Error Message Wizard
Java
10
star
47

ddd-demo

DDD demo with Java 8 and Spring Boot
Java
9
star
48

jenv-ps

jenv Power Shell Edition
PowerShell
9
star
49

nats-spring-boot-starter

Spring Boot starter for NATS
Java
9
star
50

struts2-spring-boot-integration

Spring Boot with Struts 2.5.x Integration
Java
8
star
51

kafka-demo

Kafka Demo with Spring Boot, Docker and Terraform
Java
8
star
52

rest-editor-client-contrib

REST Editor Client Contrib plugin for IntelliJ IDEA
Java
8
star
53

jenv-idea-plugin

jenv IntelliJ IDEA plugin
Java
8
star
54

mybatis-demo

MyBatis Demo with spring-boot-starter-mybatis integration
Java
8
star
55

platform-bom-contrib

Spring Platform IO BOM Contrib
Java
8
star
56

java9-in-action

Java 9 in Action
Java
7
star
57

aliyun-openapi-rust-sdk

Aliyun OpenAPI SDK for Rust
Rust
7
star
58

tgm

Template generator management
Rust
7
star
59

npm-export-spring-boot-starter

Spring Boot Starter to generate npm package to call REST API
Java
7
star
60

xterm-demo

Xterm.js with RSocket
JavaScript
7
star
61

apache-pulsar-demo

Apache Pulsar demo
Java
7
star
62

http2-java-demo

Spring Boot with HTTP/2
Java
7
star
63

spring-boot-apache-dubbo

Spring Boot 2.0 with Apache Dubbo
Java
7
star
64

markdown-chatgpt

Talk to ChatGPT from Markdown
Kotlin
7
star
65

trpc-spring-boot-starter

Spring Boot Starter for tRPC
Java
7
star
66

reactive-grpc-demo

gRPC with reactive Reactor
Java
6
star
67

unitTest_templates

unitTest IntelliJ IDEA plugin templates
6
star
68

proto-rsocket-plugin

Protobuf to RSocket service interface
Java
6
star
69

grpc-kotlin-demo

gRPC with Kotlin Demo
Kotlin
6
star
70

java11_in_action

Java 11 in Action
Java
6
star
71

markdown-wasm

Markdown wasm based on md4c for Deno ๐Ÿฆ•
TypeScript
6
star
72

kotlin-deno-example

๐Ÿฆ•Deno app development with Kotlin
Kotlin
6
star
73

zshmarks

zsh marks for oh-my-zsh
6
star
74

trunk-demo

WebAssembly development with Trunk & Vite.js
Rust
6
star
75

reactive-grpc-spring-boot-starter

Spring Boot Starter for Reactive gRPC
Java
6
star
76

hessian-spring-boot-starter

Spring Boot Start for Hessian
Java
6
star
77

alibaba-broker-example-parent

Alibaba RSocket Broker Example
Java
6
star
78

akka-demo

Akka Demo with Kotlin, Spring Integration
Java
5
star
79

intellij-templates

IntelliJ IDEA live templates
5
star
80

zookeeper-shell

New ZooKeeper shell just like bash
Java
5
star
81

embind_demo

Emscripten embind demo
C++
5
star
82

graal-native-image-demo

Graal native image demo with RSocket and Netty
Java
5
star
83

dkim-spring-boot-starter

DKIM for spring-boot-starter-mail
Java
5
star
84

akka-spring-boot-starter

akka-spring-boot-starter
Java
5
star
85

rsocket-dart

RSocket Dart SDK
Dart
4
star
86

deno-rust-wasm-demo

Deno with Rust Wasm
TypeScript
4
star
87

rest-graphql-rsocket-demo

One controller to combine HTTP REST, GraphQL and RSocket
Java
4
star
88

aria2-shell

Aria2 Shell
Java
4
star
89

spring-boot-starter-job-controller

Spring Boot with Job Controller
Java
4
star
90

aeron-demo

Aeron Spring Reactive Demo
Java
4
star
91

rsocket-transport-quic

RSocket QUIC transport
Java
4
star
92

spring-cloud-aliyun

Integration for Aliyun Cloud Services APIs with Spring Cloud
Shell
4
star
93

jvmtop

Clone from https://code.google.com/p/jvmtop
Java
4
star
94

kotlin-wasm-browser-demo

Kotlin WebAssembly demo for Browser
Kotlin
4
star
95

deno-httpx

httpx: cli to run requests from http file
TypeScript
4
star
96

kotlin-coroutine-demo

Kotlin Coroutines demo
Kotlin
4
star
97

spring-boot-polyglot-demo

Spring Boot Polyglot with Kotlin, Java + Lombok + Groovy
Kotlin
4
star
98

esnippet_idea_plugin

eSnippet IntelliJ IDEA plugin
Java
4
star
99

microservices-annotator

Java Annotations for Microservices annotator to mark your code
Java
3
star
100

logback-fluentd-appender

Logback Fluentd Appender
Java
3
star