org.jboss.modules.Module Java Examples

The following examples show how to use org.jboss.modules.Module. 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: DriverDependenciesProcessor.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Override
public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    final ModuleSpecification moduleSpecification = deploymentUnit.getAttachment(Attachments.MODULE_SPECIFICATION);
    final ModuleLoader moduleLoader = Module.getBootModuleLoader();
    if (deploymentUnit.hasAttachment(Attachments.RESOURCE_ROOTS)) {
        final List<ResourceRoot> resourceRoots = deploymentUnit.getAttachmentList(Attachments.RESOURCE_ROOTS);
        for (ResourceRoot root : resourceRoots) {
            VirtualFile child = root.getRoot().getChild(SERVICE_FILE_NAME);
            if (child.exists()) {
                moduleSpecification.addSystemDependency(new ModuleDependency(moduleLoader, JTA, false, false, false, false));
                break;
            }
        }
    }
}
 
Example #2
Source File: ModuleInfoHandler.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Override
public void execute(OperationContext context, ModelNode operation) throws OperationFailedException {
    ModelNode model = new ModelNode();
    populateModel(operation, model);
    String moduleName = MODULE_NAME.resolveModelAttribute(context, model).asString();
    String slot = MODULE_SLOT.resolveModelAttribute(context, model).asString();
    ModuleIdentifier id = ModuleIdentifier.create(moduleName, slot);
    ModuleLoader loader = Module.getBootModuleLoader();
    try {
        ModuleLoaderMXBean mxBean = getMxBean(loader);
        ModuleInfo moduleInfo = mxBean.getModuleDescription(id.toString());
        context.getResult().set(populateModuleInfo(moduleInfo));
    } catch (Exception e) {
        throw ServerLogger.ROOT_LOGGER.couldNotGetModuleInfo(id.toString(), e);
    }
}
 
Example #3
Source File: Swarm.java    From thorntail with Apache License 2.0 6 votes vote down vote up
/**
 * Stop the container, first undeploying all deployments.
 *
 * @return THe container.
 * @throws Exception If an error occurs.
 */
public Swarm stop() throws Exception {

    if (this.server == null) {
        throw SwarmMessages.MESSAGES.containerNotStarted("stop()");
    }

    this.server.stop();
    this.server = null;

    Module module = Module.getBootModuleLoader().loadModule(CONTAINER_MODULE_NAME);
    Class<?> shutdownClass = module.getClassLoader().loadClass("org.wildfly.swarm.container.runtime.WeldShutdownImpl");

    WeldShutdown shutdown = (WeldShutdown) shutdownClass.newInstance();
    shutdown.shutdown();

    return this;
}
 
Example #4
Source File: KeycloakMicroprofileJwtArchivePreparer.java    From thorntail with Apache License 2.0 6 votes vote down vote up
@Override
public void process() throws IOException {
    InputStream keycloakJsonStream = getKeycloakJsonFromClasspath("keycloak.json");
    if (keycloakJsonStream == null) {
        keycloakJsonStream = getKeycloakJsonFromSystemProperties();
    }
    if (keycloakJsonStream != null) {
        try {
            Module module = Module.getBootModuleLoader().loadModule("org.wildfly.swarm.keycloak.mpjwt:deployment");
            Class<?> use = module.getClassLoader()
                .loadClass("org.wildfly.swarm.keycloak.mpjwt.deployment.KeycloakJWTCallerPrincipalFactory");
            Method m = use.getDeclaredMethod("createDeploymentFromStream", InputStream.class);
            m.invoke(null, keycloakJsonStream);
        } catch (Throwable ex) {
            log.warn("keycloak.json resource is not available", ex);
        }
    }
}
 
Example #5
Source File: Main.java    From thorntail with Apache License 2.0 6 votes vote down vote up
public static void main(String... args) throws Exception {
    Path tmpFile = null;
    if (System.getProperty("jboss.cli.config") == null) {
        tmpFile = Files.createTempFile("jboss-cli", ".xml");
        Files.copy(Main.class.getResourceAsStream("/jboss-cli.xml"),
                tmpFile,
                StandardCopyOption.REPLACE_EXISTING);
        System.setProperty("jboss.cli.config", tmpFile.toAbsolutePath().toString());
    }
    Module cli = Module.getBootModuleLoader().loadModule("org.jboss.as.cli");
    try {
        cli.run(args);
    } finally {
        if (tmpFile != null) {
            Files.delete(tmpFile);
        }
    }
}
 
Example #6
Source File: Main.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
private static void runBootableJar(Path jbossHome, List<String> arguments, Long unzipTime) throws Exception {
    final String modulePath = jbossHome.resolve(JBOSS_MODULES_DIR_NAME).toAbsolutePath().toString();
    ModuleLoader moduleLoader = setupModuleLoader(modulePath);
    final Module bootableJarModule;
    try {
        bootableJarModule = moduleLoader.loadModule(MODULE_ID_JAR_RUNTIME);
    } catch (final ModuleLoadException mle) {
        throw new Exception(mle);
    }

    final ModuleClassLoader moduleCL = bootableJarModule.getClassLoader();
    final Class<?> bjFactoryClass;
    try {
        bjFactoryClass = moduleCL.loadClass(BOOTABLE_JAR);
    } catch (final ClassNotFoundException cnfe) {
        throw new Exception(cnfe);
    }
    Method runMethod;
    try {
        runMethod = bjFactoryClass.getMethod(BOOTABLE_JAR_RUN_METHOD, Path.class, List.class, ModuleLoader.class, ModuleClassLoader.class, Long.class);
    } catch (final NoSuchMethodException nsme) {
        throw new Exception(nsme);
    }
    runMethod.invoke(null, jbossHome, arguments, moduleLoader, moduleCL, unzipTime);
}
 
Example #7
Source File: ModuleUsageProvider.java    From thorntail with Apache License 2.0 6 votes vote down vote up
@Override
public String getRawUsageText() throws Exception {
    Module module = Module.getBootModuleLoader().loadModule("thorntail.application");
    ClassLoader cl = module.getClassLoader();

    InputStream in = cl.getResourceAsStream(META_INF_USAGE_TXT);

    if (in == null) {
        in = cl.getResourceAsStream(WEB_INF_USAGE_TXT);
    }

    if (in == null) {
        in = cl.getResourceAsStream(USAGE_TXT);
    }

    if (in != null) {
        try (BufferedReader reader = new BufferedReader(new InputStreamReader(in))) {
            return reader
                    .lines()
                    .collect(Collectors.joining("\n"));
        }
    }

    return null;
}
 
Example #8
Source File: BootstrapPersister.java    From thorntail with Apache License 2.0 6 votes vote down vote up
private XmlConfigurationPersister createDelegate(File configFile) {

        QName rootElement = new QName(Namespace.CURRENT.getUriString(), "server");
        ExtensionRegistry extensionRegistry = new ExtensionRegistry(
                ProcessType.SELF_CONTAINED,
                new RunningModeControl(RunningMode.NORMAL),
                null,
                null,
                null,
                RuntimeHostControllerInfoAccessor.SERVER
        );
        StandaloneXml parser = new StandaloneXml(Module.getBootModuleLoader(), Executors.newSingleThreadExecutor(), extensionRegistry);

        XmlConfigurationPersister persister = new XmlConfigurationPersister(
                configFile, rootElement, parser, parser, false
        );

        return persister;

    }
 
Example #9
Source File: KeycloakProviderDeploymentProcessor.java    From keycloak with Apache License 2.0 6 votes vote down vote up
@Override
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    KeycloakAdapterConfigService config = KeycloakAdapterConfigService.INSTANCE;
    String deploymentName = deploymentUnit.getName();

    if (config.isKeycloakServerDeployment(deploymentName)) {
        return;
    }

    KeycloakDeploymentInfo info = KeycloakProviderDependencyProcessor.getKeycloakProviderDeploymentInfo(deploymentUnit);
    
    ScriptProviderDeploymentProcessor.deploy(deploymentUnit, info);
    
    if (info.isProvider()) {
        logger.infov("Deploying Keycloak provider: {0}", deploymentUnit.getName());
        final Module module = deploymentUnit.getAttachment(Attachments.MODULE);
        ProviderManager pm = new ProviderManager(info, module.getClassLoader());
        ProviderManagerRegistry.SINGLETON.deploy(pm);
        deploymentUnit.putAttachment(ATTACHMENT_KEY, pm);
    }
}
 
Example #10
Source File: MultiVersionClusterTest.java    From keycloak with Apache License 2.0 6 votes vote down vote up
@Test
public void verifyFailureOnLegacy() throws Exception {

    deploy(deployment(), currentNode);
    
    try {
        backendTestingClients.get(currentNode).server().run(session -> {
            try {
                Class<?> itShouldFail = Module.getContextModuleLoader().loadModule("deployment.negative.jar").getClassLoader()
                        .loadClassLocal(SerializableTestClass.class.getName());
                session.getProvider(InfinispanConnectionProvider.class).getCache(InfinispanConnectionProvider.USER_SESSION_CACHE_NAME)
                        .put("itShouldFail", Reflections.newInstance(itShouldFail));
            } catch (Exception ex) {
                throw new RunOnServerException(ex);
            }
        });
    } catch (Exception e) {
        assertThat(e, instanceOf(RunOnServerException.class));
        assertThat(e.getCause().getCause(), instanceOf(RemoteException.class));
    } finally {
        undeploy(deployment(), currentNode);
    }
}
 
Example #11
Source File: ContextCreateHandlerRegistryIntegrationTest.java    From wildfly-camel with Apache License 2.0 6 votes vote down vote up
@Test
public void testHandlerRegistry() throws Exception {
    ContextCreateHandlerRegistry handlerRegistry = ServiceLocator.getRequiredService(CamelConstants.CONTEXT_CREATE_HANDLER_REGISTRY_SERVICE_NAME, ContextCreateHandlerRegistry.class);
    ModuleLoader moduleLoader = Module.getCallerModuleLoader();

    deployer.deploy(CAMEL_TEST_JAR);

    Module module = moduleLoader.loadModule(ModuleIdentifier.create("deployment.camel-test.jar"));
    ClassLoader classLoader = module.getClassLoader();

    // Registry should have classloader key after deploy
    Assert.assertTrue(handlerRegistry.containsKey(classLoader));

    deployer.undeploy(CAMEL_TEST_JAR);

    // Registry should have removed classloader key after undeploy
    Assert.assertFalse("Expected registry to not contain key: " + classLoader, handlerRegistry.containsKey(classLoader));
}
 
Example #12
Source File: CommandLine.java    From thorntail with Apache License 2.0 6 votes vote down vote up
public void displayConfigHelp(PrintStream out, String fraction) throws IOException, ModuleLoadException {
    ModuleClassLoader cl = Module.getBootModuleLoader().loadModule("thorntail.application").getClassLoader();
    Enumeration<URL> docs = cl.getResources("META-INF/configuration-meta.properties");

    Properties props = new Properties();

    while (docs.hasMoreElements()) {
        URL each = docs.nextElement();
        Properties fractionDocs = new Properties();
        fractionDocs.load(each.openStream());
        if (fraction.equals(ALL) || fraction.equals(fractionDocs.getProperty(FRACTION))) {
            fractionDocs.remove(FRACTION);
            props.putAll(fractionDocs);
        }
    }

    props.stringPropertyNames().stream()
            .sorted()
            .forEach(key -> {
                out.println("# " + key);
                out.println();
                out.println(formatDocs("    ", props.getProperty(key)));
                out.println();
            });
}
 
Example #13
Source File: CommandLine.java    From thorntail with Apache License 2.0 6 votes vote down vote up
public void dumpYaml(PrintStream out, String fraction) throws IOException, ModuleLoadException {
    ModuleClassLoader cl = Module.getBootModuleLoader().loadModule("thorntail.application").getClassLoader();
    Enumeration<URL> docs = cl.getResources("META-INF/configuration-meta.properties");

    Properties props = new Properties();

    while (docs.hasMoreElements()) {
        URL each = docs.nextElement();
        Properties fractionDocs = new Properties();
        fractionDocs.load(each.openStream());
        if (fraction.equals(ALL) || fraction.equals(fractionDocs.getProperty(FRACTION))) {
            fractionDocs.remove(FRACTION);
            props.putAll(fractionDocs);
        }
    }

    YamlDumper.dump(out, props);
}
 
Example #14
Source File: MainInvoker.java    From thorntail with Apache License 2.0 6 votes vote down vote up
public void stop() throws Exception {
    Method stopMethod = null;
    Class<?> mainClass = mainMethod.getDeclaringClass();
    try {
        stopMethod = mainClass.getDeclaredMethod("stopMain");
    } catch (NoSuchMethodException e) {
    }

    if (stopMethod != null) {
        stopMethod.invoke(mainClass, (Object[]) null);
    } else {
        Module module = Module.getBootModuleLoader().loadModule("swarm.container");
        Class<?> swarmClass = module.getClassLoader().loadClass("org.wildfly.swarm.Swarm");
        Field instanceField = swarmClass.getField("INSTANCE");
        Object swarmInstance = instanceField.get(null);
        if (swarmInstance != null) {
            stopMethod = swarmClass.getMethod("stop");
            stopMethod.invoke(swarmInstance);
        }
    }
}
 
Example #15
Source File: DaemonServiceActivator.java    From ARCHIVE-wildfly-swarm with Apache License 2.0 6 votes vote down vote up
@Override
public void start(StartContext context) throws StartException {
    try {
        final String artifactName = System.getProperty(BootstrapProperties.APP_ARTIFACT);
        if (artifactName == null) {
            throw new StartException("Failed to find artifact name under " + BootstrapProperties.APP_ARTIFACT);
        }

        final ModuleLoader serviceLoader = this.serviceLoader.getValue();
        final String moduleName = "deployment." + artifactName;
        final Module module = serviceLoader.loadModule(ModuleIdentifier.create(moduleName));
        if (module == null) {
            throw new StartException("Failed to find deployment module under " + moduleName);
        }

        //TODO: allow overriding the default port?
        this.server = Server.create("localhost", 12345, module.getClassLoader());
        this.server.start();
    } catch (ModuleLoadException | ServerLifecycleException e) {
        throw new StartException(e);
    }
}
 
Example #16
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 #17
Source File: Container.java    From ARCHIVE-wildfly-swarm with Apache License 2.0 6 votes vote down vote up
private void createServer(boolean debugBootstrap, URL xmlConfig) throws Exception {
    if (System.getProperty("boot.module.loader") == null) {
        System.setProperty("boot.module.loader", BootModuleLoader.class.getName());
    }
    if (debugBootstrap) {
        Module.setModuleLogger(new StreamModuleLogger(System.err));
    }
    Module module = Module.getBootModuleLoader().loadModule(ModuleIdentifier.create("org.wildfly.swarm.container", "runtime"));
    Class<?> serverClass = module.getClassLoader().loadClass("org.wildfly.swarm.container.runtime.RuntimeServer");
    try {
        this.server = (Server) serverClass.newInstance();
        if (this.xmlConfig != null)
            this.server.setXmlConfig(this.xmlConfig);
    } catch (Throwable t) {
        t.printStackTrace();
    }
}
 
Example #18
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 #19
Source File: RuntimeServer.java    From ARCHIVE-wildfly-swarm with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unused")
public RuntimeServer() {
    try {
        Module loggingModule = Module.getBootModuleLoader().loadModule(ModuleIdentifier.create("org.wildfly.swarm.logging", "runtime"));

        ClassLoader originalCl = Thread.currentThread().getContextClassLoader();
        try {
            Thread.currentThread().setContextClassLoader(loggingModule.getClassLoader());
            System.setProperty("java.util.logging.manager", "org.jboss.logmanager.LogManager");
            System.setProperty("org.jboss.logmanager.configurator", LoggingConfigurator.class.getName());
            //force logging init
            LogManager.getLogManager();
            BootstrapLogger.setBackingLoggerManager(new JBossLoggingManager());
        } finally {
            Thread.currentThread().setContextClassLoader(originalCl);
        }
    } catch (ModuleLoadException e) {
        System.err.println("[WARN] logging not available, logging will not be configured");
    }
}
 
Example #20
Source File: FaviconHandler.java    From ARCHIVE-wildfly-swarm with Apache License 2.0 6 votes vote down vote up
public Response toResponse(NotFoundException e) {
    if (e.getMessage().contains("favicon.ico")) {
        try {
            Module module = Module.getBootModuleLoader().loadModule(ModuleIdentifier.create("org.wildfly.swarm.undertow", "runtime"));
            ClassLoader cl = module.getClassLoader();
            final InputStream in = cl.getResourceAsStream("favicon.ico");
            if (in != null) {
                Response.ResponseBuilder builder = Response.ok();
                builder.entity(in);
                return builder.build();
            }
        } catch (ModuleLoadException e1) {
            throw e;
        }
    }

    // can't handle it, rethrow.
    throw e;
}
 
Example #21
Source File: LoggerContext.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Override
public void activate() {
    final Module logModule;
    try {
        logModule = moduleLoader.loadModule(MODULE_ID_LOGGING);
    } catch (final ModuleLoadException mle) {
        throw EmbeddedLogger.ROOT_LOGGER.moduleLoaderError(mle, MODULE_ID_LOGGING, moduleLoader);
    }

    final ModuleClassLoader logModuleClassLoader = logModule.getClassLoader();
    final ClassLoader tccl = getTccl();
    try {
        setTccl(logModuleClassLoader);
        loggerToRestore = Module.getModuleLogger();
        Module.setModuleLogger(new JBossLoggingModuleLogger());
    } finally {
        // Reset TCCL
        setTccl(tccl);
    }
}
 
Example #22
Source File: LoggerContext.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Override
public void restore() {
    final Module logModule;
    try {
        logModule = moduleLoader.loadModule(MODULE_ID_LOGGING);
    } catch (final ModuleLoadException mle) {
        throw EmbeddedLogger.ROOT_LOGGER.moduleLoaderError(mle, MODULE_ID_LOGGING, moduleLoader);
    }

    final ModuleClassLoader logModuleClassLoader = logModule.getClassLoader();
    final ClassLoader tccl = getTccl();
    try {
        setTccl(logModuleClassLoader);
        final ModuleLogger loggerToRestore = this.loggerToRestore;
        if (loggerToRestore == null) {
            Module.setModuleLogger(NoopModuleLogger.getInstance());
        } else {
            Module.setModuleLogger(loggerToRestore);
        }
    } finally {
        // Reset TCCL
        setTccl(tccl);
    }
}
 
Example #23
Source File: ConfigurationPersisterFactory.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
public static ExtensibleConfigurationPersister createDomainXmlConfigurationPersister(final ConfigurationFile file, ExecutorService executorService, ExtensionRegistry extensionRegistry, final HostControllerEnvironment environment) {
    DomainXml domainXml = new DomainXml(Module.getBootModuleLoader(), executorService, extensionRegistry);

    boolean suppressLoad = false;
    ConfigurationFile.InteractionPolicy policy = file.getInteractionPolicy();
    final boolean isReloaded = environment.getRunningModeControl().isReloaded();

    if (!isReloaded && (policy == ConfigurationFile.InteractionPolicy.NEW && (file.getBootFile().exists() && file.getBootFile().length() != 0))) {
        throw HostControllerLogger.ROOT_LOGGER.cannotOverwriteDomainXmlWithEmpty(file.getBootFile().getName());
    }

    if (!isReloaded && (policy == ConfigurationFile.InteractionPolicy.NEW || policy == ConfigurationFile.InteractionPolicy.DISCARD)) {
        suppressLoad = true;
    }

    BackupXmlConfigurationPersister persister = new BackupXmlConfigurationPersister(file, new QName(Namespace.CURRENT.getUriString(), "domain"), domainXml, domainXml, suppressLoad);
    for (Namespace namespace : Namespace.domainValues()) {
        if (!namespace.equals(Namespace.CURRENT)) {
            persister.registerAdditionalRootElement(new QName(namespace.getUriString(), "domain"), domainXml);
        }
    }
    extensionRegistry.setWriterRegistry(persister);
    return persister;
}
 
Example #24
Source File: ConfigurationPersisterFactory.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
public static ExtensibleConfigurationPersister createHostXmlConfigurationPersister(final ConfigurationFile file, final HostControllerEnvironment environment,
                                                                                   final ExecutorService executorService, final ExtensionRegistry hostExtensionRegistry,
                                                                                   final LocalHostControllerInfo localHostControllerInfo) {
    String defaultHostname = localHostControllerInfo.getLocalHostName();
    if (environment.getRunningModeControl().isReloaded()) {
        if (environment.getRunningModeControl().getReloadHostName() != null) {
            defaultHostname = environment.getRunningModeControl().getReloadHostName();
        }
    }
    HostXml hostXml = new HostXml(defaultHostname, environment.getRunningModeControl().getRunningMode(),
            environment.isUseCachedDc(), Module.getBootModuleLoader(), executorService, hostExtensionRegistry);
    BackupXmlConfigurationPersister persister = new BackupXmlConfigurationPersister(file, new QName(Namespace.CURRENT.getUriString(), "host"), hostXml, hostXml, false);
    for (Namespace namespace : Namespace.domainValues()) {
        if (!namespace.equals(Namespace.CURRENT)) {
            persister.registerAdditionalRootElement(new QName(namespace.getUriString(), "host"), hostXml);
        }
    }
    hostExtensionRegistry.setWriterRegistry(persister);
    return persister;
}
 
Example #25
Source File: KeycloakDependencyProcessor.java    From keycloak with Apache License 2.0 6 votes vote down vote up
@Override
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    if (!KeycloakAdapterConfigService.getInstance().isSecureDeployment(deploymentUnit)) {
        WarMetaData warMetaData = deploymentUnit.getAttachment(WarMetaData.ATTACHMENT_KEY);
        if (warMetaData == null) {
            return;
        }
        JBossWebMetaData webMetaData = warMetaData.getMergedJBossWebMetaData();
        if (webMetaData == null) {
            return;
        }
        LoginConfigMetaData loginConfig = webMetaData.getLoginConfig();
        if (loginConfig == null) return;
        if (loginConfig.getAuthMethod() == null) return;
        if (!loginConfig.getAuthMethod().equals("KEYCLOAK")) return;
    }

    final ModuleSpecification moduleSpecification = deploymentUnit.getAttachment(Attachments.MODULE_SPECIFICATION);
    final ModuleLoader moduleLoader = Module.getBootModuleLoader();
    addCommonModules(moduleSpecification, moduleLoader);
    addPlatformSpecificModules(phaseContext, moduleSpecification, moduleLoader);
}
 
Example #26
Source File: AbstractLoggingDeploymentProcessor.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
private void unregisterLogContext(final DeploymentUnit deploymentUnit, final AttachmentKey<LogContext> attachmentKey, final Module module) {
    final LogContext logContext = deploymentUnit.removeAttachment(attachmentKey);
    if (logContext != null) {
        final boolean success;
        if (WildFlySecurityManager.isChecking()) {
            success = WildFlySecurityManager.doUnchecked(new PrivilegedAction<Boolean>() {
                @Override
                public Boolean run() {
                    return logContextSelector.unregisterLogContext(module.getClassLoader(), logContext);
                }
            });
        } else {
            success = logContextSelector.unregisterLogContext(module.getClassLoader(), logContext);
        }
        if (success) {
            LoggingLogger.ROOT_LOGGER.tracef("Removed LogContext '%s' from '%s'", logContext, module);
        } else {
            LoggingLogger.ROOT_LOGGER.logContextNotRemoved(logContext, deploymentUnit.getName());
        }
    }
}
 
Example #27
Source File: PlugInLoaderService.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
private List<PlugInProvider> loadPlugInProvider(final String name) {
    synchronized (cachedProviders) {
        List<PlugInProvider> response;
        if (cachedProviders.containsKey(name)) {
            response = cachedProviders.get(name);
        } else {
            List<PlugInProvider> providers = new LinkedList<PlugInProvider>();
            try {
                for (PlugInProvider current : Module.loadServiceFromCallerModuleLoader(ModuleIdentifier.fromString(name),
                        PlugInProvider.class)) {
                    providers.add(current);
                }
            } catch (ModuleLoadException e) {
                throw DomainManagementLogger.ROOT_LOGGER.unableToLoadPlugInProviders(name, e.getMessage());
            }
            if (providers.size() > 0) {
                cachedProviders.put(name, providers);
                response = providers;
            } else {
                throw DomainManagementLogger.ROOT_LOGGER.noPlugInProvidersLoaded(name);
            }
        }
        return response;
    }
}
 
Example #28
Source File: InterfaceManagementUnitTestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
ModelControllerService(final ControlledProcessState processState, final StringConfigurationPersister persister, final ServerDelegatingResourceDefinition rootResourceDefinition) {
    super(ProcessType.EMBEDDED_SERVER, new RunningModeControl(RunningMode.ADMIN_ONLY), persister, processState, rootResourceDefinition, null, ExpressionResolver.TEST_RESOLVER,
            AuditLogger.NO_OP_LOGGER, new DelegatingConfigurableAuthorizer(), new ManagementSecurityIdentitySupplier(), new CapabilityRegistry(true));
    this.persister = persister;
    this.processState = processState;
    this.rootResourceDefinition = rootResourceDefinition;

    Properties properties = new Properties();
    properties.put("jboss.home.dir", System.getProperty("basedir", ".") + File.separatorChar + "target");

    final String hostControllerName = "hostControllerName"; // Host Controller name may not be null when in a managed domain
    environment = new ServerEnvironment(hostControllerName, properties, new HashMap<String, String>(), null, null,
            ServerEnvironment.LaunchType.DOMAIN, null, ProductConfig.fromFilesystemSlot(Module.getBootModuleLoader(), ".", properties), false);
    extensionRegistry =
            new ExtensionRegistry(ProcessType.STANDALONE_SERVER, new RunningModeControl(RunningMode.NORMAL), null, null, null, RuntimeHostControllerInfoAccessor.SERVER);

    capabilityRegistry = new CapabilityRegistry(processType.isServer());
}
 
Example #29
Source File: ProcessApplicationDeploymentProcessor.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
protected Map<String, byte[]> getDeploymentResources(ProcessArchiveXml processArchive, DeploymentUnit deploymentUnit, VirtualFile processesXmlFile) {

    final Module module = deploymentUnit.getAttachment(MODULE);

    Map<String, byte[]> resources = new HashMap<String, byte[]>();

    // first, add all resources listed in the processe.xml
    List<String> process = processArchive.getProcessResourceNames();
    ModuleClassLoader classLoader = module.getClassLoader();

    for (String resource : process) {
      InputStream inputStream = null;
      try {
        inputStream = classLoader.getResourceAsStream(resource);
        resources.put(resource, IoUtil.readInputStream(inputStream, resource));
      } finally {
        IoUtil.closeSilently(inputStream);
      }
    }

    // scan for process definitions
    if(PropertyHelper.getBooleanProperty(processArchive.getProperties(), ProcessArchiveXml.PROP_IS_SCAN_FOR_PROCESS_DEFINITIONS, process.isEmpty())) {

      //always use VFS scanner on JBoss
      final VfsProcessApplicationScanner scanner = new VfsProcessApplicationScanner();

      String resourceRootPath = processArchive.getProperties().get(ProcessArchiveXml.PROP_RESOURCE_ROOT_PATH);
      String[] additionalResourceSuffixes = StringUtil.split(processArchive.getProperties().get(ProcessArchiveXml.PROP_ADDITIONAL_RESOURCE_SUFFIXES), ProcessArchiveXml.PROP_ADDITIONAL_RESOURCE_SUFFIXES_SEPARATOR);
      URL processesXmlUrl = vfsFileAsUrl(processesXmlFile);
      resources.putAll(scanner.findResources(classLoader, resourceRootPath, processesXmlUrl, additionalResourceSuffixes));
    }

    return resources;
  }
 
Example #30
Source File: ProcessesXmlProcessor.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {

    DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();

    if(!ProcessApplicationAttachments.isProcessApplication(deploymentUnit)) {
      return;
    }

    final Module module = deploymentUnit.getAttachment(MODULE);

    // read @ProcessApplication annotation of PA-component
    String[] deploymentDescriptors = getDeploymentDescriptors(deploymentUnit);

    // load all processes.xml files
    List<URL> deploymentDescriptorURLs = getDeploymentDescriptorUrls(module, deploymentDescriptors);

    for (URL processesXmlResource : deploymentDescriptorURLs) {
      VirtualFile processesXmlFile = getFile(processesXmlResource);

      // parse processes.xml metadata.
      ProcessesXml processesXml = null;
      if(isEmptyFile(processesXmlResource)) {
        processesXml = ProcessesXml.EMPTY_PROCESSES_XML;
      } else {
        processesXml = parseProcessesXml(processesXmlResource);
      }

      // add the parsed metadata to the attachment list
      ProcessApplicationAttachments.addProcessesXml(deploymentUnit, new ProcessesXmlWrapper(processesXml, processesXmlFile));
    }
  }