Search in sources :

Example 16 with ModuleLoader

use of org.jboss.modules.ModuleLoader in project wildfly by wildfly.

the class HibernateSearchProcessor method deploy.

public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    final ModuleSpecification moduleSpecification = deploymentUnit.getAttachment(Attachments.MODULE_SPECIFICATION);
    final ModuleLoader moduleLoader = Module.getBootModuleLoader();
    if (JPADeploymentMarker.isJPADeployment(deploymentUnit)) {
        addSearchDependency(moduleSpecification, moduleLoader, deploymentUnit);
    }
}
Also used : ModuleLoader(org.jboss.modules.ModuleLoader) ModuleSpecification(org.jboss.as.server.deployment.module.ModuleSpecification) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit)

Example 17 with ModuleLoader

use of org.jboss.modules.ModuleLoader in project wildfly by wildfly.

the class PersistenceProviderLoader method loadProviderModuleByName.

/**
     * Loads the specified JPA persistence provider module
     *
     * @param moduleName is the static module to be loaded
     * @throws ModuleLoadException
     * @return list of persistence providers in specified module
     *
     * Note: side effect of saving loaded persistence providers to static api in javax.persistence.spi.PersistenceProvider.
     */
public static List<PersistenceProvider> loadProviderModuleByName(String moduleName) throws ModuleLoadException {
    final ModuleLoader moduleLoader = Module.getBootModuleLoader();
    Module module = moduleLoader.loadModule(ModuleIdentifier.fromString(moduleName));
    final ServiceLoader<PersistenceProvider> serviceLoader = module.loadService(PersistenceProvider.class);
    List<PersistenceProvider> result = new ArrayList<>();
    if (serviceLoader != null) {
        for (PersistenceProvider provider1 : serviceLoader) {
            // persistence provider jar may contain multiple provider service implementations
            // save each provider
            PersistenceProviderResolverImpl.getInstance().addPersistenceProvider(provider1);
            result.add(provider1);
        }
    }
    return result;
}
Also used : ModuleLoader(org.jboss.modules.ModuleLoader) PersistenceProvider(javax.persistence.spi.PersistenceProvider) ArrayList(java.util.ArrayList) Module(org.jboss.modules.Module)

Example 18 with ModuleLoader

use of org.jboss.modules.ModuleLoader in project wildfly by wildfly.

the class FederationDependencyProcessor method addDependency.

private void addDependency(DeploymentPhaseContext phaseContext, ServiceName federationServiceName) {
    DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    ModuleSpecification moduleSpecification = deploymentUnit.getAttachment(Attachments.MODULE_SPECIFICATION);
    ModuleLoader moduleLoader = Module.getBootModuleLoader();
    moduleSpecification.addSystemDependency(new ModuleDependency(moduleLoader, MODULE_ORG_PICKETLINK, false, false, true, false));
    phaseContext.addDeploymentDependency(federationServiceName, DEPLOYMENT_ATTACHMENT_KEY);
}
Also used : ModuleLoader(org.jboss.modules.ModuleLoader) ModuleDependency(org.jboss.as.server.deployment.module.ModuleDependency) ModuleSpecification(org.jboss.as.server.deployment.module.ModuleSpecification) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit)

Example 19 with ModuleLoader

use of org.jboss.modules.ModuleLoader in project wildfly by wildfly.

the class UndertowDependencyProcessor method deploy.

@Override
public void deploy(DeploymentPhaseContext phaseContext) {
    final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    final ModuleSpecification moduleSpecification = deploymentUnit.getAttachment(Attachments.MODULE_SPECIFICATION);
    final ModuleLoader moduleLoader = Module.getBootModuleLoader();
    //add the api classes for every deployment
    moduleSpecification.addSystemDependency(new ModuleDependency(moduleLoader, SERVLET_API, false, false, true, false));
    moduleSpecification.addSystemDependency(new ModuleDependency(moduleLoader, JSP_API, false, false, true, false));
    moduleSpecification.addSystemDependency(new ModuleDependency(moduleLoader, WEBSOCKET_API, false, false, true, false));
    moduleSpecification.addSystemDependency(new ModuleDependency(moduleLoader, JSTL, false, false, false, false));
    if (!DeploymentTypeMarker.isType(DeploymentType.WAR, deploymentUnit)) {
        // Skip non web deployments
        return;
    }
    moduleSpecification.addSystemDependency(new ModuleDependency(moduleLoader, UNDERTOW_CORE, false, false, true, false));
    moduleSpecification.addSystemDependency(new ModuleDependency(moduleLoader, UNDERTOW_SERVLET, false, false, true, false));
    moduleSpecification.addSystemDependency(new ModuleDependency(moduleLoader, UNDERTOW_JSP, false, false, true, false));
    moduleSpecification.addSystemDependency(new ModuleDependency(moduleLoader, UNDERTOW_WEBSOCKET, false, false, true, false));
    moduleSpecification.addSystemDependency(new ModuleDependency(moduleLoader, UNDERTOW_JS, true, false, true, false));
    moduleSpecification.addSystemDependency(new ModuleDependency(moduleLoader, CLUSTERING_API, true, false, false, false));
}
Also used : ModuleLoader(org.jboss.modules.ModuleLoader) ModuleDependency(org.jboss.as.server.deployment.module.ModuleDependency) ModuleSpecification(org.jboss.as.server.deployment.module.ModuleSpecification) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit)

Example 20 with ModuleLoader

use of org.jboss.modules.ModuleLoader in project wildfly by wildfly.

the class ExpressionFilterDefinition method createHttpHandler.

@Override
public HttpHandler createHttpHandler(Predicate predicate, ModelNode model, HttpHandler next) {
    String expression = model.get(EXPRESSION.getName()).asString();
    String moduleName = null;
    if (model.hasDefined(MODULE.getName())) {
        moduleName = model.get(MODULE.getName()).asString();
    }
    ClassLoader classLoader;
    if (moduleName == null) {
        classLoader = getClass().getClassLoader();
    } else {
        try {
            ModuleLoader moduleLoader = Module.getBootModuleLoader();
            Module filterModule = moduleLoader.loadModule(ModuleIdentifier.fromString(moduleName));
            classLoader = filterModule.getClassLoader();
        } catch (ModuleLoadException e) {
            throw UndertowLogger.ROOT_LOGGER.couldNotLoadHandlerFromModule(expression, moduleName, e);
        }
    }
    List<PredicatedHandler> handlers = PredicatedHandlersParser.parse(expression, classLoader);
    UndertowLogger.ROOT_LOGGER.debugf("Creating http handler %s from module %s", expression, moduleName);
    if (predicate != null) {
        return Handlers.predicate(predicate, Handlers.predicates(handlers, next), next);
    } else {
        return Handlers.predicates(handlers, next);
    }
}
Also used : ModuleLoadException(org.jboss.modules.ModuleLoadException) ModuleLoader(org.jboss.modules.ModuleLoader) PredicatedHandler(io.undertow.server.handlers.builder.PredicatedHandler) Module(org.jboss.modules.Module)

Aggregations

ModuleLoader (org.jboss.modules.ModuleLoader)32 ModuleSpecification (org.jboss.as.server.deployment.module.ModuleSpecification)26 DeploymentUnit (org.jboss.as.server.deployment.DeploymentUnit)24 ModuleDependency (org.jboss.as.server.deployment.module.ModuleDependency)22 Module (org.jboss.modules.Module)4 ModuleIdentifier (org.jboss.modules.ModuleIdentifier)4 ArrayList (java.util.ArrayList)2 PredicatedHandler (io.undertow.server.handlers.builder.PredicatedHandler)1 Method (java.lang.reflect.Method)1 Collections (java.util.Collections)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 List (java.util.List)1 ConcurrencyManagementType (javax.ejb.ConcurrencyManagementType)1 TransactionManagementType (javax.ejb.TransactionManagementType)1 PersistenceProvider (javax.persistence.spi.PersistenceProvider)1 Attachments (org.jboss.as.ee.component.Attachments)1 ComponentConfiguration (org.jboss.as.ee.component.ComponentConfiguration)1 ComponentConfigurator (org.jboss.as.ee.component.ComponentConfigurator)1 ComponentDescription (org.jboss.as.ee.component.ComponentDescription)1