try {
Module.registerURLStreamHandlerFactoryModule(Module.getBootModuleLoader().loadModule(ModuleIdentifier.create("org.jboss.vfs")));
final ParsedOptions options = determineEnvironment(args, new Properties(SecurityActions.getSystemProperties()), SecurityActions.getSystemEnvironment(), ServerEnvironment.LaunchType.APPCLIENT);
ServerEnvironment serverEnvironment = options.environment;
final List<String> clientArgs = options.clientArguments;
if (clientArgs.isEmpty()) {
System.err.println(MESSAGES.appClientNotSpecified());
usage();
abort(null);
} else {
final QName rootElement = new QName(Namespace.CURRENT.getUriString(), "server");
final String file = clientArgs.get(0);
final List<String> params = clientArgs.subList(1, clientArgs.size());
final String deploymentName;
final String earPath;
int pos = file.lastIndexOf("#");
if (pos == -1) {
earPath = file;
deploymentName = null;
} else {
deploymentName = file.substring(pos + 1);
earPath = file.substring(0, pos);
}
File realFile = new File(earPath);
if (!realFile.exists()) {
throw MESSAGES.cannotFindAppClientFile(realFile.getAbsoluteFile());
}
final Bootstrap bootstrap = Bootstrap.Factory.newInstance();
final Bootstrap.Configuration configuration = new Bootstrap.Configuration(serverEnvironment);
configuration.setModuleLoader(Module.getBootModuleLoader());
final ExtensionRegistry extensionRegistry = configuration.getExtensionRegistry();
final AppClientXml parser = new AppClientXml(Module.getBootModuleLoader(), extensionRegistry);
final Bootstrap.ConfigurationPersisterFactory configurationPersisterFactory = new Bootstrap.ConfigurationPersisterFactory() {
@Override
public ExtensibleConfigurationPersister createConfigurationPersister(ServerEnvironment serverEnvironment, ExecutorService executorService) {
ApplicationClientConfigurationPersister persister = new ApplicationClientConfigurationPersister(earPath, deploymentName, options.hostUrl,options.propertiesFile, params,
serverEnvironment.getServerConfigurationFile().getBootFile(), rootElement, parser);
for (Namespace namespace : Namespace.values()) {
if (!namespace.equals(Namespace.CURRENT)) {
persister.registerAdditionalRootElement(new QName(namespace.getUriString(), "server"), parser);
}
}