From 1702471d9103a4752b6dca3dfa049a2d9bf91b09 Mon Sep 17 00:00:00 2001 From: Kabir Khan Date: Tue, 9 Apr 2024 12:20:28 +1000 Subject: [PATCH] [WFCORE-6753] Make ServerEnvironment.setStability() package protected --- .../jboss/as/server/ServerEnvironment.java | 3 +-- ...rEnvironmentAwareProcessReloadHandler.java | 25 +++++++++++++++++++ .../ServerProcessReloadHandler.java | 9 +++---- 3 files changed, 30 insertions(+), 7 deletions(-) create mode 100644 server/src/main/java/org/jboss/as/server/ServerEnvironmentAwareProcessReloadHandler.java diff --git a/server/src/main/java/org/jboss/as/server/ServerEnvironment.java b/server/src/main/java/org/jboss/as/server/ServerEnvironment.java index 589684470e6..35646ff3eea 100644 --- a/server/src/main/java/org/jboss/as/server/ServerEnvironment.java +++ b/server/src/main/java/org/jboss/as/server/ServerEnvironment.java @@ -1190,8 +1190,7 @@ private void checkStabilityIsValidForInstallation(ProductConfig productConfig, S } } - // TODO Figure out how to make this package protected - public void setStability(Stability stability) { + void setStability(Stability stability) { WildFlySecurityManager.setPropertyPrivileged(ProcessEnvironment.STABILITY, stability.toString()); this.stability = stability; } diff --git a/server/src/main/java/org/jboss/as/server/ServerEnvironmentAwareProcessReloadHandler.java b/server/src/main/java/org/jboss/as/server/ServerEnvironmentAwareProcessReloadHandler.java new file mode 100644 index 00000000000..8c508334780 --- /dev/null +++ b/server/src/main/java/org/jboss/as/server/ServerEnvironmentAwareProcessReloadHandler.java @@ -0,0 +1,25 @@ +/* + * Copyright The WildFly Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +package org.jboss.as.server; + +import org.jboss.as.controller.ControlledProcessState; +import org.jboss.as.controller.RunningModeControl; +import org.jboss.as.controller.operations.common.ProcessReloadHandler; +import org.jboss.as.version.Stability; +import org.jboss.msc.service.ServiceName; + +public abstract class ServerEnvironmentAwareProcessReloadHandler extends ProcessReloadHandler { + protected final ServerEnvironment environment; + + public ServerEnvironmentAwareProcessReloadHandler(ServiceName rootService, RunningModeControl runningModeControl, ControlledProcessState processState, ServerEnvironment environment) { + super(rootService, runningModeControl, processState); + this.environment = environment; + } + + protected void updateServerEnvironmentStability(Stability stability) { + environment.setStability(stability); + } +} diff --git a/server/src/main/java/org/jboss/as/server/operations/ServerProcessReloadHandler.java b/server/src/main/java/org/jboss/as/server/operations/ServerProcessReloadHandler.java index 28f2d969d20..821b834b70c 100644 --- a/server/src/main/java/org/jboss/as/server/operations/ServerProcessReloadHandler.java +++ b/server/src/main/java/org/jboss/as/server/operations/ServerProcessReloadHandler.java @@ -27,6 +27,7 @@ import org.jboss.as.controller.registry.ManagementResourceRegistration; import org.jboss.as.controller.persistence.ExtensibleConfigurationPersister; import org.jboss.as.server.ServerEnvironment; +import org.jboss.as.server.ServerEnvironmentAwareProcessReloadHandler; import org.jboss.as.server.Services; import org.jboss.as.server.controller.descriptions.ServerDescriptions; import org.jboss.as.server.logging.ServerLogger; @@ -39,7 +40,7 @@ * * @author Kabir Khan */ -public class ServerProcessReloadHandler extends ProcessReloadHandler { +public class ServerProcessReloadHandler extends ServerEnvironmentAwareProcessReloadHandler { private static final AttributeDefinition USE_CURRENT_SERVER_CONFIG = new SimpleAttributeDefinitionBuilder(ModelDescriptionConstants.USE_CURRENT_SERVER_CONFIG, ModelType.BOOLEAN, true) .setAlternatives(ModelDescriptionConstants.SERVER_CONFIG) @@ -84,14 +85,12 @@ public class ServerProcessReloadHandler extends ProcessReloadHandler additionalAttributes; - private final ServerEnvironment environment; private ExtensibleConfigurationPersister extensibleConfigurationPersister; public ServerProcessReloadHandler(ServiceName rootService, RunningModeControl runningModeControl, ControlledProcessState processState, ServerEnvironment environment, Set additionalAttributes, ExtensibleConfigurationPersister extensibleConfigurationPersister) { - super(rootService, runningModeControl, processState); + super(rootService, runningModeControl, processState, environment); this.additionalAttributes = additionalAttributes == null ? Collections.emptySet() : additionalAttributes; - this.environment = environment; this.extensibleConfigurationPersister = extensibleConfigurationPersister; } @@ -178,7 +177,7 @@ public void doReload(RunningModeControl runningModeControl) { runningModeControl.setNewBootFileName(serverConfig); runningModeControl.setSuspend(finalSuspend); if (stability != null) { - environment.setStability(stability); + updateServerEnvironmentStability(stability); } runningModeControl.setApplyConfigurationExtension(applyConfigurationExtension); }