diff --git a/cli/src/main/java/org/jboss/as/cli/embedded/EmbedHostControllerHandler.java b/cli/src/main/java/org/jboss/as/cli/embedded/EmbedHostControllerHandler.java index bb2ba84f690..584e72c7815 100644 --- a/cli/src/main/java/org/jboss/as/cli/embedded/EmbedHostControllerHandler.java +++ b/cli/src/main/java/org/jboss/as/cli/embedded/EmbedHostControllerHandler.java @@ -90,6 +90,7 @@ static EmbedHostControllerHandler create(final AtomicReference se result.removeExisting = new ArgumentWithoutValue(result, "--remove-existing"); result.removeExisting.addRequiredPreceding(result.emptyConfig); result.timeout = new ArgumentWithValue(result, "--timeout"); + // TODO: Use ProductConfig.getStabilitySet() result.stability = new ArgumentWithValue(result, new SimpleTabCompleter(EnumSet.allOf(Stability.class)), "--stability"); return result; diff --git a/controller/src/main/java/org/jboss/as/controller/registry/ManagementResourceRegistration.java b/controller/src/main/java/org/jboss/as/controller/registry/ManagementResourceRegistration.java index 3c9bacd571e..5ca563dbac9 100644 --- a/controller/src/main/java/org/jboss/as/controller/registry/ManagementResourceRegistration.java +++ b/controller/src/main/java/org/jboss/as/controller/registry/ManagementResourceRegistration.java @@ -67,7 +67,8 @@ public interface ManagementResourceRegistration extends ImmutableManagementResou * * @param resourceDefinition source for descriptive information describing this * portion of the model (must not be {@code null}) - * @return a resource registration which may be used to add attributes, operations, notifications and sub-models + * @return a resource registration which may be used to add attributes, operations, notifications and sub-models, + * or null, if this resource definition is not enabled by the current stability level. * * @throws IllegalArgumentException if a submodel is already registered at {@code address} * @throws IllegalStateException if {@link #isRuntimeOnly()} returns {@code true} @@ -103,7 +104,7 @@ public interface ManagementResourceRegistration extends ImmutableManagementResou * @param name the specific name of the resource. Cannot be {@code null} or {@link PathElement#WILDCARD_VALUE} * @param descriptionProvider provider for descriptions of the additional attributes or child types * - * @return a resource registration which may be used to add attributes, operations and sub-models + * @return a resource registration which may be used to add attributes, operations and sub-models. * * @throws IllegalArgumentException if either parameter is null or if there is already a registration under {@code name} * @throws IllegalStateException if {@link #isRuntimeOnly()} returns {@code true} or if {@link #isAllowsOverride()} returns false @@ -118,7 +119,8 @@ public interface ManagementResourceRegistration extends ImmutableManagementResou * @param registration the child registration of this registry that should no longer be available * @param descriptionProvider provider for descriptions of the additional attributes or child types * - * @return a resource registration which may be used to add attributes, operations and sub-models + * @return a resource registration which may be used to add attributes, operations and sub-models, + * or null, if this resource definition is not enabled by the current stability level. * * @throws IllegalArgumentException if either parameter is null or if there is already a registration under {@code name} * @throws IllegalStateException if {@link #isRuntimeOnly()} returns {@code true} or if {@link #isAllowsOverride()} returns false diff --git a/host-controller/src/main/java/org/jboss/as/host/controller/HostControllerEnvironment.java b/host-controller/src/main/java/org/jboss/as/host/controller/HostControllerEnvironment.java index 74cee6926f8..c7aa92a746d 100644 --- a/host-controller/src/main/java/org/jboss/as/host/controller/HostControllerEnvironment.java +++ b/host-controller/src/main/java/org/jboss/as/host/controller/HostControllerEnvironment.java @@ -485,7 +485,7 @@ public HostControllerEnvironment(Map hostSystemProperties, boole this.processType = processType; this.stability = getEnumProperty(hostSystemProperties, STABILITY, this.productConfig.getDefaultStability()); - if (!this.productConfig.getMinimumStability().enables(this.stability)) { + if (!this.productConfig.getStabilitySet().contains(this.stability)) { throw HostControllerLogger.ROOT_LOGGER.unsupportedStability(this.stability, this.productConfig.getProductName()); } if (!hostSystemProperties.containsKey(STABILITY)) { diff --git a/host-controller/src/main/java/org/jboss/as/host/controller/HostControllerEnvironmentWrapper.java b/host-controller/src/main/java/org/jboss/as/host/controller/HostControllerEnvironmentWrapper.java index 2743c813c7f..ab19c3ad53b 100644 --- a/host-controller/src/main/java/org/jboss/as/host/controller/HostControllerEnvironmentWrapper.java +++ b/host-controller/src/main/java/org/jboss/as/host/controller/HostControllerEnvironmentWrapper.java @@ -5,6 +5,8 @@ package org.jboss.as.host.controller; +import org.jboss.as.version.ProductConfig; + /** * @author wangc * @@ -18,18 +20,20 @@ enum HostControllerEnvironmentStatus { private HostControllerEnvironment hostControllerEnvironment; private HostControllerEnvironmentStatus hostControllerEnvironmentStatus; + private ProductConfig productConfig; - private HostControllerEnvironmentWrapper(HostControllerEnvironment hostControllerEnvironment, HostControllerEnvironmentStatus hostControllerEnvironmentStatus) { + private HostControllerEnvironmentWrapper(HostControllerEnvironment hostControllerEnvironment, HostControllerEnvironmentStatus hostControllerEnvironmentStatus, ProductConfig productConfig) { this.hostControllerEnvironment = hostControllerEnvironment; this.hostControllerEnvironmentStatus = hostControllerEnvironmentStatus; + this.productConfig = productConfig; } HostControllerEnvironmentWrapper(HostControllerEnvironment hostControllerEnvironment) { - this(hostControllerEnvironment, null); + this(hostControllerEnvironment, null, hostControllerEnvironment.getProductConfig()); } - HostControllerEnvironmentWrapper(HostControllerEnvironmentStatus hostControllerEnvironmentStatus) { - this(null, hostControllerEnvironmentStatus); + HostControllerEnvironmentWrapper(HostControllerEnvironmentStatus hostControllerEnvironmentStatus, ProductConfig productConfig) { + this(null, hostControllerEnvironmentStatus, productConfig); } public HostControllerEnvironment getHostControllerEnvironment() { @@ -39,4 +43,8 @@ public HostControllerEnvironment getHostControllerEnvironment() { public HostControllerEnvironmentStatus getHostControllerEnvironmentStatus() { return hostControllerEnvironmentStatus; } + + public ProductConfig getProductConfig() { + return this.productConfig; + } } diff --git a/host-controller/src/main/java/org/jboss/as/host/controller/Main.java b/host-controller/src/main/java/org/jboss/as/host/controller/Main.java index 10ffdc59eb9..a0a1696de25 100644 --- a/host-controller/src/main/java/org/jboss/as/host/controller/Main.java +++ b/host-controller/src/main/java/org/jboss/as/host/controller/Main.java @@ -118,7 +118,7 @@ private HostControllerBootstrap boot(String[] args, final String authCode) { final long startTime = Module.getStartTime(); final HostControllerEnvironmentWrapper hostControllerEnvironmentWrapper = determineEnvironment(args, startTime); if (hostControllerEnvironmentWrapper.getHostControllerEnvironment() == null) { - usage(); // In case there was an error determining the environment print the usage + usage(hostControllerEnvironmentWrapper.getProductConfig()); // In case there was an error determining the environment print the usage if (hostControllerEnvironmentWrapper.getHostControllerEnvironmentStatus() == HostControllerEnvironmentWrapper.HostControllerEnvironmentStatus.ERROR) { abort(); } else { @@ -174,8 +174,8 @@ private static void fail(){ SystemExiter.abort(ExitCodes.FAILED); } - private static void usage() { - CommandLineArgumentUsageImpl.printUsage(STDOUT); + private static void usage(ProductConfig productConfig) { + CommandLineArgumentUsageImpl.printUsage(productConfig, STDOUT); } public static HostControllerEnvironmentWrapper determineEnvironment(String[] args, long startTime) { @@ -196,7 +196,7 @@ public static HostControllerEnvironmentWrapper determineEnvironment(String[] arg String initialHostConfig = null; RunningMode initialRunningMode = RunningMode.NORMAL; Map hostSystemProperties = getHostSystemProperties(); - ProductConfig productConfig; + ProductConfig productConfig = ProductConfig.fromFilesystemSlot(Module.getBootModuleLoader(), WildFlySecurityManager.getPropertyPrivileged(HostControllerEnvironment.HOME_DIR, null), null); ConfigurationFile.InteractionPolicy hostConfigInteractionPolicy = ConfigurationFile.InteractionPolicy.STANDARD; ConfigurationFile.InteractionPolicy domainConfigInteractionPolicy = ConfigurationFile.InteractionPolicy.STANDARD; String modulePath = null; @@ -215,22 +215,22 @@ public static HostControllerEnvironmentWrapper determineEnvironment(String[] arg || CommandLineConstants.SHORT_PROPERTIES.equals(arg)) { // Set system properties from url/file if (!processProperties(arg, args[++i], hostSystemProperties)) { - return new HostControllerEnvironmentWrapper(HostControllerEnvironmentWrapper.HostControllerEnvironmentStatus.ERROR); + return new HostControllerEnvironmentWrapper(HostControllerEnvironmentWrapper.HostControllerEnvironmentStatus.ERROR, productConfig); } } else if (arg.startsWith(CommandLineConstants.PROPERTIES)) { String urlSpec = parseValue(arg, CommandLineConstants.PROPERTIES); if (urlSpec == null || !processProperties(arg, urlSpec, hostSystemProperties)) { - return new HostControllerEnvironmentWrapper(HostControllerEnvironmentWrapper.HostControllerEnvironmentStatus.ERROR); + return new HostControllerEnvironmentWrapper(HostControllerEnvironmentWrapper.HostControllerEnvironmentStatus.ERROR, productConfig); } } else if (arg.startsWith(CommandLineConstants.SHORT_PROPERTIES)) { String urlSpec = parseValue(arg, CommandLineConstants.SHORT_PROPERTIES); if (urlSpec == null || !processProperties(arg, urlSpec, hostSystemProperties)) { - return new HostControllerEnvironmentWrapper(HostControllerEnvironmentWrapper.HostControllerEnvironmentStatus.ERROR); + return new HostControllerEnvironmentWrapper(HostControllerEnvironmentWrapper.HostControllerEnvironmentStatus.ERROR, productConfig); } } else if (arg.startsWith(CommandLineConstants.OLD_PROPERTIES)) { String urlSpec = parseValue(arg, CommandLineConstants.OLD_PROPERTIES); if (urlSpec == null || !processProperties(arg, urlSpec, hostSystemProperties)) { - return new HostControllerEnvironmentWrapper(HostControllerEnvironmentWrapper.HostControllerEnvironmentStatus.ERROR); + return new HostControllerEnvironmentWrapper(HostControllerEnvironmentWrapper.HostControllerEnvironmentStatus.ERROR, productConfig); } } else if (CommandLineConstants.PROCESS_CONTROLLER_BIND_PORT.equals(arg)) { final String port = args[++i]; @@ -238,16 +238,16 @@ public static HostControllerEnvironmentWrapper determineEnvironment(String[] arg pmPort = Integer.valueOf(port); } catch (NumberFormatException e) { STDERR.println(HostControllerLogger.ROOT_LOGGER.invalidValue(CommandLineConstants.PROCESS_CONTROLLER_BIND_PORT, "Integer", port, usageNote())); - return new HostControllerEnvironmentWrapper(HostControllerEnvironmentWrapper.HostControllerEnvironmentStatus.ERROR); + return new HostControllerEnvironmentWrapper(HostControllerEnvironmentWrapper.HostControllerEnvironmentStatus.ERROR, productConfig); } } else if (arg.startsWith(CommandLineConstants.PROCESS_CONTROLLER_BIND_PORT)) { String val = parseValue(arg, CommandLineConstants.PROCESS_CONTROLLER_BIND_PORT); if (val == null) { - return new HostControllerEnvironmentWrapper(HostControllerEnvironmentWrapper.HostControllerEnvironmentStatus.ERROR); + return new HostControllerEnvironmentWrapper(HostControllerEnvironmentWrapper.HostControllerEnvironmentStatus.ERROR, productConfig); } final Integer port = parsePort(val, CommandLineConstants.PROCESS_CONTROLLER_BIND_PORT); if (port == null) { - return new HostControllerEnvironmentWrapper(HostControllerEnvironmentWrapper.HostControllerEnvironmentStatus.ERROR); + return new HostControllerEnvironmentWrapper(HostControllerEnvironmentWrapper.HostControllerEnvironmentStatus.ERROR, productConfig); } pmPort = port; } else if (CommandLineConstants.PROCESS_CONTROLLER_BIND_ADDR.equals(arg)) { @@ -256,21 +256,21 @@ public static HostControllerEnvironmentWrapper determineEnvironment(String[] arg pmAddress = InetAddress.getByName(addr); } catch (UnknownHostException e) { STDERR.println(HostControllerLogger.ROOT_LOGGER.unknownHostValue(CommandLineConstants.PROCESS_CONTROLLER_BIND_ADDR, addr, usageNote())); - return new HostControllerEnvironmentWrapper(HostControllerEnvironmentWrapper.HostControllerEnvironmentStatus.ERROR); + return new HostControllerEnvironmentWrapper(HostControllerEnvironmentWrapper.HostControllerEnvironmentStatus.ERROR, productConfig); } } else if (arg.startsWith(CommandLineConstants.PROCESS_CONTROLLER_BIND_ADDR)) { final String val = parseValue(arg, CommandLineConstants.PROCESS_CONTROLLER_BIND_ADDR); if (val == null) { - return new HostControllerEnvironmentWrapper(HostControllerEnvironmentWrapper.HostControllerEnvironmentStatus.ERROR); + return new HostControllerEnvironmentWrapper(HostControllerEnvironmentWrapper.HostControllerEnvironmentStatus.ERROR, productConfig); } final InetAddress addr = parseAddress(val, arg); if (addr == null) { - return new HostControllerEnvironmentWrapper(HostControllerEnvironmentWrapper.HostControllerEnvironmentStatus.ERROR); + return new HostControllerEnvironmentWrapper(HostControllerEnvironmentWrapper.HostControllerEnvironmentStatus.ERROR, productConfig); } pmAddress = addr; } else if (pcSocketConfig.processPCSocketConfigArgument(arg, args, i)) { if (pcSocketConfig.isParseFailed()) { - return new HostControllerEnvironmentWrapper(HostControllerEnvironmentWrapper.HostControllerEnvironmentStatus.ERROR); + return new HostControllerEnvironmentWrapper(HostControllerEnvironmentWrapper.HostControllerEnvironmentStatus.ERROR, productConfig); } i += pcSocketConfig.getArgIncrement(); } else if (CommandLineConstants.RESTART_HOST_CONTROLLER.equals(arg)) { @@ -282,31 +282,31 @@ public static HostControllerEnvironmentWrapper determineEnvironment(String[] arg } else if(CommandLineConstants.DEFAULT_JVM.equals(arg) || CommandLineConstants.OLD_DEFAULT_JVM.equals(arg)) { defaultJVM = checkValueIsNotAnArg(arg, args[++i]); if (defaultJVM == null) { - return new HostControllerEnvironmentWrapper(HostControllerEnvironmentWrapper.HostControllerEnvironmentStatus.ERROR); + return new HostControllerEnvironmentWrapper(HostControllerEnvironmentWrapper.HostControllerEnvironmentStatus.ERROR, productConfig); } } else if (CommandLineConstants.DOMAIN_CONFIG.equals(arg) || CommandLineConstants.SHORT_DOMAIN_CONFIG.equals(arg) || CommandLineConstants.OLD_DOMAIN_CONFIG.equals(arg)) { domainConfig = checkValueIsNotAnArg(arg, args[++i]); if (domainConfig == null) { - return new HostControllerEnvironmentWrapper(HostControllerEnvironmentWrapper.HostControllerEnvironmentStatus.ERROR); + return new HostControllerEnvironmentWrapper(HostControllerEnvironmentWrapper.HostControllerEnvironmentStatus.ERROR, productConfig); } } else if (arg.startsWith(CommandLineConstants.DOMAIN_CONFIG)) { String val = parseValue(arg, CommandLineConstants.DOMAIN_CONFIG); if (val == null) { - return new HostControllerEnvironmentWrapper(HostControllerEnvironmentWrapper.HostControllerEnvironmentStatus.ERROR); + return new HostControllerEnvironmentWrapper(HostControllerEnvironmentWrapper.HostControllerEnvironmentStatus.ERROR, productConfig); } domainConfig = val; } else if (arg.startsWith(CommandLineConstants.SHORT_DOMAIN_CONFIG)) { String val = parseValue(arg, CommandLineConstants.SHORT_DOMAIN_CONFIG); if (val == null) { - return new HostControllerEnvironmentWrapper(HostControllerEnvironmentWrapper.HostControllerEnvironmentStatus.ERROR); + return new HostControllerEnvironmentWrapper(HostControllerEnvironmentWrapper.HostControllerEnvironmentStatus.ERROR, productConfig); } domainConfig = val; } else if (arg.startsWith(CommandLineConstants.OLD_DOMAIN_CONFIG)) { String val = parseValue(arg, CommandLineConstants.OLD_DOMAIN_CONFIG); if (val == null) { - return new HostControllerEnvironmentWrapper(HostControllerEnvironmentWrapper.HostControllerEnvironmentStatus.ERROR); + return new HostControllerEnvironmentWrapper(HostControllerEnvironmentWrapper.HostControllerEnvironmentStatus.ERROR, productConfig); } domainConfig = val; } else if (processType == ProcessType.EMBEDDED_HOST_CONTROLLER && arg.startsWith("--empty-host-config")) { @@ -326,41 +326,41 @@ public static HostControllerEnvironmentWrapper determineEnvironment(String[] arg initialDomainConfig = parseValue(arg, CommandLineConstants.READ_ONLY_DOMAIN_CONFIG); domainConfigInteractionPolicy = ConfigurationFile.InteractionPolicy.READ_ONLY; if (initialDomainConfig == null) { - return new HostControllerEnvironmentWrapper(HostControllerEnvironmentWrapper.HostControllerEnvironmentStatus.ERROR); + return new HostControllerEnvironmentWrapper(HostControllerEnvironmentWrapper.HostControllerEnvironmentStatus.ERROR, productConfig); } } else if (CommandLineConstants.HOST_CONFIG.equals(arg) || CommandLineConstants.OLD_HOST_CONFIG.equals(arg)) { hostConfig = checkValueIsNotAnArg(arg, args[++i]); if (hostConfig == null) { - return new HostControllerEnvironmentWrapper(HostControllerEnvironmentWrapper.HostControllerEnvironmentStatus.ERROR); + return new HostControllerEnvironmentWrapper(HostControllerEnvironmentWrapper.HostControllerEnvironmentStatus.ERROR, productConfig); } } else if (arg.startsWith(CommandLineConstants.HOST_CONFIG)) { String val = parseValue(arg, CommandLineConstants.HOST_CONFIG); if (val == null) { - return new HostControllerEnvironmentWrapper(HostControllerEnvironmentWrapper.HostControllerEnvironmentStatus.ERROR); + return new HostControllerEnvironmentWrapper(HostControllerEnvironmentWrapper.HostControllerEnvironmentStatus.ERROR, productConfig); } hostConfig = val; } else if (arg.startsWith(CommandLineConstants.OLD_HOST_CONFIG)) { String val = parseValue(arg, CommandLineConstants.OLD_HOST_CONFIG); if (val == null) { - return new HostControllerEnvironmentWrapper(HostControllerEnvironmentWrapper.HostControllerEnvironmentStatus.ERROR); + return new HostControllerEnvironmentWrapper(HostControllerEnvironmentWrapper.HostControllerEnvironmentStatus.ERROR, productConfig); } hostConfig = val; } else if (arg.startsWith(CommandLineConstants.READ_ONLY_HOST_CONFIG)) { initialHostConfig = parseValue(arg, CommandLineConstants.READ_ONLY_HOST_CONFIG); hostConfigInteractionPolicy = ConfigurationFile.InteractionPolicy.READ_ONLY; if (initialHostConfig == null) { - return new HostControllerEnvironmentWrapper(HostControllerEnvironmentWrapper.HostControllerEnvironmentStatus.ERROR); + return new HostControllerEnvironmentWrapper(HostControllerEnvironmentWrapper.HostControllerEnvironmentStatus.ERROR, productConfig); } } else if (arg.startsWith(CommandLineConstants.PRIMARY_ADDRESS)) { int idx = arg.indexOf('='); if (idx == arg.length() - 1) { STDERR.println(HostControllerLogger.ROOT_LOGGER.argumentExpected(arg, usageNote())); - return new HostControllerEnvironmentWrapper(HostControllerEnvironmentWrapper.HostControllerEnvironmentStatus.ERROR); + return new HostControllerEnvironmentWrapper(HostControllerEnvironmentWrapper.HostControllerEnvironmentStatus.ERROR, productConfig); } String value = idx > -1 ? arg.substring(idx + 1) : checkValueIsNotAnArg(arg, args[++i]); if (value == null) { - return new HostControllerEnvironmentWrapper(HostControllerEnvironmentWrapper.HostControllerEnvironmentStatus.ERROR); + return new HostControllerEnvironmentWrapper(HostControllerEnvironmentWrapper.HostControllerEnvironmentStatus.ERROR, productConfig); } value = fixPossibleIPv6URL(value); hostSystemProperties.put(HostControllerEnvironment.JBOSS_DOMAIN_PRIMARY_ADDRESS, value); @@ -370,12 +370,12 @@ public static HostControllerEnvironmentWrapper determineEnvironment(String[] arg int idx = arg.indexOf('='); if (idx == arg.length() - 1) { STDERR.println(HostControllerLogger.ROOT_LOGGER.argumentExpected(arg, usageNote())); - return new HostControllerEnvironmentWrapper(HostControllerEnvironmentWrapper.HostControllerEnvironmentStatus.ERROR); + return new HostControllerEnvironmentWrapper(HostControllerEnvironmentWrapper.HostControllerEnvironmentStatus.ERROR, productConfig); } String value = idx > -1 ? arg.substring(idx + 1) : args[++i]; final Integer port = parsePort(value, CommandLineConstants.PRIMARY_PORT); if (port == null) { - return new HostControllerEnvironmentWrapper(HostControllerEnvironmentWrapper.HostControllerEnvironmentStatus.ERROR); + return new HostControllerEnvironmentWrapper(HostControllerEnvironmentWrapper.HostControllerEnvironmentStatus.ERROR, productConfig); } hostSystemProperties.put(HostControllerEnvironment.JBOSS_DOMAIN_PRIMARY_PORT, value); @@ -404,11 +404,11 @@ public static HostControllerEnvironmentWrapper determineEnvironment(String[] arg int idx = arg.indexOf('='); if (idx == arg.length() - 1) { STDERR.println(HostControllerLogger.ROOT_LOGGER.argumentExpected(arg, usageNote())); - return new HostControllerEnvironmentWrapper(HostControllerEnvironmentWrapper.HostControllerEnvironmentStatus.ERROR); + return new HostControllerEnvironmentWrapper(HostControllerEnvironmentWrapper.HostControllerEnvironmentStatus.ERROR, productConfig); } String value = idx > -1 ? arg.substring(idx + 1) : checkValueIsNotAnArg(arg, args[++i]); if (value == null) { - return new HostControllerEnvironmentWrapper(HostControllerEnvironmentWrapper.HostControllerEnvironmentStatus.ERROR); + return new HostControllerEnvironmentWrapper(HostControllerEnvironmentWrapper.HostControllerEnvironmentStatus.ERROR, productConfig); } value = fixPossibleIPv6URL(value); String propertyName; @@ -429,11 +429,11 @@ public static HostControllerEnvironmentWrapper determineEnvironment(String[] arg int idx = arg.indexOf('='); if (idx == arg.length() - 1) { STDERR.println(HostControllerLogger.ROOT_LOGGER.argumentExpected(arg, usageNote())); - return new HostControllerEnvironmentWrapper(HostControllerEnvironmentWrapper.HostControllerEnvironmentStatus.ERROR); + return new HostControllerEnvironmentWrapper(HostControllerEnvironmentWrapper.HostControllerEnvironmentStatus.ERROR, productConfig); } String value = idx > -1 ? arg.substring(idx + 1) : checkValueIsNotAnArg(arg, args[++i]); if (value == null) { - return new HostControllerEnvironmentWrapper(HostControllerEnvironmentWrapper.HostControllerEnvironmentStatus.ERROR); + return new HostControllerEnvironmentWrapper(HostControllerEnvironmentWrapper.HostControllerEnvironmentStatus.ERROR, productConfig); } value = fixPossibleIPv6URL(value); hostSystemProperties.put(HostControllerEnvironment.JBOSS_DEFAULT_MULTICAST_ADDRESS, value); @@ -441,26 +441,27 @@ public static HostControllerEnvironmentWrapper determineEnvironment(String[] arg } else if (arg.equals(CommandLineConstants.MODULE_PATH)) { modulePath = checkValueIsNotAnArg(arg, args[++i]); if (modulePath == null) { - return new HostControllerEnvironmentWrapper(HostControllerEnvironmentWrapper.HostControllerEnvironmentStatus.ERROR); + return new HostControllerEnvironmentWrapper(HostControllerEnvironmentWrapper.HostControllerEnvironmentStatus.ERROR, productConfig); } } else if (arg.equals(CommandLineConstants.SECMGR)) { // Enable the security manager securityManagerEnabled = true; - } else if (arg.startsWith(CommandLineConstants.STABILITY)) { + } else if ((productConfig.getStabilitySet().size() > 1) && arg.startsWith(CommandLineConstants.STABILITY)) { String stabilityName = (arg.length() == CommandLineConstants.STABILITY.length()) ? args[++i] : parseValue(arg, CommandLineConstants.STABILITY); if (stabilityName == null) { - return new HostControllerEnvironmentWrapper(HostControllerEnvironmentWrapper.HostControllerEnvironmentStatus.ERROR); + return new HostControllerEnvironmentWrapper(HostControllerEnvironmentWrapper.HostControllerEnvironmentStatus.ERROR, productConfig); } hostSystemProperties.put(ProcessEnvironment.STABILITY, stabilityName); } else { STDERR.println(HostControllerLogger.ROOT_LOGGER.invalidOption(arg, usageNote())); - return new HostControllerEnvironmentWrapper(HostControllerEnvironmentWrapper.HostControllerEnvironmentStatus.ERROR); + return new HostControllerEnvironmentWrapper(HostControllerEnvironmentWrapper.HostControllerEnvironmentStatus.ERROR, productConfig); } } catch (IndexOutOfBoundsException e) { STDERR.println(HostControllerLogger.ROOT_LOGGER.argumentExpected(arg, usageNote())); - return new HostControllerEnvironmentWrapper(HostControllerEnvironmentWrapper.HostControllerEnvironmentStatus.ERROR); + return new HostControllerEnvironmentWrapper(HostControllerEnvironmentWrapper.HostControllerEnvironmentStatus.ERROR, productConfig); } } + // Recreate using system properties productConfig = ProductConfig.fromFilesystemSlot(Module.getBootModuleLoader(), WildFlySecurityManager.getPropertyPrivileged(HostControllerEnvironment.HOME_DIR, null), hostSystemProperties); return new HostControllerEnvironmentWrapper(new HostControllerEnvironment(hostSystemProperties, isRestart, modulePath, diff --git a/host-controller/src/main/java/org/jboss/as/host/controller/mgmt/HostInfo.java b/host-controller/src/main/java/org/jboss/as/host/controller/mgmt/HostInfo.java index d5bebf2bcca..430a61154bc 100644 --- a/host-controller/src/main/java/org/jboss/as/host/controller/mgmt/HostInfo.java +++ b/host-controller/src/main/java/org/jboss/as/host/controller/mgmt/HostInfo.java @@ -133,6 +133,7 @@ private HostInfo(final ModelNode hostInfo, DomainHostExcludeRegistry hostIgnoreR productVersion = hostInfo.hasDefined(PRODUCT_VERSION) ? hostInfo.require(PRODUCT_VERSION).asString() : null; remoteConnectionId = hostInfo.hasDefined(RemoteDomainConnectionService.DOMAIN_CONNECTION_ID) ? hostInfo.get(RemoteDomainConnectionService.DOMAIN_CONNECTION_ID).asLong() : null; + // Legacy hosts may return null - if so, assume default stability per our ProductConfig this.stability = Optional.ofNullable(hostInfo.get(ModelDescriptionConstants.STABILITY).asStringOrNull()).map(Stability::valueOf).orElse(productConfig.getDefaultStability()); Set domainIgnoredExtensions = null; diff --git a/process-controller/src/main/java/org/jboss/as/process/CommandLineArgumentUsageImpl.java b/process-controller/src/main/java/org/jboss/as/process/CommandLineArgumentUsageImpl.java index de1716bd919..759321e4c0c 100644 --- a/process-controller/src/main/java/org/jboss/as/process/CommandLineArgumentUsageImpl.java +++ b/process-controller/src/main/java/org/jboss/as/process/CommandLineArgumentUsageImpl.java @@ -6,14 +6,13 @@ package org.jboss.as.process; import java.io.PrintStream; -import java.util.EnumSet; import org.jboss.as.process.logging.ProcessLogger; -import org.jboss.as.version.Stability; +import org.jboss.as.version.ProductConfig; public class CommandLineArgumentUsageImpl extends CommandLineArgumentUsage { - public static void init(){ + public static void init(ProductConfig productConfig){ addArguments(CommandLineConstants.ADMIN_ONLY); instructions.add(ProcessLogger.ROOT_LOGGER.argAdminOnly()); @@ -81,12 +80,14 @@ public static void init(){ addArguments(CommandLineConstants.SECMGR); instructions.add(ProcessLogger.ROOT_LOGGER.argSecMgr()); - addArguments(CommandLineConstants.STABILITY + "="); - instructions.add(ProcessLogger.ROOT_LOGGER.argStability(EnumSet.allOf(Stability.class), Stability.DEFAULT)); + if (productConfig.getStabilitySet().size() > 1) { + addArguments(CommandLineConstants.STABILITY + "="); + instructions.add(ProcessLogger.ROOT_LOGGER.argStability(productConfig.getStabilitySet(), productConfig.getDefaultStability())); + } } - public static void printUsage(final PrintStream out) { - init(); + public static void printUsage(ProductConfig productConfig, PrintStream out) { + init(productConfig); out.print(usage("domain")); } } diff --git a/process-controller/src/main/java/org/jboss/as/process/Main.java b/process-controller/src/main/java/org/jboss/as/process/Main.java index c5288bc33ca..a275630abce 100644 --- a/process-controller/src/main/java/org/jboss/as/process/Main.java +++ b/process-controller/src/main/java/org/jboss/as/process/Main.java @@ -44,8 +44,8 @@ public static String getVersionString() { return Version.AS_VERSION; } - private static void usage() { - CommandLineArgumentUsageImpl.printUsage(System.out); + private static void usage(ProductConfig productConfig) { + CommandLineArgumentUsageImpl.printUsage(productConfig, System.out); } private Main() { @@ -68,8 +68,8 @@ public static ProcessController start(String[] args) throws IOException { String modulePath = null; String bootJar = null; String bootModule = HOST_CONTROLLER_MODULE; - final PCSocketConfig pcSocketConfig = new PCSocketConfig(); - + ProductConfig productConfig = ProductConfig.fromFilesystemSlot(Module.getBootModuleLoader(), jbossHome, null); + final PCSocketConfig pcSocketConfig = new PCSocketConfig(productConfig); String currentWorkingDir = WildFlySecurityManager.getPropertyPrivileged("user.dir", null); final List javaOptions = new ArrayList(); @@ -100,7 +100,7 @@ public static ProcessController start(String[] args) throws IOException { if ("--".equals(arg)) { for (i++; i < args.length; i++) { arg = args[i]; - if (handleHelpOrVersion(arg, jbossHome)) { + if (handleHelpOrVersion(productConfig, arg, jbossHome)) { return null; } else if (pcSocketConfig.processPCSocketConfigArgument(arg, args, i)) { if (pcSocketConfig.isParseFailed()) { @@ -109,12 +109,12 @@ public static ProcessController start(String[] args) throws IOException { i += pcSocketConfig.getArgIncrement(); } else if (arg.startsWith("-D" + CommandLineConstants.PREFER_IPV4_STACK + "=")) { // AS7-5409 set the property for this process and pass it to HC via javaOptions - String val = parseValue(arg, "-D" + CommandLineConstants.PREFER_IPV4_STACK); + String val = parseValue(productConfig, arg, "-D" + CommandLineConstants.PREFER_IPV4_STACK); WildFlySecurityManager.setPropertyPrivileged(CommandLineConstants.PREFER_IPV4_STACK, val); addJavaOption(arg, javaOptions); } else if (arg.startsWith("-D" + CommandLineConstants.PREFER_IPV6_ADDRESSES + "=")) { // AS7-5409 set the property for this process and pass it to HC via javaOptions - String val = parseValue(arg, "-D" + CommandLineConstants.PREFER_IPV6_ADDRESSES); + String val = parseValue(productConfig, arg, "-D" + CommandLineConstants.PREFER_IPV6_ADDRESSES); WildFlySecurityManager.setPropertyPrivileged(CommandLineConstants.PREFER_IPV6_ADDRESSES, val); addJavaOption(arg, javaOptions); @@ -123,7 +123,7 @@ public static ProcessController start(String[] args) throws IOException { } } break OUT; - } else if (handleHelpOrVersion(arg, jbossHome)) { + } else if (handleHelpOrVersion(productConfig, arg, jbossHome)) { // This would normally come in via the nested if ("--".equals(arg)) case above, but in case someone tweaks the // script to set it directly, we've handled it return null; @@ -145,7 +145,7 @@ public static ProcessController start(String[] args) throws IOException { } } break OUT; - } else if (handleHelpOrVersion(arg, jbossHome)) { + } else if (handleHelpOrVersion(productConfig, arg, jbossHome)) { // This would normally come in via the if ("--".equals(arg)) cases above, but in case someone tweaks the // script to set it directly, we've handled it) return null; @@ -249,12 +249,12 @@ private static boolean isJavaSecurityManagerConfigured(final String arg) { && !"-Djava.security.manager=disallow".equals(arg); } - private static String parseValue(final String arg, final String key) { + private static String parseValue(ProductConfig productConfig, final String arg, final String key) { String value = null; int splitPos = key.length(); if (arg.length() <= splitPos + 1 || arg.charAt(splitPos) != '=') { System.out.println(ProcessLogger.ROOT_LOGGER.noArgValue(key)); - usage(); + usage(productConfig); } else { value = arg.substring(splitPos + 1); } @@ -283,10 +283,10 @@ private static void addJavaOption(String option, List javaOptions) { javaOptions.add(option); } - private static boolean handleHelpOrVersion(String arg, String jbossHome) { + private static boolean handleHelpOrVersion(ProductConfig productConfig, String arg, String jbossHome) { if (CommandLineConstants.HELP.equals(arg) || CommandLineConstants.SHORT_HELP.equals(arg) || CommandLineConstants.OLD_HELP.equals(arg)) { - usage(); + usage(productConfig); return true; } else if (CommandLineConstants.VERSION.equals(arg) || CommandLineConstants.SHORT_VERSION.equals(arg) || CommandLineConstants.OLD_VERSION.equals(arg) || CommandLineConstants.OLD_SHORT_VERSION.equals(arg)) { @@ -297,12 +297,14 @@ private static boolean handleHelpOrVersion(String arg, String jbossHome) { } private static class PCSocketConfig { + private final ProductConfig productConfig; private String bindAddress; private int bindPort = 0; private int argIncrement = 0; private boolean parseFailed; - private PCSocketConfig() { + private PCSocketConfig(ProductConfig productConfig) { + this.productConfig = productConfig; } private String getBindAddress() { @@ -336,14 +338,14 @@ private boolean processPCSocketConfigArgument(final String arg, final String[] a bindAddress = args[index +1]; argIncrement = 1; } else if (arg.startsWith(CommandLineConstants.PROCESS_CONTROLLER_BIND_ADDR)) { - String addr = parseValue(arg, CommandLineConstants.PROCESS_CONTROLLER_BIND_ADDR); + String addr = parseValue(this.productConfig, arg, CommandLineConstants.PROCESS_CONTROLLER_BIND_ADDR); if (addr == null) { parseFailed = true; } else { bindAddress = addr; } } else if (arg.startsWith(CommandLineConstants.OLD_PROCESS_CONTROLLER_BIND_ADDR)) { - String addr = parseValue(arg, CommandLineConstants.OLD_PROCESS_CONTROLLER_BIND_ADDR); + String addr = parseValue(this.productConfig, arg, CommandLineConstants.OLD_PROCESS_CONTROLLER_BIND_ADDR); if (addr == null) { parseFailed = true; } else { @@ -353,14 +355,14 @@ private boolean processPCSocketConfigArgument(final String arg, final String[] a bindPort = Integer.parseInt(args[index + 1]); argIncrement = 1; } else if (arg.startsWith(CommandLineConstants.PROCESS_CONTROLLER_BIND_PORT)) { - String port = parseValue(arg, CommandLineConstants.PROCESS_CONTROLLER_BIND_PORT); + String port = parseValue(this.productConfig, arg, CommandLineConstants.PROCESS_CONTROLLER_BIND_PORT); if (port == null) { parseFailed = true; } else { bindPort = Integer.parseInt(port); } } else if (arg.startsWith(CommandLineConstants.OLD_PROCESS_CONTROLLER_BIND_PORT)) { - String port = parseValue(arg, CommandLineConstants.OLD_PROCESS_CONTROLLER_BIND_PORT); + String port = parseValue(this.productConfig, arg, CommandLineConstants.OLD_PROCESS_CONTROLLER_BIND_PORT); if (port == null) { parseFailed = true; } else { diff --git a/server/src/main/java/org/jboss/as/server/CommandLineArgumentUsageImpl.java b/server/src/main/java/org/jboss/as/server/CommandLineArgumentUsageImpl.java index f5d28c60c16..e9538ffb02c 100644 --- a/server/src/main/java/org/jboss/as/server/CommandLineArgumentUsageImpl.java +++ b/server/src/main/java/org/jboss/as/server/CommandLineArgumentUsageImpl.java @@ -6,18 +6,17 @@ package org.jboss.as.server; import java.io.PrintStream; -import java.util.EnumSet; import org.jboss.as.controller.persistence.ConfigurationExtensionFactory; import org.jboss.as.process.CommandLineArgumentUsage; import org.jboss.as.process.CommandLineConstants; import org.jboss.as.server.logging.ServerLogger; -import org.jboss.as.version.Stability; +import org.jboss.as.version.ProductConfig; public class CommandLineArgumentUsageImpl extends CommandLineArgumentUsage { - public static void init(){ + public static void init(ProductConfig productConfig){ addArguments(CommandLineConstants.ADMIN_ONLY); instructions.add(ServerLogger.ROOT_LOGGER.argAdminOnly()); @@ -81,12 +80,14 @@ public static void init(){ instructions.add(ConfigurationExtensionFactory.getCommandLineInstructions()); } - addArguments(CommandLineConstants.STABILITY + "="); - instructions.add(ServerLogger.ROOT_LOGGER.argStability(EnumSet.allOf(Stability.class), Stability.DEFAULT)); + if (productConfig.getStabilitySet().size() > 1) { + addArguments(CommandLineConstants.STABILITY + "="); + instructions.add(ServerLogger.ROOT_LOGGER.argStability(productConfig.getStabilitySet(), productConfig.getDefaultStability())); + } } - public static void printUsage(final PrintStream out) { - init(); + public static void printUsage(ProductConfig productConfig, PrintStream out) { + init(productConfig); out.print(usage("standalone")); } diff --git a/server/src/main/java/org/jboss/as/server/Main.java b/server/src/main/java/org/jboss/as/server/Main.java index fa390e3c83c..c072e76b014 100644 --- a/server/src/main/java/org/jboss/as/server/Main.java +++ b/server/src/main/java/org/jboss/as/server/Main.java @@ -46,8 +46,8 @@ public final class Main { private static final PrintStream STDOUT = System.out; private static final PrintStream STDERR = System.err; - private static void usage() { - CommandLineArgumentUsageImpl.printUsage(STDOUT); + private static void usage(ProductConfig productConfig) { + CommandLineArgumentUsageImpl.printUsage(productConfig, STDOUT); } private Main() { @@ -125,7 +125,7 @@ public static ServerEnvironmentWrapper determineEnvironment(String[] args, Prope String gitAuthConfiguration = null; String supplementalConfiguration = null; RunningMode runningMode = RunningMode.NORMAL; - ProductConfig productConfig; + ProductConfig productConfig = ProductConfig.fromFilesystemSlot(Module.getBootModuleLoader(), WildFlySecurityManager.getPropertyPrivileged(ServerEnvironment.HOME_DIR, null), null); ConfigurationFile.InteractionPolicy configInteractionPolicy = ConfigurationFile.InteractionPolicy.STANDARD; boolean startSuspended = false; boolean startGracefully = true; @@ -136,11 +136,10 @@ public static ServerEnvironmentWrapper determineEnvironment(String[] args, Prope try { if (CommandLineConstants.VERSION.equals(arg) || CommandLineConstants.SHORT_VERSION.equals(arg) || CommandLineConstants.OLD_VERSION.equals(arg) || CommandLineConstants.OLD_SHORT_VERSION.equals(arg)) { - productConfig = ProductConfig.fromFilesystemSlot(Module.getBootModuleLoader(), WildFlySecurityManager.getPropertyPrivileged(ServerEnvironment.HOME_DIR, null), null); STDOUT.println(productConfig.getPrettyVersionString()); return new ServerEnvironmentWrapper (ServerEnvironmentWrapper.ServerEnvironmentStatus.NORMAL); } else if (CommandLineConstants.HELP.equals(arg) || CommandLineConstants.SHORT_HELP.equals(arg) || CommandLineConstants.OLD_HELP.equals(arg)) { - usage(); + usage(productConfig); return new ServerEnvironmentWrapper (ServerEnvironmentWrapper.ServerEnvironmentStatus.NORMAL); } else if (CommandLineConstants.SERVER_CONFIG.equals(arg) || CommandLineConstants.SHORT_SERVER_CONFIG.equals(arg) || CommandLineConstants.OLD_SERVER_CONFIG.equals(arg)) { @@ -148,25 +147,25 @@ public static ServerEnvironmentWrapper determineEnvironment(String[] args, Prope serverConfig = args[++i]; } else if (arg.startsWith(CommandLineConstants.SERVER_CONFIG)) { assertSingleConfig(serverConfig); - serverConfig = parseValue(arg, CommandLineConstants.SERVER_CONFIG); + serverConfig = parseValue(productConfig, arg, CommandLineConstants.SERVER_CONFIG); if (serverConfig == null) { return new ServerEnvironmentWrapper (ServerEnvironmentWrapper.ServerEnvironmentStatus.ERROR); } } else if (arg.startsWith(CommandLineConstants.SHORT_SERVER_CONFIG)) { assertSingleConfig(serverConfig); - serverConfig = parseValue(arg, CommandLineConstants.SHORT_SERVER_CONFIG); + serverConfig = parseValue(productConfig, arg, CommandLineConstants.SHORT_SERVER_CONFIG); if (serverConfig == null) { return new ServerEnvironmentWrapper (ServerEnvironmentWrapper.ServerEnvironmentStatus.ERROR); } } else if (arg.startsWith(CommandLineConstants.READ_ONLY_SERVER_CONFIG)) { assertSingleConfig(serverConfig); - serverConfig = parseValue(arg, CommandLineConstants.READ_ONLY_SERVER_CONFIG); + serverConfig = parseValue(productConfig, arg, CommandLineConstants.READ_ONLY_SERVER_CONFIG); if (serverConfig == null) { return new ServerEnvironmentWrapper (ServerEnvironmentWrapper.ServerEnvironmentStatus.ERROR); } configInteractionPolicy = ConfigurationFile.InteractionPolicy.READ_ONLY; } else if (arg.startsWith(CommandLineConstants.OLD_SERVER_CONFIG)) { - serverConfig = parseValue(arg, CommandLineConstants.OLD_SERVER_CONFIG); + serverConfig = parseValue(productConfig, arg, CommandLineConstants.OLD_SERVER_CONFIG); if (serverConfig == null) { return new ServerEnvironmentWrapper (ServerEnvironmentWrapper.ServerEnvironmentStatus.ERROR); } @@ -182,22 +181,22 @@ public static ServerEnvironmentWrapper determineEnvironment(String[] args, Prope } else if (CommandLineConstants.PROPERTIES.equals(arg) || CommandLineConstants.OLD_PROPERTIES.equals(arg) || CommandLineConstants.SHORT_PROPERTIES.equals(arg)) { // Set system properties from url/file - if (!processProperties(arg, args[++i],systemProperties)) { + if (!processProperties(productConfig, arg, args[++i],systemProperties)) { return new ServerEnvironmentWrapper (ServerEnvironmentWrapper.ServerEnvironmentStatus.ERROR); } } else if (arg.startsWith(CommandLineConstants.PROPERTIES)) { - String urlSpec = parseValue(arg, CommandLineConstants.PROPERTIES); - if (urlSpec == null || !processProperties(arg, urlSpec,systemProperties)) { + String urlSpec = parseValue(productConfig, arg, CommandLineConstants.PROPERTIES); + if (urlSpec == null || !processProperties(productConfig, arg, urlSpec,systemProperties)) { return new ServerEnvironmentWrapper (ServerEnvironmentWrapper.ServerEnvironmentStatus.ERROR); } } else if (arg.startsWith(CommandLineConstants.SHORT_PROPERTIES)) { - String urlSpec = parseValue(arg, CommandLineConstants.SHORT_PROPERTIES); - if (urlSpec == null || !processProperties(arg, urlSpec,systemProperties)) { + String urlSpec = parseValue(productConfig, arg, CommandLineConstants.SHORT_PROPERTIES); + if (urlSpec == null || !processProperties(productConfig, arg, urlSpec,systemProperties)) { return new ServerEnvironmentWrapper (ServerEnvironmentWrapper.ServerEnvironmentStatus.ERROR); } } else if (arg.startsWith(CommandLineConstants.OLD_PROPERTIES)) { - String urlSpec = parseValue(arg, CommandLineConstants.OLD_PROPERTIES); - if (urlSpec == null || !processProperties(arg, urlSpec,systemProperties)) { + String urlSpec = parseValue(productConfig, arg, CommandLineConstants.OLD_PROPERTIES); + if (urlSpec == null || !processProperties(productConfig, arg, urlSpec,systemProperties)) { return new ServerEnvironmentWrapper (ServerEnvironmentWrapper.ServerEnvironmentStatus.ERROR); } } else if (arg.startsWith(CommandLineConstants.SYS_PROP)) { @@ -218,7 +217,7 @@ public static ServerEnvironmentWrapper determineEnvironment(String[] args, Prope int idx = arg.indexOf('='); if (idx == arg.length() - 1) { STDERR.println(ServerLogger.ROOT_LOGGER.noArgValue(arg)); - usage(); + usage(productConfig); return new ServerEnvironmentWrapper (ServerEnvironmentWrapper.ServerEnvironmentStatus.ERROR); } String value = idx > -1 ? arg.substring(idx + 1) : args[++i]; @@ -240,7 +239,7 @@ public static ServerEnvironmentWrapper determineEnvironment(String[] args, Prope int idx = arg.indexOf('='); if (idx == arg.length() - 1) { STDERR.println(ServerLogger.ROOT_LOGGER.valueExpectedForCommandLineOption(arg)); - usage(); + usage(productConfig); return new ServerEnvironmentWrapper (ServerEnvironmentWrapper.ServerEnvironmentStatus.ERROR); } String value = idx > -1 ? arg.substring(idx + 1) : args[++i]; @@ -250,7 +249,7 @@ public static ServerEnvironmentWrapper determineEnvironment(String[] args, Prope } else if (CommandLineConstants.ADMIN_ONLY.equals(arg)) { if(startModeSet) { STDERR.println(ServerLogger.ROOT_LOGGER.cannotSetBothAdminOnlyAndStartMode()); - usage(); + usage(productConfig); return new ServerEnvironmentWrapper (ServerEnvironmentWrapper.ServerEnvironmentStatus.ERROR); } startModeSet = true; @@ -259,18 +258,18 @@ public static ServerEnvironmentWrapper determineEnvironment(String[] args, Prope //Value can be a comma separated key value pair //Drop the first 2 characters String token = arg.substring(2); - processSecurityProperties(token,systemProperties); + processSecurityProperties(productConfig, token,systemProperties); } else if (arg.startsWith(CommandLineConstants.START_MODE)) { if (startModeSet) { STDERR.println(ServerLogger.ROOT_LOGGER.cannotSetBothAdminOnlyAndStartMode()); - usage(); + usage(productConfig); return new ServerEnvironmentWrapper(ServerEnvironmentWrapper.ServerEnvironmentStatus.ERROR); } startModeSet = true; int idx = arg.indexOf('='); if (idx == arg.length() - 1) { STDERR.println(ServerLogger.ROOT_LOGGER.noArgValue(arg)); - usage(); + usage(productConfig); return new ServerEnvironmentWrapper(ServerEnvironmentWrapper.ServerEnvironmentStatus.ERROR); } String value = idx > -1 ? arg.substring(idx + 1) : args[++i]; @@ -286,14 +285,14 @@ public static ServerEnvironmentWrapper determineEnvironment(String[] args, Prope break; default: STDERR.println(ServerLogger.ROOT_LOGGER.unknownStartMode(value)); - usage(); + usage(productConfig); return new ServerEnvironmentWrapper(ServerEnvironmentWrapper.ServerEnvironmentStatus.ERROR); } } else if (arg.startsWith(CommandLineConstants.GRACEFUL_STARTUP)) { int idx = arg.indexOf('='); if (idx == arg.length() - 1) { STDERR.println(ServerLogger.ROOT_LOGGER.noArgValue(arg)); - usage(); + usage(productConfig); return new ServerEnvironmentWrapper(ServerEnvironmentWrapper.ServerEnvironmentStatus.ERROR); } String value = (idx > -1 ? arg.substring(idx + 1) : args[++i]) @@ -304,7 +303,7 @@ public static ServerEnvironmentWrapper determineEnvironment(String[] args, Prope startGracefully = false; } else { STDERR.println(ServerLogger.ROOT_LOGGER.invalidCommandLineOption(arg)); - usage(); + usage(productConfig); return new ServerEnvironmentWrapper(ServerEnvironmentWrapper.ServerEnvironmentStatus.ERROR); } } else if (arg.equals(CommandLineConstants.DEBUG)) { // Need to process the debug options as they cannot be filtered out in Windows @@ -331,7 +330,7 @@ public static ServerEnvironmentWrapper determineEnvironment(String[] args, Prope i++; } else { STDERR.println(ServerLogger.ROOT_LOGGER.valueExpectedForCommandLineOption(arg)); - usage(); + usage(productConfig); return new ServerEnvironmentWrapper (ServerEnvironmentWrapper.ServerEnvironmentStatus.ERROR); } } else { @@ -346,7 +345,7 @@ public static ServerEnvironmentWrapper determineEnvironment(String[] args, Prope i++; } else { STDERR.println(ServerLogger.ROOT_LOGGER.valueExpectedForCommandLineOption(arg)); - usage(); + usage(productConfig); return new ServerEnvironmentWrapper (ServerEnvironmentWrapper.ServerEnvironmentStatus.ERROR); } } else { @@ -361,14 +360,14 @@ public static ServerEnvironmentWrapper determineEnvironment(String[] args, Prope i++; } else { STDERR.println(ServerLogger.ROOT_LOGGER.valueExpectedForCommandLineOption(arg)); - usage(); + usage(productConfig); return new ServerEnvironmentWrapper (ServerEnvironmentWrapper.ServerEnvironmentStatus.ERROR); } } else { gitBranch = arg.substring(idx + 1); } - } else if (arg.startsWith(CommandLineConstants.STABILITY)) { - String stability = (arg.length() == CommandLineConstants.STABILITY.length()) ? args[++i] : parseValue(arg, CommandLineConstants.STABILITY); + } else if ((productConfig.getStabilitySet().size() > 1) && arg.startsWith(CommandLineConstants.STABILITY)) { + String stability = (arg.length() == CommandLineConstants.STABILITY.length()) ? args[++i] : parseValue(productConfig, arg, CommandLineConstants.STABILITY); if (stability == null) { return new ServerEnvironmentWrapper(ServerEnvironmentWrapper.ServerEnvironmentStatus.ERROR); } @@ -383,7 +382,7 @@ public static ServerEnvironmentWrapper determineEnvironment(String[] args, Prope i++; } else { STDERR.println(ServerLogger.ROOT_LOGGER.valueExpectedForCommandLineOption(arg)); - usage(); + usage(productConfig); return new ServerEnvironmentWrapper (ServerEnvironmentWrapper.ServerEnvironmentStatus.ERROR); } } else { @@ -391,17 +390,18 @@ public static ServerEnvironmentWrapper determineEnvironment(String[] args, Prope } } else { STDERR.println(ServerLogger.ROOT_LOGGER.invalidCommandLineOption(arg)); - usage(); + usage(productConfig); return new ServerEnvironmentWrapper (ServerEnvironmentWrapper.ServerEnvironmentStatus.ERROR); } } catch (IndexOutOfBoundsException e) { STDERR.println(ServerLogger.ROOT_LOGGER.valueExpectedForCommandLineOption(arg)); - usage(); + usage(productConfig); return new ServerEnvironmentWrapper(ServerEnvironmentWrapper.ServerEnvironmentStatus.ERROR); } } String hostControllerName = null; // No host controller unless in domain mode. + // Re-create using updated properties productConfig = ProductConfig.fromFilesystemSlot(Module.getBootModuleLoader(), WildFlySecurityManager.getPropertyPrivileged(ServerEnvironment.HOME_DIR, null), systemProperties); return new ServerEnvironmentWrapper(new ServerEnvironment(hostControllerName, systemProperties, systemEnvironment, serverConfig, configInteractionPolicy, launchType, runningMode, productConfig, startTime, startSuspended, @@ -414,11 +414,11 @@ private static void assertSingleConfig(String serverConfig) { } } - private static String parseValue(final String arg, final String key) { + private static String parseValue(ProductConfig productConfig, final String arg, final String key) { String value = null; int splitPos = key.length(); if (arg.length() <= splitPos + 1 || arg.charAt(splitPos) != '=') { - usage(); + usage(productConfig); } else { value = arg.substring(splitPos + 1); } @@ -435,7 +435,7 @@ private static String fixPossibleIPv6URL(String val) { return result; } - private static boolean processProperties(final String arg, final String urlSpec, Properties systemProperties) { + private static boolean processProperties(ProductConfig productConfig, final String arg, final String urlSpec, Properties systemProperties) { URL url = null; try { url = makeURL(urlSpec); @@ -443,11 +443,11 @@ private static boolean processProperties(final String arg, final String urlSpec, return true; } catch (MalformedURLException e) { STDERR.println(ServerLogger.ROOT_LOGGER.malformedCommandLineURL(urlSpec, arg)); - usage(); + usage(productConfig); return false; } catch (IOException e) { STDERR.println(ServerLogger.ROOT_LOGGER.unableToLoadProperties(url)); - usage(); + usage(productConfig); return false; } } @@ -477,7 +477,7 @@ private static URL makeURL(String urlspec) throws MalformedURLException { return url; } - private static void processSecurityProperties(String secProperties, Properties systemProperties){ + private static void processSecurityProperties(ProductConfig productConfig, String secProperties, Properties systemProperties){ StringTokenizer tokens = new StringTokenizer(secProperties, ","); while(tokens.hasMoreTokens()){ String token = tokens.nextToken(); @@ -485,7 +485,7 @@ private static void processSecurityProperties(String secProperties, Properties s int idx = token.indexOf('='); if (idx == token.length() - 1) { STDERR.println(ServerLogger.ROOT_LOGGER.valueExpectedForCommandLineOption(secProperties)); - usage(); + usage(productConfig); return; } String value = token.substring(idx + 1); 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 9d98e8d2954..40019885b5e 100644 --- a/server/src/main/java/org/jboss/as/server/ServerEnvironment.java +++ b/server/src/main/java/org/jboss/as/server/ServerEnvironment.java @@ -523,7 +523,7 @@ public ServerEnvironment(final String hostControllerName, final Properties props } this.stability = getEnumProperty(props, ProcessEnvironment.STABILITY, productConfig.getDefaultStability()); - if (!productConfig.getMinimumStability().enables(this.stability)) { + if (!productConfig.getStabilitySet().contains(this.stability)) { throw ServerLogger.ROOT_LOGGER.unsupportedStability(this.stability, productConfig.getProductName()); } } diff --git a/version/src/main/java/org/jboss/as/version/ProductConfig.java b/version/src/main/java/org/jboss/as/version/ProductConfig.java index 49e08384e0a..ec491412644 100644 --- a/version/src/main/java/org/jboss/as/version/ProductConfig.java +++ b/version/src/main/java/org/jboss/as/version/ProductConfig.java @@ -15,8 +15,10 @@ import java.nio.file.Paths; import java.security.AccessController; import java.security.PrivilegedAction; +import java.util.EnumSet; import java.util.Map; import java.util.Properties; +import java.util.Set; import java.util.jar.Manifest; import org.jboss.modules.Module; @@ -34,7 +36,7 @@ public class ProductConfig implements Serializable { private final String version; private final String consoleSlot; private final Stability defaultStability; - private final Stability minStability; + private final Set stabilities; private boolean isProduct; public static ProductConfig fromFilesystemSlot(ModuleLoader loader, String home, Map providedProperties) { @@ -51,6 +53,7 @@ private ProductConfig(ModuleLoader loader, ProductConfProps productConfProps, Ma String consoleSlot = null; Stability defaultStability = Stability.COMMUNITY; Stability minStability = Stability.EXPERIMENTAL; + Stability maxStability = Stability.DEFAULT; InputStream manifestStream = null; try { @@ -91,7 +94,7 @@ private ProductConfig(ModuleLoader loader, ProductConfProps productConfProps, Ma version = productVersion; this.consoleSlot = consoleSlot; this.defaultStability = defaultStability; - this.minStability = minStability; + this.stabilities = EnumSet.range(maxStability, minStability); } private static String getProductConf(String home) { @@ -129,7 +132,7 @@ public ProductConfig(final String productName, final String productVersion, fina this.version = productVersion; this.consoleSlot = consoleSlot; this.defaultStability = Stability.DEFAULT; - this.minStability = Stability.DEFAULT; + this.stabilities = EnumSet.of(this.defaultStability); } public String getProductName() { @@ -148,12 +151,20 @@ public String getConsoleSlot() { return consoleSlot; } + /** + * Returns the presumed stability level of this product. + * @return a stability level + */ public Stability getDefaultStability() { return this.defaultStability; } - public Stability getMinimumStability() { - return this.minStability; + /** + * Returns the set of permissible stability levels for this product. + * @return a set of stability levels + */ + public Set getStabilitySet() { + return this.stabilities; } public String getPrettyVersionString() {