refactor(banking-demo): introduce DemoApplication orchestrator and add controlled lifecycle management
- Replace DemoFactory with DemoApplication to centralize system setup, execution, and shutdown - Move ExecutorService and ScheduledExecutorService lifecycle management into application layer - Ensure proper shutdown sequence for worker and monitoring threads - Simplify Main class to a minimal entry-point wrapper - Improve clarity of execution flow: build → run → shutdown - Prevent resource leakage by explicitly awaiting termination of thread pools
This commit is contained in:
@@ -1,17 +1,11 @@
|
||||
package dev.banking;
|
||||
|
||||
import dev.banking.service.BankingSystem;
|
||||
import dev.banking.DemoFactory;
|
||||
|
||||
/**
|
||||
* Entry point of the application.
|
||||
*
|
||||
* This class is provided for demonstration purposes only.
|
||||
*
|
||||
* IMPORTANT:
|
||||
* - Do NOT modify this file.
|
||||
* - This file is NOT used during grading.
|
||||
* - All grading is performed through the provided JUnit tests.
|
||||
* - Do NOT modify this file in student assignment.
|
||||
* - This is only a wrapper for running the demo.
|
||||
*/
|
||||
public final class Main {
|
||||
|
||||
@@ -22,25 +16,19 @@ public final class Main {
|
||||
|
||||
System.out.println("=================================");
|
||||
System.out.println(" Advanced Banking System");
|
||||
System.out.println("=================================");
|
||||
System.out.println("=================================\n");
|
||||
|
||||
try {
|
||||
|
||||
BankingSystem bankingSystem =
|
||||
DemoFactory.createDemoSystem();
|
||||
|
||||
System.out.println("System initialized...");
|
||||
System.out.println("Running simulation with concurrent workers...\n");
|
||||
|
||||
// bankingSystem.start();
|
||||
DemoApplication.run();
|
||||
|
||||
System.out.println("\n=================================");
|
||||
System.out.println("Simulation completed successfully.");
|
||||
System.out.println(" System finished successfully ");
|
||||
System.out.println("=================================");
|
||||
|
||||
} catch (Exception e) {
|
||||
|
||||
System.err.println("\nUnexpected error occurred:");
|
||||
System.err.println("Unexpected error occurred:");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user