Skip to content

knetic0/java-mediator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Ā 

History

8 Commits
Ā 
Ā 
Ā 
Ā 
Ā 
Ā 
Ā 
Ā 
Ā 
Ā 
Ā 
Ā 
Ā 
Ā 

Repository files navigation

The mediator pattern implementing on Java Spring Boot

A lightweight, annotation‐driven Mediator pattern implementation for Spring Boot that decouples request objects from their handlers and centralizes the dispatch logic.

Features

  • Annotation-based configuration: Enable the mediator with a single annotation.

  • Generic request/response support: Send commands and queries with typed responses.

  • Automatic handler registration: All your RequestHandler beans are discovered and wired up.

  • Spring Boot starter–style integration: Plug into any existing Spring Boot app.

Getting Started

Maven

<dependency>
  <groupId>com.mehmetsolak</groupId>
  <artifactId>spring-boot-mediator</artifactId>
  <version>1.0.0</version>
</dependency>

Gradle

implementation 'com.mehmetsolak:spring-boot-mediator:1.0.0'

Enable the Mediator

Add @EnableMediator to your main Spring Boot application class:

Enable-Mediator

Defining a Command

Create a class that implements your Request<TResponse> interface. For example, a CarCreateCommand that returns a CarResponse:

Car-Command

Implementing a Command Handler

Implement RequestHandler<CommandType, ResponseType> and annotate it as a Spring bean:

Car-Command-Handler

Sending Commands from a Controller

Inject Mediator into your controller and send() your command:

Car-Controller

Result

Result

Contributing

Contributions are welcome! Feel free to open issues or submit pull requests for improvements.

Contact

For questions or suggestions, please open an issue or contact the maintainer.

About

šŸ”„ Implementing the Mediator Pattern in Java Spring Boot.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages