Search in sources :

Example 26 with ModuleSpecification

use of org.jboss.as.server.deployment.module.ModuleSpecification in project wildfly by wildfly.

the class SarModuleDependencyProcessor method deploy.

/**
 * Add dependencies for modules required for manged bean deployments, if managed bean configurations are attached
 * to the deployment.
 *
 * @param phaseContext the deployment unit context
 * @throws DeploymentUnitProcessingException
 */
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    final ModuleSpecification moduleSpecification = deploymentUnit.getAttachment(Attachments.MODULE_SPECIFICATION);
    final JBossServiceXmlDescriptor serviceXmlDescriptor = deploymentUnit.getAttachment(JBossServiceXmlDescriptor.ATTACHMENT_KEY);
    if (serviceXmlDescriptor == null) {
        // Skip deployments with out a service xml descriptor
        return;
    }
    moduleSpecification.addSystemDependency(new ModuleDependency(Module.getBootModuleLoader(), JBOSS_MODULES_ID, false, false, false, false));
    moduleSpecification.addSystemDependency(new ModuleDependency(Module.getBootModuleLoader(), JBOSS_AS_SYSTEM_JMX_ID, true, false, false, false));
    // depend on Properties editor module which uses ServiceLoader approach to load the appropriate org.jboss.common.beans.property.finder.PropertyEditorFinder
    moduleSpecification.addSystemDependency(new ModuleDependency(Module.getBootModuleLoader(), PROPERTIES_EDITOR_MODULE_ID, false, false, true, false));
    // All SARs require the ability to register MBeans.
    moduleSpecification.addPermissionFactory(REGISTER_PERMISSION_FACTORY);
}
Also used : JBossServiceXmlDescriptor(org.jboss.as.service.descriptor.JBossServiceXmlDescriptor) ModuleDependency(org.jboss.as.server.deployment.module.ModuleDependency) ModuleSpecification(org.jboss.as.server.deployment.module.ModuleSpecification) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit)

Example 27 with ModuleSpecification

use of org.jboss.as.server.deployment.module.ModuleSpecification in project wildfly by wildfly.

the class WeldBeanValidationDependencyProcessor method deploy.

@Override
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();
    final CapabilityServiceSupport support = deploymentUnit.getAttachment(Attachments.CAPABILITY_SERVICE_SUPPORT);
    final WeldCapability weldCapability;
    try {
        weldCapability = support.getCapabilityRuntimeAPI(WELD_CAPABILITY_NAME, WeldCapability.class);
    } catch (CapabilityServiceSupport.NoSuchCapabilityException ignored) {
        return;
    }
    if (!weldCapability.isPartOfWeldDeployment(deploymentUnit)) {
        // Skip if there are no beans.xml files in the deployment
        return;
    }
    ModuleDependency cdiBeanValidationDep = new ModuleDependency(moduleLoader, CDI_BEAN_VALIDATION_ID, false, false, true, false);
    moduleSpecification.addSystemDependency(cdiBeanValidationDep);
}
Also used : ModuleLoader(org.jboss.modules.ModuleLoader) ModuleDependency(org.jboss.as.server.deployment.module.ModuleDependency) ModuleSpecification(org.jboss.as.server.deployment.module.ModuleSpecification) WeldCapability(org.jboss.as.weld.WeldCapability) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit) CapabilityServiceSupport(org.jboss.as.controller.capability.CapabilityServiceSupport)

Example 28 with ModuleSpecification

use of org.jboss.as.server.deployment.module.ModuleSpecification in project wildfly by wildfly.

the class CompensationsDependenciesDeploymentProcessor method addCompensationsModuleDependency.

private void addCompensationsModuleDependency(final DeploymentUnit unit) {
    final ModuleLoader moduleLoader = Module.getBootModuleLoader();
    final ModuleSpecification moduleSpec = unit.getAttachment(Attachments.MODULE_SPECIFICATION);
    moduleSpec.addSystemDependency(new ModuleDependency(moduleLoader, COMPENSATIONS_MODULE, false, false, true, false));
}
Also used : ModuleLoader(org.jboss.modules.ModuleLoader) ModuleDependency(org.jboss.as.server.deployment.module.ModuleDependency) ModuleSpecification(org.jboss.as.server.deployment.module.ModuleSpecification)

Example 29 with ModuleSpecification

use of org.jboss.as.server.deployment.module.ModuleSpecification in project wildfly by wildfly.

the class JPADependencyProcessor method addHibernate3AdaptorToDeployment.

private void addHibernate3AdaptorToDeployment(final ModuleLoader moduleLoader, final DeploymentUnit deploymentUnit) {
    final ModuleSpecification moduleSpecification = deploymentUnit.getAttachment(Attachments.MODULE_SPECIFICATION);
    try {
        final Module module = moduleLoader.loadModule(HIBERNATE_3_PROVIDER);
        //use a trick to get to the root of the class loader
        final URL url = module.getClassLoader().getResource(HIBERNATE3_PROVIDER_ADAPTOR.replace('.', '/') + ".class");
        final URLConnection connection = url.openConnection();
        if (!(connection instanceof JarURLConnection)) {
            throw JpaLogger.ROOT_LOGGER.invalidUrlConnection("hibernate 3", connection);
        }
        final JarFile jarFile = ((JarURLConnection) connection).getJarFile();
        moduleSpecification.addResourceLoader(ResourceLoaderSpec.createResourceLoaderSpec(ResourceLoaders.createJarResourceLoader("hibernate3integration", jarFile)));
        // hack in the dependencies which are part of hibernate3integration
        // TODO:  do this automatically (adding dependencies found in HIBERNATE_3_PROVIDER).
        addDependency(moduleSpecification, moduleLoader, deploymentUnit, JBOSS_AS_NAMING_ID, JBOSS_JANDEX_ID);
    } catch (ModuleLoadException e) {
        throw JpaLogger.ROOT_LOGGER.cannotLoadModule(e, HIBERNATE_3_PROVIDER, "hibernate 3");
    } catch (MalformedURLException e) {
        throw JpaLogger.ROOT_LOGGER.cannotAddIntegration(e, "hibernate 3");
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
}
Also used : ModuleLoadException(org.jboss.modules.ModuleLoadException) MalformedURLException(java.net.MalformedURLException) JarURLConnection(java.net.JarURLConnection) ModuleSpecification(org.jboss.as.server.deployment.module.ModuleSpecification) IOException(java.io.IOException) Module(org.jboss.modules.Module) JarFile(java.util.jar.JarFile) URL(java.net.URL) URLConnection(java.net.URLConnection) JarURLConnection(java.net.JarURLConnection)

Example 30 with ModuleSpecification

use of org.jboss.as.server.deployment.module.ModuleSpecification 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)

Aggregations

ModuleSpecification (org.jboss.as.server.deployment.module.ModuleSpecification)58 DeploymentUnit (org.jboss.as.server.deployment.DeploymentUnit)45 ModuleLoader (org.jboss.modules.ModuleLoader)45 ModuleDependency (org.jboss.as.server.deployment.module.ModuleDependency)44 ModuleIdentifier (org.jboss.modules.ModuleIdentifier)10 CapabilityServiceSupport (org.jboss.as.controller.capability.CapabilityServiceSupport)7 ResourceRoot (org.jboss.as.server.deployment.module.ResourceRoot)7 IOException (java.io.IOException)6 VirtualFile (org.jboss.vfs.VirtualFile)6 DeploymentUnitProcessingException (org.jboss.as.server.deployment.DeploymentUnitProcessingException)5 WeldCapability (org.jboss.as.weld.WeldCapability)5 HashSet (java.util.HashSet)4 MountHandle (org.jboss.as.server.deployment.module.MountHandle)4 WarMetaData (org.jboss.as.web.common.WarMetaData)4 ModuleLoadException (org.jboss.modules.ModuleLoadException)4 Closeable (java.io.Closeable)3 ArrayList (java.util.ArrayList)3 File (java.io.File)2 FilePermission (java.io.FilePermission)2 HashMap (java.util.HashMap)2