Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WFLY-17973] Clean up appclient Main #16796

Merged
merged 1 commit into from
Apr 30, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
29 changes: 12 additions & 17 deletions appclient/src/main/java/org/jboss/as/appclient/subsystem/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@
import org.jboss.as.server.SystemExiter;
import org.jboss.as.version.ProductConfig;
import org.jboss.modules.Module;
import org.jboss.modules.ModuleIdentifier;
import org.jboss.msc.service.ServiceActivator;
import org.jboss.stdio.LoggingOutputStream;
import org.jboss.stdio.NullInputStream;
import org.jboss.stdio.SimpleStdioContextSelector;
Expand Down Expand Up @@ -97,7 +95,7 @@ public static void main(String[] args) {
}

try {
Module.registerURLStreamHandlerFactoryModule(Module.getBootModuleLoader().loadModule(ModuleIdentifier.create("org.jboss.vfs")));
Module.registerURLStreamHandlerFactoryModule(Module.getBootModuleLoader().loadModule("org.jboss.vfs"));

final ParsedOptions options = determineEnvironment(args, new Properties(WildFlySecurityManager.getSystemPropertiesPrivileged()), WildFlySecurityManager.getSystemEnvironmentPrivileged(), ServerEnvironment.LaunchType.APPCLIENT);
if(options == null) {
Expand Down Expand Up @@ -149,7 +147,7 @@ public ExtensibleConfigurationPersister createConfigurationPersister(ServerEnvir
}
};
configuration.setConfigurationPersisterFactory(configurationPersisterFactory);
bootstrap.bootstrap(configuration, Collections.<ServiceActivator>emptyList()).get();
bootstrap.bootstrap(configuration, Collections.emptyList()).get();
}
} catch (Throwable t) {
abort(t);
Expand All @@ -167,7 +165,7 @@ private static void abort(Throwable t) {
}

public static ParsedOptions determineEnvironment(String[] args, Properties systemProperties, Map<String, String> systemEnvironment, ServerEnvironment.LaunchType launchType) {
List<String> clientArguments = new ArrayList<String>();
List<String> clientArguments = new ArrayList<>();
ParsedOptions ret = new ParsedOptions();
ret.clientArguments = clientArguments;
final int argsLength = args.length;
Expand All @@ -184,7 +182,7 @@ public static ParsedOptions determineEnvironment(String[] args, Properties syste
clientArguments.add(arg);
} else if (CommandLineConstants.VERSION.equals(arg) || CommandLineConstants.SHORT_VERSION.equals(arg)
|| CommandLineConstants.OLD_VERSION.equals(arg) || CommandLineConstants.OLD_SHORT_VERSION.equals(arg)) {
productConfig = new ProductConfig(Module.getBootModuleLoader(), WildFlySecurityManager.getPropertyPrivileged(ServerEnvironment.HOME_DIR, null), null);
productConfig = ProductConfig.fromFilesystemSlot(Module.getBootModuleLoader(), WildFlySecurityManager.getPropertyPrivileged(ServerEnvironment.HOME_DIR, null), null);
STDOUT.println(productConfig.getPrettyVersionString());
return null;
} else if (CommandLineConstants.HELP.equals(arg) || CommandLineConstants.SHORT_HELP.equals(arg) || CommandLineConstants.OLD_HELP.equals(arg)) {
Expand Down Expand Up @@ -216,28 +214,24 @@ public static ParsedOptions determineEnvironment(String[] args, Properties syste
throw AppClientLogger.ROOT_LOGGER.cannotSpecifyBothHostAndPropertiesFile();
}
hostSet = true;
String urlSpec = args[++i];
ret.hostUrl = urlSpec;
ret.hostUrl = args[++i];
} else if (arg.startsWith(CommandLineConstants.SHORT_HOST)) {
if(ret.propertiesFile != null) {
throw AppClientLogger.ROOT_LOGGER.cannotSpecifyBothHostAndPropertiesFile();
}
hostSet = true;
String urlSpec = parseValue(arg, CommandLineConstants.SHORT_HOST);
ret.hostUrl = urlSpec;
ret.hostUrl = parseValue(arg, CommandLineConstants.SHORT_HOST);
} else if (arg.startsWith(CommandLineConstants.HOST)) {
if(ret.propertiesFile != null) {
throw AppClientLogger.ROOT_LOGGER.cannotSpecifyBothHostAndPropertiesFile();
}
hostSet = true;
String urlSpec = parseValue(arg, CommandLineConstants.HOST);
ret.hostUrl = urlSpec;
ret.hostUrl = parseValue(arg, CommandLineConstants.HOST);
} else if (arg.startsWith(CommandLineConstants.CONNECTION_PROPERTIES)) {
if(hostSet) {
throw AppClientLogger.ROOT_LOGGER.cannotSpecifyBothHostAndPropertiesFile();
}
String fileUrl = parseValue(arg, CommandLineConstants.CONNECTION_PROPERTIES);
ret.propertiesFile = fileUrl;
ret.propertiesFile = parseValue(arg, CommandLineConstants.CONNECTION_PROPERTIES);
} else if (arg.startsWith(CommandLineConstants.SYS_PROP)) {
// set a system property
String name, value;
Expand Down Expand Up @@ -269,7 +263,7 @@ public static ParsedOptions determineEnvironment(String[] args, Properties syste
return null;
}
} else {
yamlFile = arg.substring(idx + 1, arg.length());
yamlFile = arg.substring(idx + 1);
}
} else {
if (arg.startsWith("-")) {
Expand All @@ -289,9 +283,9 @@ public static ParsedOptions determineEnvironment(String[] args, Properties syste
}

String hostControllerName = null; // No host controller unless in domain mode.
productConfig = new ProductConfig(Module.getBootModuleLoader(), WildFlySecurityManager.getPropertyPrivileged(ServerEnvironment.HOME_DIR, null), systemProperties);
productConfig = ProductConfig.fromFilesystemSlot(Module.getBootModuleLoader(), WildFlySecurityManager.getPropertyPrivileged(ServerEnvironment.HOME_DIR, null), systemProperties);
ret.environment = new ServerEnvironment(hostControllerName, systemProperties, systemEnvironment, appClientConfig, null, launchType, null, productConfig,
System.currentTimeMillis(), false, null, null, null, yamlFile);
System.currentTimeMillis(), false, false,null, null, null, yamlFile);
return ret;
}

Expand All @@ -306,6 +300,7 @@ private static String parseValue(final String arg, final String key) {
return value;
}

@SuppressWarnings("BooleanMethodIsAlwaysInverted")
private static boolean processProperties(final String arg, final String urlSpec) {
URL url = null;
try {
Expand Down