// Load the server Module and get its ClassLoader
final ModuleIdentifier serverModuleId = ModuleIdentifier.create("org.jboss.as.server");
final Module serverModule = moduleLoader.loadModule(serverModuleId);
final ModuleClassLoader serverModuleClassLoader = serverModule.getClassLoader();
Class<?> embeddedStandAloneServerFactoryClass = serverModuleClassLoader.loadClass("org.jboss.as.server.EmbeddedStandAloneServerFactory");
Method createMethod = embeddedStandAloneServerFactoryClass.getMethod("create", File.class, ModuleLoader.class, Properties.class, Map.class);
final StandaloneServer standaloneServer = (StandaloneServer) createMethod.invoke(null, jbossHomeDir, moduleLoader, systemProps, systemEnv);
return standaloneServer;
} catch (ModuleLoadException e) {
throw MESSAGES.moduleLoaderError(e, e.getMessage(), moduleLoader);