Skip to content

Commit f66a966

Browse files
predic8rrayst
andauthored
Router factor out hotdeploy (#2466)
* refactor: delegate hot deployment logic to new `HotDeployer` interface and streamline related code in `Router` * refactor: make `router` field in `DefaultHotDeployer` final for immutability * fix: ensure proper cleanup and initialization of `hotDeployer` in `Router` * refactor: enhance `Router` structure with streamlined initialization and reconfiguration logic * refactor: improve thread synchronization in `DefaultHotDeployer` and add `getLock()` in `Router` for enhanced concurrency handling * refactor: simplify `DefaultHotDeployer` by removing redundant `hotDeployingContexts` tracking and improve `Router` concurrency management * refactor: replace `System.exit` calls with `StartupException` in `Router` and `RouterCLI` for cleaner error handling during startup * refactor: remove redundant `errorNotice` logic and replace `System.exit` with `StartupException` in `RouterCLI` for cleaner error handling * refactor: extract `tryToGetConfigurationFile` method in `RouterCLI` for cleaner and reusable configuration resolution logic * refactor: improve error logging in `RouterCLI` and fix indentation for readability * refactor: replace `StartupException` with `ExitException` for streamlined error handling and debugging in `Router` and `RouterCLI` * refactor: relocate `ExitException` and rename method in `RouterCLI` for clarity and cohesion * refactor: improve synchronization and streamline `DefaultHotDeployer` by replacing direct bean factory access with `Router.getRef` * refactor: add synchronization to `DefaultHotDeployer.start` to prevent concurrent hot deployment initialization * protect 'running' field by 'lock' * added error, if Spring Context declares more than 1 router * added comment * refactor * refactor: synchronize `DefaultHotDeployer.stop` and initialize `Router.hotDeployer` with `NullHotDeployer` to enhance thread safety and prevent NPEs * refactor: simplify `Router.hotDeployer` initialization logic and clarify Javadoc for `setHotDeploy` * refactor: streamline `Router.hotDeployer` initialization and enhance `HotDeployer` interface with `init` method --------- Co-authored-by: Tobias Polley <mail@tobias-polley.de>
1 parent fd4a13a commit f66a966

7 files changed

Lines changed: 346 additions & 265 deletions

File tree

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package com.predic8.membrane.core;
2+
3+
/**
4+
* Exception that signals that the startup failed and that Membrane should exit.
5+
* It doesn't have a context or message cause it just signals that the program should exit.
6+
* By using the exception, it is possible to exit at only one place. That makes debugging and testing
7+
* of the Router class easier.
8+
* The exception is in this package instead of the cli package not to introduce a dependency to cli.
9+
*
10+
* TODO: Move exception to router subpackage together with Router.
11+
*/
12+
public class ExitException extends RuntimeException {
13+
}

0 commit comments

Comments
 (0)