Java Code Examples for org.jboss.modules.Module#loadService()

The following examples show how to use org.jboss.modules.Module#loadService() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Swarm.java    From ARCHIVE-wildfly-swarm with Apache License 2.0 6 votes vote down vote up
/**
 * Main entry-point.
 *
 * @param args Ignored.
 * @throws Exception if an error occurs.
 */
public static void main(String... args) throws Exception {
    if (System.getProperty("boot.module.loader") == null) {
        System.setProperty("boot.module.loader", "org.wildfly.swarm.bootstrap.modules.BootModuleLoader");
    }
    Module bootstrap = Module.getBootModuleLoader().loadModule(ModuleIdentifier.create("swarm.application"));

    ServiceLoader<ContainerFactory> factory = bootstrap.loadService(ContainerFactory.class);
    Iterator<ContainerFactory> factoryIter = factory.iterator();

    if (!factoryIter.hasNext()) {
        simpleMain(args);
    } else {
        factoryMain(factoryIter.next(), args);
    }
}
 
Example 2
Source File: ContainerOnlySwarm.java    From ARCHIVE-wildfly-swarm with Apache License 2.0 6 votes vote down vote up
/**
 * Main entry-point.
 *
 * @param args Ignored.
 * @throws Exception if an error occurs.
 */
public static void main(String... args) throws Exception {
    if (System.getProperty("boot.module.loader") == null) {
        System.setProperty("boot.module.loader", "org.wildfly.swarm.bootstrap.modules.BootModuleLoader");
    }
    Module bootstrap = Module.getBootModuleLoader().loadModule(ModuleIdentifier.create("swarm.application"));

    ServiceLoader<ContainerFactory> factory = bootstrap.loadService(ContainerFactory.class);
    Iterator<ContainerFactory> factoryIter = factory.iterator();

    if (!factoryIter.hasNext()) {
        simpleMain(args);
    } else {
        factoryMain(factoryIter.next(), args);
    }
}
 
Example 3
Source File: DeferredExtensionContext.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
private XMLStreamException loadModule(final String moduleName, final XMLMapper xmlMapper) throws XMLStreamException {
    // Register element handlers for this extension
    try {
        final Module module = moduleLoader.loadModule(ModuleIdentifier.fromString(moduleName));
        boolean initialized = false;
        for (final Extension extension : module.loadService(Extension.class)) {
            ClassLoader oldTccl = WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(extension.getClass());
            try {
                extensionRegistry.initializeParsers(extension, moduleName, xmlMapper);
            } finally {
                WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(oldTccl);
            }
            if (!initialized) {
                initialized = true;
            }
        }
        if (!initialized) {
            throw ControllerLogger.ROOT_LOGGER.notFound("META-INF/services/", Extension.class.getName(), module.getName());
        }
        return null;
    } catch (final ModuleLoadException e) {
        throw ControllerLogger.ROOT_LOGGER.failedToLoadModule(e);
    }
}