{"id":18559061,"url":"https://github.com/linux-china/ddd-base","last_synced_at":"2025-04-09T10:10:09.425Z","repository":{"id":23389990,"uuid":"26751731","full_name":"linux-china/ddd-base","owner":"linux-china","description":"DDD(Domain Driven Design) base package for java","archived":false,"fork":false,"pushed_at":"2023-03-31T15:14:31.000Z","size":241,"stargazers_count":261,"open_issues_count":1,"forks_count":81,"subscribers_count":25,"default_branch":"master","last_synced_at":"2025-04-02T02:51:08.861Z","etag":null,"topics":["ddd"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/linux-china.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2014-11-17T10:28:19.000Z","updated_at":"2025-01-11T15:22:07.000Z","dependencies_parsed_at":"2024-11-06T21:45:07.702Z","dependency_job_id":"bcef9bb9-3e4b-46a4-b3ec-007cb4b3572c","html_url":"https://github.com/linux-china/ddd-base","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/linux-china%2Fddd-base","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/linux-china%2Fddd-base/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/linux-china%2Fddd-base/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/linux-china%2Fddd-base/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/linux-china","download_url":"https://codeload.github.com/linux-china/ddd-base/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248018061,"owners_count":21034048,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ddd"],"created_at":"2024-11-06T21:41:57.408Z","updated_at":"2025-04-09T10:10:09.402Z","avatar_url":"https://github.com/linux-china.png","language":"Java","funding_links":[],"categories":["开发框架"],"sub_categories":[],"readme":"DDD Base\n========\n![\"Building Status\"](https://img.shields.io/github/workflow/status/linux-china/ddd-base/Java%20CI%20with%20Maven)\n\nDomain Driven Design base package for Java.\n\n# How to use it in Java?\n\nPlease refer https://jitpack.io/#linux-china/ddd-base/1.1.1\n\n# Features\n\n* Annotations\n* Base classes for entity, domain event etc\n* Domain event: follow CloudEvents specification and CloudEvent convert support\n* DDD Reactive: https://www.reactive-streams.org/\n\n# Components\n\n* Data: Entity, VO and Aggregate\n* Behaviour: Repository, Service, Factory and Specification\n* Event: Follow CloudEvents spec\n* Infrastructure\n* CQRS interfaces for command \u0026 query\n\n# Reactive\n\nDDD + Reactive(RSocket) to make context map easy.\n\n# Code Structure\n\nPlease visit [src/test/java](https://github.com/linux-china/ddd-base/tree/master/src/test/java/org/mvnsearch/demo/domain) for code structure\n\nIf you use Kotlin to develop application, the structure will be different, please add entity, vo and repository in the same kt file.\n\n# Events\n\nPlease extend DomainEvent or DomainEventBuilder, then use ApplicationEventPublisher to publish the event. please\nrefer https://spring.io/blog/2015/02/11/better-application-events-in-spring-framework-4-2\n\nAttention: Spring framework 5.2 will add reactive support:  https://github.com/spring-projects/spring-framework/issues/21831\n\nEvent extensions(JavaScript Object):\n\n* Distributed Tracing extension(traceparent, tracestate):  embeds context from Distributed Tracing so that distributed systems can include traces that span an event-driven system.\n* Dataref(dataref): reference another location where this information is stored\n* 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\n  scaling.\n* Sequence(sequence): describe the position of an event in the ordered sequence of events produced by a unique event source\n* Sampling(sampledrate): Sampling\n* Multi-tenant(tenantId): Multi-tenant system support\n\nCloudEvents JSONSchema: https://github.com/cloudevents/spec/blob/v0.3/spec.json\n\n### How to create event class\n\n* Extend CloudEvent class:\n\n```java\npublic class LoginEvent extends CloudEvent\u003cString\u003e {\n\n    public LoginEvent(String email, String ip) {\n        setData(email);\n        setContentType(\"text/plain\");\n        setExtension(\"ip\", ip);\n    }\n}\n```\n\n* Create an event directly\n\n```\nCloudEvent\u003cString\u003e loginEvent = new CloudEvent\u003cString\u003e(\"text/plain\", \"linux_china@hotmail.com\");\n```\n\n* Event Builder or reactive processor\n\n```\nCloudEvent\u003cString\u003e loginEvent = CloudEventBuilder.\u003cString\u003enewInstance().contentType(\"text/plain\").data(\"linux_china@hotmail.com\").build();\n```\n\n* Non-blocking Event Listener: https://github.com/spring-projects/spring-framework/issues/21831\n\n```java\n\n@Component\npublic class MyListener {\n\n    @EventListener\n    public Mono\u003cVoid\u003e handleContextRefresh(ContextRefreshedEvent event) {\n        //...\n    }\n\n    @EventListener\n    public Flux\u003cMyBusinessResponseEvent\u003e handleBusinessEvent(MyBusinessEvent event) {\n        //...\n    }\n\n    @EventListener\n    public CompletableFuture\u003cVoid\u003e handleBusinessEvent(MyOtherBusinessEvent event) {\n        //...\n    }\n}\n```\n\n### ObjectMapper\n\n* ObjectMapper creation\n\n```\nObjectMapper objectMapper = new ObjectMapper();\nobjectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);\nobjectMapper.enable(SerializationFeature.INDENT_OUTPUT);\n```\n\n* write as String\n\n```\nobjectMapper.writeValueAsString(loginEvent);\n```\n\n* read from json text\n\n```\nobjectMapper.readValue(jsonText, new TypeReference\u003cCloudEvent\u003cString\u003e\u003e() {});\n```\n\n### References\n\n* CloudEvents Specification: https://github.com/cloudevents/spec/blob/master/spec.md\n* Reactive Streams: http://www.reactive-streams.org/\n* DDD Reference: https://domainlanguage.com/wp-content/uploads/2016/05/DDD_Reference_2015-03.pdf\n* ddd-4-java: Base classes for Domain Driven Design with Java  https://github.com/fuinorg/ddd-4-java\n* jMolecules – Architectural abstractions for Java with DDD concepts https://github.com/xmolecules/jmolecules\n* Domain-Driven Design Crew: https://github.com/ddd-crew\n* What is Event Sourcing? https://www.eventstore.com/blog/what-is-event-sourcing\n* Event Sourcing and CQRS: https://www.eventstore.com/blog/event-sourcing-and-cqrs\n* CQRS Document: https://cqrs.files.wordpress.com/2010/11/cqrs_documents.pdf\n* remesh: a DDD framework for large and complex TypeScript/JavaScript applications - https://github.com/remesh-js/remesh","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flinux-china%2Fddd-base","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flinux-china%2Fddd-base","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flinux-china%2Fddd-base/lists"}