Skip to content

Commit 24da0a0

Browse files
authored
Router: Refactoring move baselocation and isProduction to configuration (#2525)
* refactor: simplify `AzureDnsApiSimulator` by replacing `Outcome.RETURN` with static import and minor cleanup in methods * refactor: improve JMX lifecycle management and HotDeployer YAML support - Replace `DefaultRouter` with `Router` in `JmxRouter` for enhanced abstraction. - Introduce `JMX_NAMESPACE` for improved consistency in bean names. - Enhance `JmxExporter` with static factory methods and improved `Router` integration. - Update `HotDeployer` to provide debug logging for unsupported YAML configurations. * refactor: improve JMX lifecycle management and HotDeployer YAML support - Replace `DefaultRouter` with `Router` in `JmxRouter` for enhanced abstraction. - Introduce `JMX_NAMESPACE` for improved consistency in bean names. - Enhance `JmxExporter` with static factory methods and improved `Router` integration. - Update `HotDeployer` to provide debug logging for unsupported YAML configurations. * refactor: streamline JMX integration and lifecycle handling - Remove unused methods and imports from `DefaultRouter`, `JmxRouter`, and `Configuration`. - Simplify `JmxExporter` by replacing `MBeanExporter` inheritance and improving lifecycle checks with `exporter` nullability. - Optimize `addRouter()` in `JmxExporter` by removing redundant exception handling. * extend: increase test timeout in `MassivelyParallelTest` and update JMX namespace in roadmap
1 parent 9d23eca commit 24da0a0

53 files changed

Lines changed: 250 additions & 327 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

core/src/main/java/com/predic8/membrane/core/cli/RouterCLI.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ private static Router initRouterByYAML(MembraneCommandLine commandLine, String o
161161

162162
private static Router initRouterByYAML(String location) throws Exception {
163163
var router = new DefaultRouter();
164-
router.setBaseLocation(location);
164+
router.getConfiguration().setBaseLocation(location);
165165

166166
GrammarAutoGenerated grammar = new GrammarAutoGenerated();
167167
BeanRegistryImplementation reg = new BeanRegistryImplementation(router, router, grammar);

core/src/main/java/com/predic8/membrane/core/interceptor/acl/AccessControlInterceptor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ protected AccessControl parse(String fileName, Router router) {
137137
try {
138138
reader = factory.createXMLStreamReader(
139139
router.getResolverMap().resolve(
140-
ResolverMap.combine(router.getBaseLocation(), fileName)));
140+
ResolverMap.combine(router.getConfiguration().getBaseLocation(), fileName)));
141141
AccessControl res = (AccessControl) new AccessControl(router).parse(reader);
142142
res.init(router);
143143
return res;

core/src/main/java/com/predic8/membrane/core/interceptor/apikey/stores/ApiKeyFileStore.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public class ApiKeyFileStore implements ApiKeyStore {
6161
@Override
6262
public void init(Router router) {
6363
try {
64-
scopes = readKeyData(readFile(location, router.getResolverMap(), router.getBaseLocation()));
64+
scopes = readKeyData(readFile(location, router.getResolverMap(), router.getConfiguration().getBaseLocation()));
6565
} catch (IOException e) {
6666
throw new RuntimeException(e);
6767
}

core/src/main/java/com/predic8/membrane/core/interceptor/authentication/session/LDAPUserDataProvider.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,7 @@ public void init(Router router) {
442442
}
443443

444444
if (sslParser != null)
445-
CustomSocketFactory.sslContext = new StaticSSLContext(sslParser, router.getResolverMap(), router.getBaseLocation());
445+
CustomSocketFactory.sslContext = new StaticSSLContext(sslParser, router.getResolverMap(), router.getConfiguration().getBaseLocation());
446446
}
447447

448448
public AttributeMap getMap() {

core/src/main/java/com/predic8/membrane/core/interceptor/authentication/session/LoginDialog.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,15 +89,15 @@ public void init(Router router) {
8989
wsi.init(router);
9090
try {
9191
// This is only a check if index.html is present
92-
router.getResolverMap().resolve(ResolverMap.combine(router.getBaseLocation(), wsi.getDocBase(), "index.html")).close();
92+
router.getResolverMap().resolve(ResolverMap.combine(router.getConfiguration().getBaseLocation(), wsi.getDocBase(), "index.html")).close();
9393
} catch (ResourceRetrievalException e) {
9494
throw new ConfigurationException("""
9595
Cannot access index.html at:
9696
Location base: %s
9797
Doc base: %s
98-
""".formatted( router.getBaseLocation(), wsi.getDocBase()),e);
98+
""".formatted( router.getConfiguration().getBaseLocation(), wsi.getDocBase()),e);
9999
} catch (IOException e) {
100-
log.error("Cannot access index.html (baseLocation={}, docBase={})" , router.getBaseLocation(), wsi.getDocBase(), e);
100+
log.error("Cannot access index.html (baseLocation={}, docBase={})" , router.getConfiguration().getBaseLocation(), wsi.getDocBase(), e);
101101
}
102102
}
103103

core/src/main/java/com/predic8/membrane/core/interceptor/authentication/xen/XenAuthenticationInterceptor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ public static class JwtSessionManager implements XenSessionManager {
141141
private final SecureRandom random = new SecureRandom();
142142

143143
public void init(Router router) throws Exception {
144-
String key = jwk.get(router.getResolverMap(), router.getBaseLocation());
144+
String key = jwk.get(router.getResolverMap(), router.getConfiguration().getBaseLocation());
145145
if (key == null || key.isEmpty())
146146
rsaJsonWebKey = generateKey();
147147
else

core/src/main/java/com/predic8/membrane/core/interceptor/cache/CacheInterceptor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ public void setDir(String dir) {
103103

104104
@Override
105105
public void init(Router router) {
106-
dir = ResolverMap.combine(router.getBaseLocation(), dir);
106+
dir = ResolverMap.combine(router.getConfiguration().getBaseLocation(), dir);
107107
File d = new File(dir);
108108
if (!d.exists())
109109
if (!d.mkdirs())

core/src/main/java/com/predic8/membrane/core/interceptor/jwt/JwtAuthInterceptor.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,12 @@ public void init() {
7070
if(jwtRetriever == null)
7171
jwtRetriever = new HeaderJwtRetriever("Authorization","Bearer");
7272

73-
jwks.init(router.getResolverMap(),router.getBaseLocation());
73+
jwks.init(router.getResolverMap(),router.getConfiguration().getBaseLocation());
7474

7575
kidToKey = jwks.getJwks().stream()
7676
.map(jwk -> {
7777
try {
78-
return new RsaJsonWebKey(mapper.readValue(jwk.getJwk(router.getResolverMap(), router.getBaseLocation(),mapper),Map.class));
78+
return new RsaJsonWebKey(mapper.readValue(jwk.getJwk(router.getResolverMap(), router.getConfiguration().getBaseLocation(),mapper),Map.class));
7979
} catch (Exception e) {
8080
throw new RuntimeException(e);
8181
}

core/src/main/java/com/predic8/membrane/core/interceptor/jwt/JwtSignInterceptor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public class JwtSignInterceptor extends AbstractInterceptor {
5252
public void init() {
5353
super.init();
5454
try {
55-
Map<String, Object> params = JsonUtil.parseJson(jwk.get(router.getResolverMap(), router.getBaseLocation()));
55+
Map<String, Object> params = JsonUtil.parseJson(jwk.get(router.getResolverMap(), router.getConfiguration().getBaseLocation()));
5656
if (Objects.equals(params.get("p"), DEFAULT_PKEY)) {
5757
log.warn("""
5858
\n------------------------------------ DEFAULT JWK IN USE! ------------------------------------

core/src/main/java/com/predic8/membrane/core/interceptor/oauth2/ConsentPageFile.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public void init(Router router, String url) throws IOException {
4747
createDefaults();
4848
return;
4949
}
50-
parseFile(getFromUrl(ResolverMap.combine(router.getBaseLocation(),url)));
50+
parseFile(getFromUrl(ResolverMap.combine(router.getConfiguration().getBaseLocation(),url)));
5151
}
5252

5353
private void parseFile(String consentPageFile) throws IOException {

0 commit comments

Comments
 (0)