Conversation
PR SummaryAdds a framework-free SOA module implementing key architectural roles: Service, ServiceBus, ServiceRegistry and AccessPolicy, plus atomic services (Customer, Inventory, Payment) and a composite OrderService. Includes App bootstrap, tests, and diagrams/documentation. Also updates the root pom.xml to register the new module and provides a README with usage and trade-offs. Changes
autogenerated by presubmit.ai |
There was a problem hiding this comment.
🚨 Pull request needs attention.
Review Summary
Files Processed (22)
- pom.xml (1 hunk)
- service-oriented-architecture/README.md (1 hunk)
- service-oriented-architecture/etc/service-oriented-architecture.urm.puml (1 hunk)
- service-oriented-architecture/pom.xml (1 hunk)
- service-oriented-architecture/src/main/java/com/iluwatar/soa/App.java (1 hunk)
- service-oriented-architecture/src/main/java/com/iluwatar/soa/Customer.java (1 hunk)
- service-oriented-architecture/src/main/java/com/iluwatar/soa/CustomerService.java (1 hunk)
- service-oriented-architecture/src/main/java/com/iluwatar/soa/InventoryService.java (1 hunk)
- service-oriented-architecture/src/main/java/com/iluwatar/soa/OrderService.java (1 hunk)
- service-oriented-architecture/src/main/java/com/iluwatar/soa/PaymentService.java (1 hunk)
- service-oriented-architecture/src/main/java/com/iluwatar/soa/Service.java (1 hunk)
- service-oriented-architecture/src/main/java/com/iluwatar/soa/ServiceBus.java (1 hunk)
- service-oriented-architecture/src/main/java/com/iluwatar/soa/ServiceRegistry.java (1 hunk)
- service-oriented-architecture/src/main/java/com/iluwatar/soa/ServiceRequest.java (1 hunk)
- service-oriented-architecture/src/main/java/com/iluwatar/soa/ServiceResponse.java (1 hunk)
- service-oriented-architecture/src/test/java/com/iluwatar/soa/AppTest.java (1 hunk)
- service-oriented-architecture/src/test/java/com/iluwatar/soa/CustomerServiceTest.java (1 hunk)
- service-oriented-architecture/src/test/java/com/iluwatar/soa/InventoryServiceTest.java (1 hunk)
- service-oriented-architecture/src/test/java/com/iluwatar/soa/OrderServiceTest.java (1 hunk)
- service-oriented-architecture/src/test/java/com/iluwatar/soa/PaymentServiceTest.java (1 hunk)
- service-oriented-architecture/src/test/java/com/iluwatar/soa/ServiceBusTest.java (1 hunk)
- service-oriented-architecture/src/test/java/com/iluwatar/soa/ServiceRegistryTest.java (1 hunk)
Actionable Comments (4)
-
service-oriented-architecture/src/main/java/com/iluwatar/soa/App.java [61-61]
best_practice: "Fix incorrect logger usage in App.java"
-
service-oriented-architecture/src/main/java/com/iluwatar/soa/ServiceBus.java [57-57]
best_practice: "Logger usage mismatch with Lombok @slf4j in ServiceBus"
-
service-oriented-architecture/src/main/java/com/iluwatar/soa/ServiceRegistry.java [56-56]
best_practice: "Logger usage mismatch in ServiceRegistry"
-
service-oriented-architecture/src/main/java/com/iluwatar/soa/InventoryService.java [93-101]
possible bug: "Malformed string concatenation in reserve() error path"
Skipped Comments (0)
|
Note on the automated review comments: |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #3600 +/- ##
============================================
+ Coverage 84.06% 84.22% +0.15%
- Complexity 4353 4424 +71
============================================
Files 1133 1144 +11
Lines 15400 15599 +199
Branches 739 755 +16
============================================
+ Hits 12946 13138 +192
- Misses 2158 2163 +5
- Partials 296 298 +2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
993cea1 to
84e5c17
Compare
|
Updated the branch to cover point 8 (Security) of the issue guidelines: the bus now enforces an |
There was a problem hiding this comment.
🚨 Pull request needs attention.
Review Summary
Files Processed (24)
- pom.xml (1 hunk)
- service-oriented-architecture/README.md (1 hunk)
- service-oriented-architecture/etc/service-oriented-architecture.urm.puml (1 hunk)
- service-oriented-architecture/pom.xml (1 hunk)
- service-oriented-architecture/src/main/java/com/iluwatar/soa/AccessPolicy.java (1 hunk)
- service-oriented-architecture/src/main/java/com/iluwatar/soa/App.java (1 hunk)
- service-oriented-architecture/src/main/java/com/iluwatar/soa/Customer.java (1 hunk)
- service-oriented-architecture/src/main/java/com/iluwatar/soa/CustomerService.java (1 hunk)
- service-oriented-architecture/src/main/java/com/iluwatar/soa/InventoryService.java (1 hunk)
- service-oriented-architecture/src/main/java/com/iluwatar/soa/OrderService.java (1 hunk)
- service-oriented-architecture/src/main/java/com/iluwatar/soa/PaymentService.java (1 hunk)
- service-oriented-architecture/src/main/java/com/iluwatar/soa/Service.java (1 hunk)
- service-oriented-architecture/src/main/java/com/iluwatar/soa/ServiceBus.java (1 hunk)
- service-oriented-architecture/src/main/java/com/iluwatar/soa/ServiceRegistry.java (1 hunk)
- service-oriented-architecture/src/main/java/com/iluwatar/soa/ServiceRequest.java (1 hunk)
- service-oriented-architecture/src/main/java/com/iluwatar/soa/ServiceResponse.java (1 hunk)
- service-oriented-architecture/src/test/java/com/iluwatar/soa/AccessPolicyTest.java (1 hunk)
- service-oriented-architecture/src/test/java/com/iluwatar/soa/AppTest.java (1 hunk)
- service-oriented-architecture/src/test/java/com/iluwatar/soa/CustomerServiceTest.java (1 hunk)
- service-oriented-architecture/src/test/java/com/iluwatar/soa/InventoryServiceTest.java (1 hunk)
- service-oriented-architecture/src/test/java/com/iluwatar/soa/OrderServiceTest.java (1 hunk)
- service-oriented-architecture/src/test/java/com/iluwatar/soa/PaymentServiceTest.java (1 hunk)
- service-oriented-architecture/src/test/java/com/iluwatar/soa/ServiceBusTest.java (1 hunk)
- service-oriented-architecture/src/test/java/com/iluwatar/soa/ServiceRegistryTest.java (1 hunk)
Actionable Comments (1)
-
service-oriented-architecture/pom.xml [46-50]
enhancement: "Missing JUnit Jupiter API test dependency"
Skipped Comments (0)
84e5c17 to
453f532
Compare
|
Follow-up on the Codecov note: added |
There was a problem hiding this comment.
🚨 Pull request needs attention.
Review Summary
Files Processed (24)
- pom.xml (1 hunk)
- service-oriented-architecture/README.md (1 hunk)
- service-oriented-architecture/etc/service-oriented-architecture.urm.puml (1 hunk)
- service-oriented-architecture/pom.xml (1 hunk)
- service-oriented-architecture/src/main/java/com/iluwatar/soa/AccessPolicy.java (1 hunk)
- service-oriented-architecture/src/main/java/com/iluwatar/soa/App.java (1 hunk)
- service-oriented-architecture/src/main/java/com/iluwatar/soa/Customer.java (1 hunk)
- service-oriented-architecture/src/main/java/com/iluwatar/soa/CustomerService.java (1 hunk)
- service-oriented-architecture/src/main/java/com/iluwatar/soa/InventoryService.java (1 hunk)
- service-oriented-architecture/src/main/java/com/iluwatar/soa/OrderService.java (1 hunk)
- service-oriented-architecture/src/main/java/com/iluwatar/soa/PaymentService.java (1 hunk)
- service-oriented-architecture/src/main/java/com/iluwatar/soa/Service.java (1 hunk)
- service-oriented-architecture/src/main/java/com/iluwatar/soa/ServiceBus.java (1 hunk)
- service-oriented-architecture/src/main/java/com/iluwatar/soa/ServiceRegistry.java (1 hunk)
- service-oriented-architecture/src/main/java/com/iluwatar/soa/ServiceRequest.java (1 hunk)
- service-oriented-architecture/src/main/java/com/iluwatar/soa/ServiceResponse.java (1 hunk)
- service-oriented-architecture/src/test/java/com/iluwatar/soa/AccessPolicyTest.java (1 hunk)
- service-oriented-architecture/src/test/java/com/iluwatar/soa/AppTest.java (1 hunk)
- service-oriented-architecture/src/test/java/com/iluwatar/soa/CustomerServiceTest.java (1 hunk)
- service-oriented-architecture/src/test/java/com/iluwatar/soa/InventoryServiceTest.java (1 hunk)
- service-oriented-architecture/src/test/java/com/iluwatar/soa/OrderServiceTest.java (1 hunk)
- service-oriented-architecture/src/test/java/com/iluwatar/soa/PaymentServiceTest.java (1 hunk)
- service-oriented-architecture/src/test/java/com/iluwatar/soa/ServiceBusTest.java (1 hunk)
- service-oriented-architecture/src/test/java/com/iluwatar/soa/ServiceRegistryTest.java (1 hunk)
Actionable Comments (1)
-
service-oriented-architecture/src/main/java/com/iluwatar/soa/InventoryService.java [92-100]
possible bug: "Fix potential string concatenation bug in error message"
Skipped Comments (8)
-
service-oriented-architecture/src/main/java/com/iluwatar/soa/App.java [67-67]
best_practice: "Logger usage mismatch with Lombok @slf4j"
-
service-oriented-architecture/src/main/java/com/iluwatar/soa/App.java [76-76]
best_practice: "Replace LOGGER with log when using @slf4j"
-
service-oriented-architecture/src/main/java/com/iluwatar/soa/App.java [78-78]
best_practice: "Consistent logging with Lombok"
-
service-oriented-architecture/src/main/java/com/iluwatar/soa/App.java [88-88]
best_practice: "Consistent logging with Lombok"
-
service-oriented-architecture/src/main/java/com/iluwatar/soa/App.java [98-98]
best_practice: "Consistent logging with Lombok"
-
service-oriented-architecture/src/main/java/com/iluwatar/soa/App.java [102-102]
best_practice: "Consistent logging with Lombok"
-
service-oriented-architecture/src/main/java/com/iluwatar/soa/App.java [106-106]
best_practice: "Consistent logging with Lombok"
-
service-oriented-architecture/pom.xml [36-50]
test: "Add junit-jupiter-api as test dependency"
453f532 to
bf16d6e
Compare
|
Coverage follow-up: added |
There was a problem hiding this comment.
✅ LGTM!
Review Summary
Files Processed (24)
- pom.xml (1 hunk)
- service-oriented-architecture/README.md (1 hunk)
- service-oriented-architecture/etc/service-oriented-architecture.urm.puml (1 hunk)
- service-oriented-architecture/pom.xml (1 hunk)
- service-oriented-architecture/src/main/java/com/iluwatar/soa/AccessPolicy.java (1 hunk)
- service-oriented-architecture/src/main/java/com/iluwatar/soa/App.java (1 hunk)
- service-oriented-architecture/src/main/java/com/iluwatar/soa/Customer.java (1 hunk)
- service-oriented-architecture/src/main/java/com/iluwatar/soa/CustomerService.java (1 hunk)
- service-oriented-architecture/src/main/java/com/iluwatar/soa/InventoryService.java (1 hunk)
- service-oriented-architecture/src/main/java/com/iluwatar/soa/OrderService.java (1 hunk)
- service-oriented-architecture/src/main/java/com/iluwatar/soa/PaymentService.java (1 hunk)
- service-oriented-architecture/src/main/java/com/iluwatar/soa/Service.java (1 hunk)
- service-oriented-architecture/src/main/java/com/iluwatar/soa/ServiceBus.java (1 hunk)
- service-oriented-architecture/src/main/java/com/iluwatar/soa/ServiceRegistry.java (1 hunk)
- service-oriented-architecture/src/main/java/com/iluwatar/soa/ServiceRequest.java (1 hunk)
- service-oriented-architecture/src/main/java/com/iluwatar/soa/ServiceResponse.java (1 hunk)
- service-oriented-architecture/src/test/java/com/iluwatar/soa/AccessPolicyTest.java (1 hunk)
- service-oriented-architecture/src/test/java/com/iluwatar/soa/AppTest.java (1 hunk)
- service-oriented-architecture/src/test/java/com/iluwatar/soa/CustomerServiceTest.java (1 hunk)
- service-oriented-architecture/src/test/java/com/iluwatar/soa/InventoryServiceTest.java (1 hunk)
- service-oriented-architecture/src/test/java/com/iluwatar/soa/OrderServiceTest.java (1 hunk)
- service-oriented-architecture/src/test/java/com/iluwatar/soa/PaymentServiceTest.java (1 hunk)
- service-oriented-architecture/src/test/java/com/iluwatar/soa/ServiceBusTest.java (1 hunk)
- service-oriented-architecture/src/test/java/com/iluwatar/soa/ServiceRegistryTest.java (1 hunk)
Actionable Comments (0)
Skipped Comments (5)
-
service-oriented-architecture/src/main/java/com/iluwatar/soa/App.java [67-70]
best_practice: "Use the correct Lombok logger field"
-
service-oriented-architecture/src/main/java/com/iluwatar/soa/ServiceBus.java [66-92]
best_practice: "Logger usage should use the Lombok-provided 'log' field"
-
service-oriented-architecture/src/main/java/com/iluwatar/soa/ServiceRegistry.java [51-57]
best_practice: "Logger usage should use the Lombok-provided 'log' field"
-
service-oriented-architecture/src/main/java/com/iluwatar/soa/InventoryService.java [93-98]
readability: "Clarify error message construction"
-
service-oriented-architecture/pom.xml [36-39]
best_practice: "Add junit-jupiter-api test dependency"
There was a problem hiding this comment.
🚨 Pull request needs attention.
Review Summary
Commits Considered (4)
- 12e9aa7: fix: surface the inventory error when the stock check fails
OrderService reported every failed stock check as insufficient stock, which hid the real reason, for example a non-positive quantity. It now forwards the inventory message and only reports insufficient stock when the check itself succeeded.
- 23462b6: docs: embed the rendered class diagram in the service-oriented-architecture README
Render etc/service-oriented-architecture.urm.puml to PNG and embed it in the detailed explanation section, matching the other modules, instead of the inline mermaid block.
- a88f9d8: chore: tidy service javadoc and use the customer id in confirmations
Reword the App class javadoc so it describes the services the same way as the Service contract and the README: they keep no per-conversation state instead of being called stateless.
Note in OrderService.placeOrder that the checkStock call is there to illustrate service composition and not as a guard, since reserve re-checks the stock atomically.
Carry the customer id into OrderConfirmation so the confirmation identifies the customer it belongs to, and drop the unused email component from the Customer record. Update the tests, the URM diagram and the sample output in the README accordingly.
-
83eb3c8: fix: reserve stock before charging and validate order quantity
-
OrderService now reserves stock before charging and releases the reservation when the charge fails, so a rejected order never leaves the customer charged.
-
InventoryService gains a release operation and rejects a non-positive quantity in checkStock, reserve and release.
-
ServiceBus applies the access policy before the registry lookup, so a denied caller cannot probe which services exist.
-
Corrected the statelessness and interoperability claims in the javadoc and the README.
-
Replaced the class diagram link with an inline mermaid diagram, refreshed the sample output and kept the puml in sync.
Files Processed (15)
- service-oriented-architecture/README.md (1 hunk)
- service-oriented-architecture/etc/service-oriented-architecture.urm.png (0 hunks)
- service-oriented-architecture/etc/service-oriented-architecture.urm.puml (1 hunk)
- service-oriented-architecture/src/main/java/com/iluwatar/soa/App.java (1 hunk)
- service-oriented-architecture/src/main/java/com/iluwatar/soa/Customer.java (1 hunk)
- service-oriented-architecture/src/main/java/com/iluwatar/soa/CustomerService.java (1 hunk)
- service-oriented-architecture/src/main/java/com/iluwatar/soa/InventoryService.java (1 hunk)
- service-oriented-architecture/src/main/java/com/iluwatar/soa/OrderService.java (1 hunk)
- service-oriented-architecture/src/main/java/com/iluwatar/soa/Service.java (1 hunk)
- service-oriented-architecture/src/main/java/com/iluwatar/soa/ServiceBus.java (1 hunk)
- service-oriented-architecture/src/main/java/com/iluwatar/soa/ServiceRequest.java (1 hunk)
- service-oriented-architecture/src/test/java/com/iluwatar/soa/CustomerServiceTest.java (1 hunk)
- service-oriented-architecture/src/test/java/com/iluwatar/soa/InventoryServiceTest.java (1 hunk)
- service-oriented-architecture/src/test/java/com/iluwatar/soa/OrderServiceTest.java (1 hunk)
- service-oriented-architecture/src/test/java/com/iluwatar/soa/ServiceBusTest.java (1 hunk)
Actionable Comments (1)
-
service-oriented-architecture/src/main/java/com/iluwatar/soa/InventoryService.java [102-109]
bug: "Fix string concatenation in error message"
Skipped Comments (0)
12e9aa7 to
a569f16
Compare
The order flow is now reserve, charge, release on failure. Inventory rejects non-positive quantities and its errors are surfaced, the access policy runs before the registry lookup, the statelessness and interoperability wording is corrected, and confirmations carry the customer id. The class diagram is a rendered PNG.
a569f16 to
cd7ff04
Compare
There was a problem hiding this comment.
✅ LGTM!
Review Summary
Commits Considered (2)
- cd7ff04: fix: reserve stock before charging and validate order quantity
The order flow is now reserve, charge, release on failure. Inventory rejects non-positive quantities and its errors are surfaced, the access policy runs before the registry lookup, the statelessness and interoperability wording is corrected, and confirmations carry the customer id. The class diagram is a rendered PNG.
Files Processed (25)
- pom.xml (1 hunk)
- service-oriented-architecture/README.md (1 hunk)
- service-oriented-architecture/etc/service-oriented-architecture.urm.png (0 hunks)
- service-oriented-architecture/etc/service-oriented-architecture.urm.puml (1 hunk)
- service-oriented-architecture/pom.xml (1 hunk)
- service-oriented-architecture/src/main/java/com/iluwatar/soa/AccessPolicy.java (1 hunk)
- service-oriented-architecture/src/main/java/com/iluwatar/soa/App.java (1 hunk)
- service-oriented-architecture/src/main/java/com/iluwatar/soa/Customer.java (1 hunk)
- service-oriented-architecture/src/main/java/com/iluwatar/soa/CustomerService.java (1 hunk)
- service-oriented-architecture/src/main/java/com/iluwatar/soa/InventoryService.java (1 hunk)
- service-oriented-architecture/src/main/java/com/iluwatar/soa/OrderService.java (1 hunk)
- service-oriented-architecture/src/main/java/com/iluwatar/soa/PaymentService.java (1 hunk)
- service-oriented-architecture/src/main/java/com/iluwatar/soa/Service.java (1 hunk)
- service-oriented-architecture/src/main/java/com/iluwatar/soa/ServiceBus.java (1 hunk)
- service-oriented-architecture/src/main/java/com/iluwatar/soa/ServiceRegistry.java (1 hunk)
- service-oriented-architecture/src/main/java/com/iluwatar/soa/ServiceRequest.java (1 hunk)
- service-oriented-architecture/src/main/java/com/iluwatar/soa/ServiceResponse.java (1 hunk)
- service-oriented-architecture/src/test/java/com/iluwatar/soa/AccessPolicyTest.java (1 hunk)
- service-oriented-architecture/src/test/java/com/iluwatar/soa/AppTest.java (1 hunk)
- service-oriented-architecture/src/test/java/com/iluwatar/soa/CustomerServiceTest.java (1 hunk)
- service-oriented-architecture/src/test/java/com/iluwatar/soa/InventoryServiceTest.java (1 hunk)
- service-oriented-architecture/src/test/java/com/iluwatar/soa/OrderServiceTest.java (1 hunk)
- service-oriented-architecture/src/test/java/com/iluwatar/soa/PaymentServiceTest.java (1 hunk)
- service-oriented-architecture/src/test/java/com/iluwatar/soa/ServiceBusTest.java (1 hunk)
- service-oriented-architecture/src/test/java/com/iluwatar/soa/ServiceRegistryTest.java (1 hunk)
Actionable Comments (0)
Skipped Comments (0)
…ed-architecture # Conflicts: # pom.xml
| * @param args command line arguments, not used | ||
| */ | ||
| public static void main(String[] args) { | ||
| LOGGER.info("Bootstrapping the service registry and the service bus"); |
There was a problem hiding this comment.
In a class annotated with @slf4j, Lombok provides a 'log' field, not 'LOGGER'. The code currently uses LOGGER.info(...), which will not compile. Replace with log.info(...) and align all other logging calls in this file accordingly.
| request.operation(), | ||
| request.credential() == null ? "anonymous" : "credentialed"); | ||
| return ServiceResponse.error("Access denied to " + request.service()); | ||
| } |
There was a problem hiding this comment.
Logging is done with LOGGER, but the class uses @slf4j. Replace LOGGER.* with log.* to align with Lombok's generated logger.
| request.operation(), | ||
| response.success(), | ||
| TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - start)); | ||
| return response; |
There was a problem hiding this comment.
Further in this file, all remaining LOGGER usages should be replaced with log to maintain consistency with @slf4j. Example: log.info("-> {}.{} payload={}", ...)
|
Hi @iluwatar, I've resolved the merge conflicts in |
What does this PR do?
Adds the Service-Oriented Architecture (SOA) pattern as a new
service-oriented-architecturemodule, implemented in plain Java without frameworks so the architectural mechanism stays visible.Service: the contract every service exposes (name()andhandle(ServiceRequest)); services are stateless.ServiceRequest/ServiceResponse: coarse-grained, self-describing messages that form the interoperability boundary (flat payload, uniform response envelope).ServiceRegistry: discovery by name on aConcurrentHashMap, rejects duplicate registrations.ServiceBus: routes messages to the registered service, applies cross-cutting concerns (tracing, timing) in one place and translates provider failures into error responses, so consumers only ever talk to the bus.CustomerService,InventoryService,PaymentService: reusable atomic services.OrderService: composite service that orchestrates the three atomic services through the bus to place an order.App: bootstraps registry and bus, registers the services, places an order that succeeds, one that is rejected for stock, and addresses an unregistered service. Logging traces every message.README.md: intent, real-world example, diagram, code walkthrough, applicability, real-world uses (ESBs, SOAP/WSDL), trade-offs, related patterns including how SOA differs from microservices. PlantUML class diagram underetc/.AppTest.pom.xml../mvnw clean verify -pl service-oriented-architecturepasses locally on JDK 21 and inside aneclipse-temurin:21container.Fixes #2937