Search in sources :

Example 1 with ModuleDependency

use of org.jboss.as.server.deployment.module.ModuleDependency in project teiid by teiid.

the class VDBDependencyDeployer method deploy.

@Override
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    if (!TeiidAttachments.isVDBDeployment(deploymentUnit)) {
        return;
    }
    final VDBMetaData deployment = deploymentUnit.getAttachment(TeiidAttachments.VDB_METADATA);
    ArrayList<ModuleDependency> localDependencies = new ArrayList<ModuleDependency>();
    ArrayList<ModuleDependency> userDependencies = new ArrayList<ModuleDependency>();
    // $NON-NLS-1$
    String moduleNames = deployment.getPropertyValue("lib");
    if (moduleNames != null) {
        StringTokenizer modules = new StringTokenizer(moduleNames);
        while (modules.hasMoreTokens()) {
            String moduleName = modules.nextToken().trim();
            ModuleIdentifier lib = ModuleIdentifier.create(moduleName);
            ModuleLoader moduleLoader = Module.getCallerModuleLoader();
            try {
                moduleLoader.loadModule(lib);
                localDependencies.add(new ModuleDependency(moduleLoader, ModuleIdentifier.create(moduleName), false, false, false, false));
            } catch (ModuleLoadException e) {
                // this is to handle JAR based deployments which take on name like "deployment.<jar-name>"
                moduleLoader = deploymentUnit.getAttachment(Attachments.SERVICE_MODULE_LOADER);
                try {
                    moduleLoader.loadModule(lib);
                    userDependencies.add(new ModuleDependency(moduleLoader, ModuleIdentifier.create(moduleName), false, false, false, true));
                } catch (ModuleLoadException e1) {
                    throw new DeploymentUnitProcessingException(IntegrationPlugin.Util.gs(IntegrationPlugin.Event.TEIID50088, moduleName, deployment.getName(), deployment.getVersion(), e1));
                }
            }
        }
    }
    if (!TeiidAttachments.isVDBXMLDeployment(deploymentUnit)) {
        try {
            final ResourceRoot deploymentResourceRoot = deploymentUnit.getAttachment(Attachments.DEPLOYMENT_ROOT);
            final VirtualFile deploymentRoot = deploymentResourceRoot.getRoot();
            if (deploymentRoot == null) {
                return;
            }
            final VirtualFile libDir = deploymentRoot.getChild(LIB);
            if (libDir.exists()) {
                final List<VirtualFile> archives = libDir.getChildren(DEFAULT_JAR_LIB_FILTER);
                for (final VirtualFile archive : archives) {
                    try {
                        final Closeable closable = VFS.mountZip(archive, archive, TempFileProviderService.provider());
                        final ResourceRoot jarArchiveRoot = new ResourceRoot(archive.getName(), archive, new MountHandle(closable));
                        ModuleRootMarker.mark(jarArchiveRoot);
                        deploymentUnit.addToAttachmentList(Attachments.RESOURCE_ROOTS, jarArchiveRoot);
                    } catch (IOException e) {
                        throw new DeploymentUnitProcessingException(IntegrationPlugin.Util.gs(IntegrationPlugin.Event.TEIID50018, archive), e);
                    }
                }
            }
        } catch (IOException e) {
            throw new DeploymentUnitProcessingException(e);
        }
    }
    // add translators as dependent modules to this VDB.
    try {
        final ModuleSpecification moduleSpecification = deploymentUnit.getAttachment(Attachments.MODULE_SPECIFICATION);
        // $NON-NLS-1$
        final ModuleLoader moduleLoader = Module.getCallerModule().getModule(ModuleIdentifier.create("org.jboss.teiid")).getModuleLoader();
        // $NON-NLS-1$
        moduleSpecification.addLocalDependency(new ModuleDependency(moduleLoader, ModuleIdentifier.create("org.jboss.teiid.api"), false, false, false, false));
        // $NON-NLS-1$
        moduleSpecification.addLocalDependency(new ModuleDependency(moduleLoader, ModuleIdentifier.create("org.jboss.teiid.common-core"), false, false, false, false));
        // $NON-NLS-1$
        moduleSpecification.addLocalDependency(new ModuleDependency(moduleLoader, ModuleIdentifier.create("javax.api"), false, false, false, false));
        if (!localDependencies.isEmpty()) {
            moduleSpecification.addLocalDependencies(localDependencies);
        }
        if (!userDependencies.isEmpty()) {
            moduleSpecification.addUserDependencies(userDependencies);
        }
    } catch (ModuleLoadException e) {
        throw new DeploymentUnitProcessingException(IntegrationPlugin.Event.TEIID50018.name(), e);
    }
}
Also used : ModuleLoadException(org.jboss.modules.ModuleLoadException) DeploymentUnitProcessingException(org.jboss.as.server.deployment.DeploymentUnitProcessingException) VirtualFile(org.jboss.vfs.VirtualFile) ModuleLoader(org.jboss.modules.ModuleLoader) ModuleDependency(org.jboss.as.server.deployment.module.ModuleDependency) MountHandle(org.jboss.as.server.deployment.module.MountHandle) Closeable(java.io.Closeable) ArrayList(java.util.ArrayList) IOException(java.io.IOException) ResourceRoot(org.jboss.as.server.deployment.module.ResourceRoot) StringTokenizer(java.util.StringTokenizer) VDBMetaData(org.teiid.adminapi.impl.VDBMetaData) ModuleSpecification(org.jboss.as.server.deployment.module.ModuleSpecification) ModuleIdentifier(org.jboss.modules.ModuleIdentifier) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit)

Example 2 with ModuleDependency

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

the class ClusteringDependencyProcessor 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();
    moduleSpecification.addSystemDependency(new ModuleDependency(moduleLoader, API, true, false, false, false));
    moduleSpecification.addSystemDependency(new ModuleDependency(moduleLoader, MARSHALLING_API, true, false, false, false));
    moduleSpecification.addSystemDependency(new ModuleDependency(moduleLoader, SINGLETON_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 3 with ModuleDependency

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

the class BeanValidationDeploymentDependenciesProcessor 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();
    // 
    for (final ModuleIdentifier moduleIdentifier : DEPENDENCIES) {
        moduleSpecification.addSystemDependency(new ModuleDependency(moduleLoader, moduleIdentifier, true, 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) ModuleIdentifier(org.jboss.modules.ModuleIdentifier) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit)

Example 4 with ModuleDependency

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

the class HibernateSearchProcessor method addSearchDependency.

private void addSearchDependency(ModuleSpecification moduleSpecification, ModuleLoader moduleLoader, DeploymentUnit deploymentUnit) throws DeploymentUnitProcessingException {
    String searchModuleName = null;
    PersistenceUnitsInApplication persistenceUnitsInApplication = DeploymentUtils.getTopDeploymentUnit(deploymentUnit).getAttachment(PersistenceUnitsInApplication.PERSISTENCE_UNITS_IN_APPLICATION);
    for (PersistenceUnitMetadataHolder holder : persistenceUnitsInApplication.getPersistenceUnitHolders()) {
        for (PersistenceUnitMetadata pu : holder.getPersistenceUnits()) {
            String providerModule = pu.getProperties().getProperty(Configuration.HIBERNATE_SEARCH_MODULE);
            if (providerModule != null) {
                // one persistence unit specifying the Hibernate search module is allowed
                if (searchModuleName == null) {
                    searchModuleName = providerModule;
                } else // more than one persistence unit specifying different Hibernate search module names is not allowed
                if (!providerModule.equals(searchModuleName)) {
                    throw JpaLogger.ROOT_LOGGER.differentSearchModuleDependencies(deploymentUnit.getName(), searchModuleName, providerModule);
                }
            }
        }
    }
    if (NONE.equals(searchModuleName)) {
        // Hibernate Search module will not be added to deployment
        ROOT_LOGGER.debugf("Not adding Hibernate Search dependency to deployment %s", deploymentUnit.getName());
        return;
    }
    // use Search module name specified in persistence unit definition
    if (searchModuleName != null && !IGNORE.equals(searchModuleName)) {
        ModuleIdentifier moduleIdentifier = ModuleIdentifier.fromString(searchModuleName);
        moduleSpecification.addSystemDependency(new ModuleDependency(moduleLoader, moduleIdentifier, false, true, true, false));
        ROOT_LOGGER.debugf("added %s dependency to %s", moduleIdentifier, deploymentUnit.getName());
    } else {
        // add Hibernate Search module dependency if application is using the Hibernate Search Indexed annotation
        final CompositeIndex index = deploymentUnit.getAttachment(org.jboss.as.server.deployment.Attachments.COMPOSITE_ANNOTATION_INDEX);
        List<AnnotationInstance> annotations = index.getAnnotations(SEARCH_INDEXED_ANNOTATION_NAME);
        if (annotations != null && !annotations.isEmpty()) {
            moduleSpecification.addSystemDependency(new ModuleDependency(moduleLoader, defaultSearchModule, false, true, true, false));
            ROOT_LOGGER.debugf("deployment %s contains %s annotation, added %s dependency", deploymentUnit.getName(), SEARCH_INDEXED_ANNOTATION_NAME, defaultSearchModule);
        }
    }
}
Also used : ModuleDependency(org.jboss.as.server.deployment.module.ModuleDependency) PersistenceUnitMetadataHolder(org.jboss.as.jpa.config.PersistenceUnitMetadataHolder) PersistenceUnitsInApplication(org.jboss.as.jpa.config.PersistenceUnitsInApplication) CompositeIndex(org.jboss.as.server.deployment.annotation.CompositeIndex) PersistenceUnitMetadata(org.jipijapa.plugin.spi.PersistenceUnitMetadata) ModuleIdentifier(org.jboss.modules.ModuleIdentifier) AnnotationInstance(org.jboss.jandex.AnnotationInstance)

Example 5 with ModuleDependency

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

the class JPADependencyProcessor method addOptionalDependency.

private void addOptionalDependency(ModuleSpecification moduleSpecification, ModuleLoader moduleLoader, DeploymentUnit deploymentUnit, ModuleIdentifier... moduleIdentifiers) {
    for (ModuleIdentifier moduleIdentifier : moduleIdentifiers) {
        moduleSpecification.addSystemDependency(new ModuleDependency(moduleLoader, moduleIdentifier, true, false, false, false));
        ROOT_LOGGER.debugf("added %s dependency to %s", moduleIdentifier, deploymentUnit.getName());
    }
}
Also used : ModuleDependency(org.jboss.as.server.deployment.module.ModuleDependency) ModuleIdentifier(org.jboss.modules.ModuleIdentifier)

Aggregations

ModuleDependency (org.jboss.as.server.deployment.module.ModuleDependency)59 ModuleSpecification (org.jboss.as.server.deployment.module.ModuleSpecification)44 ModuleLoader (org.jboss.modules.ModuleLoader)39 DeploymentUnit (org.jboss.as.server.deployment.DeploymentUnit)33 ModuleIdentifier (org.jboss.modules.ModuleIdentifier)16 Test (org.junit.Test)6 ModuleLoadException (org.jboss.modules.ModuleLoadException)5 HashSet (java.util.HashSet)4 CapabilityServiceSupport (org.jboss.as.controller.capability.CapabilityServiceSupport)4 ArrayList (java.util.ArrayList)3 CompositeIndex (org.jboss.as.server.deployment.annotation.CompositeIndex)3 WarMetaData (org.jboss.as.web.common.WarMetaData)3 WeldCapability (org.jboss.as.weld.WeldCapability)3 Module (org.jboss.modules.Module)3 HashMap (java.util.HashMap)2 DeploymentUnitProcessingException (org.jboss.as.server.deployment.DeploymentUnitProcessingException)2 ResourceRoot (org.jboss.as.server.deployment.module.ResourceRoot)2 ServiceModuleLoader (org.jboss.as.server.moduleservice.ServiceModuleLoader)2 VirtualFile (org.jboss.vfs.VirtualFile)2 Closeable (java.io.Closeable)1