How simonharmonicminor/spring-chain-of-responsibility-example works
Project type and purpose
• This is a small Spring Boot example application demonstrating the Chain of Responsibility design pattern.
• The README and package names (com.example.demo.enrichment) explicitly point to a pipeline of “enrichment” steps applied to a Message object.
File structure
Top-level:
• build.gradle, gradlew, settings.gradle – standard Gradle/Spring Boot build and wrapper files.
• src/main/java/com/example/demo – core application code.
Within com.example.demo:
• DemoApplication.java – Spring Boot entry point.
• Message.java – the domain object being enriched.
Enrichment package:
• AbstractEnrichmentStep, EnrichmentStep (interface), ChainElement – implementing the Chain of Responsibility pattern.
• AgeEnrichmentStep, GeoLocationEnrichmentStep, PhoneNumberEnrichmentStep, NoOpEnrichmentStep – concrete pipeline steps.
• EnrichmentStepFacade – orchestrates running the chain.
Repo package:
• Repositories (AgeRepository, GeoLocationRepository, PhoneNumberRepository) plus stub implementations under Stub*Repository.
Resources:
• application.properties – any config values (e.g., database or external API endpoints).
README for additional insights
• Confirms this is purely an example of the Chain of Responsibility in Spring, with no production-grade external services.
• No external DB; stubs simulate data access.