public static HostController createHostController(final Configuration configuration) {
        final ChainedContext context = new ChainedContext();
        context.add(new HostControllerSystemPropertyContext(configuration.getJBossHome()));
        context.add(new LoggerContext(configuration.getModuleLoader()));
        final ModuleLoader moduleLoader = configuration.getModuleLoader();

        setupVfsModule(moduleLoader);

        // Load the Embedded Server Module
        final Module embeddedModule;
        try {
            embeddedModule = moduleLoader.loadModule(MODULE_ID_EMBEDDED);
        } catch (final ModuleLoadException mle) {
            throw EmbeddedLogger.ROOT_LOGGER.moduleLoaderError(mle, MODULE_ID_EMBEDDED, moduleLoader);
        }

        // Load the Embedded Server Factory via the modular environment
        final ModuleClassLoader embeddedModuleCL = embeddedModule.getClassLoader();
        final Class<?> embeddedHostControllerFactoryClass;
        final Class<?> hostControllerClass;
        try {
            embeddedHostControllerFactoryClass = embeddedModuleCL.loadClass(HOST_FACTORY);
            hostControllerClass = embeddedModuleCL.loadClass(HostController.class.getName());
        } catch (final ClassNotFoundException cnfe) {
            throw EmbeddedLogger.ROOT_LOGGER.cannotLoadEmbeddedServerFactory(cnfe, HOST_FACTORY);
        }

        // Get a handle to the method which will create the server
        boolean useClMethod = true;
        Method createServerMethod;
        try {
            createServerMethod = embeddedHostControllerFactoryClass.getMethod("create", File.class, ModuleLoader.class, Properties.class, Map.class, String[].class, ClassLoader.class);
        } catch (final NoSuchMethodException nsme) {
            useClMethod = false;
            try {
                // Check if we're using a version of WildFly Core before 6.0 which did not include the create method that accepts a class loader
                createServerMethod = embeddedHostControllerFactoryClass.getMethod("create", File.class, ModuleLoader.class, Properties.class, Map.class, String[].class);
            } catch (final NoSuchMethodException e) {
                throw EmbeddedLogger.ROOT_LOGGER.cannotGetReflectiveMethod(e, "create", embeddedHostControllerFactoryClass.getName());
            }
        }

        // Create the server
        Object hostControllerImpl = createManagedProcess(ProcessType.HOST_CONTROLLER, createServerMethod, configuration, useClMethod ? embeddedModuleCL : null);
        return new EmbeddedManagedProcessImpl(hostControllerClass, hostControllerImpl, context);
    }
public static HostController createHostController ( final Configuration configuration ) { final ChainedContext context = new ChainedContext ( ) ; context . add ( new HostControllerSystemPropertyContext ( configuration . getJBossHome ( ) ) ) ; context . add ( new LoggerContext ( configuration . getModuleLoader ( ) ) ) ; final ModuleLoader moduleLoader = configuration . getModuleLoader ( ) ; setupVfsModule ( moduleLoader ) ; final Module embeddedModule ; try { embeddedModule = moduleLoader . loadModule ( MODULE_ID_EMBEDDED ) ; } catch ( final ModuleLoadException mle ) { throw EmbeddedLogger . ROOT_LOGGER . moduleLoaderError ( mle , MODULE_ID_EMBEDDED , moduleLoader ) ; } final ModuleClassLoader embeddedModuleCL = embeddedModule . getClassLoader ( ) ; final Class < ? > embeddedHostControllerFactoryClass ; final Class < ? > hostControllerClass ; try { embeddedHostControllerFactoryClass = embeddedModuleCL . loadClass ( HOST_FACTORY ) ; hostControllerClass = embeddedModuleCL . loadClass ( HostController . class . getName ( ) ) ; } catch ( final ClassNotFoundException cnfe ) { throw EmbeddedLogger . ROOT_LOGGER . cannotLoadEmbeddedServerFactory ( cnfe , HOST_FACTORY ) ; } boolean useClMethod = true ; Method createServerMethod ; try { createServerMethod = embeddedHostControllerFactoryClass . getMethod ( "create" , File . class , ModuleLoader . class , Properties . class , Map . class , String [ ] . class , ClassLoader . class ) ; } catch ( final NoSuchMethodException nsme ) { useClMethod = false ; try { createServerMethod = embeddedHostControllerFactoryClass . getMethod ( "create" , File . class , ModuleLoader . class , Properties . class , Map . class , String [ ] . class ) ; } catch ( final NoSuchMethodException e ) { throw EmbeddedLogger . ROOT_LOGGER . cannotGetReflectiveMethod ( e , "create" , embeddedHostControllerFactoryClass . getName ( ) ) ; } } Object hostControllerImpl = createManagedProcess ( ProcessType . HOST_CONTROLLER , createServerMethod , configuration , useClMethod ? embeddedModuleCL : null ) ; return new EmbeddedManagedProcessImpl ( hostControllerClass , hostControllerImpl , context ) ; }
Create an embedded host controller with an already established module loader.

@param configuration the configuration for the embedded host controller
@return the running host controller Will not be {@code null}