Search in sources :

Example 1 with ModuleSpecification

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

use of org.jboss.as.server.deployment.module.ModuleSpecification in project camunda-bpm-platform by camunda.

the class ModuleDependencyProcessor method deploy.

public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    if (deploymentUnit.getParent() == null) {
        // The deployment unit has no parent so it is a simple war or an ear.
        ModuleLoader moduleLoader = Module.getBootModuleLoader();
        // If it is a simpleWar and marked with process application we have to add the dependency
        boolean isProcessApplicationWarOrEar = ProcessApplicationAttachments.isProcessApplication(deploymentUnit);
        AttachmentList<DeploymentUnit> subdeployments = deploymentUnit.getAttachment(Attachments.SUB_DEPLOYMENTS);
        // In cases of war files we have nothing todo.
        if (subdeployments != null) {
            // The deployment unit contains sub deployments which means the deployment unit is an ear.
            // We have to check whether sub deployments are process applications or not.
            boolean subDeploymentIsProcessApplication = false;
            for (DeploymentUnit subDeploymentUnit : subdeployments) {
                if (ProcessApplicationAttachments.isProcessApplication(subDeploymentUnit)) {
                    subDeploymentIsProcessApplication = true;
                    break;
                }
            }
            // Also we have to add the dependency to the current deployment unit which is an ear
            if (subDeploymentIsProcessApplication) {
                for (DeploymentUnit subDeploymentUnit : subdeployments) {
                    final ModuleSpecification moduleSpecification = subDeploymentUnit.getAttachment(Attachments.MODULE_SPECIFICATION);
                    addSystemDependencies(moduleLoader, moduleSpecification);
                }
                // An ear is not marked as process application but also needs the dependency
                isProcessApplicationWarOrEar = true;
            }
        }
        if (isProcessApplicationWarOrEar) {
            final ModuleSpecification moduleSpecification = deploymentUnit.getAttachment(Attachments.MODULE_SPECIFICATION);
            addSystemDependencies(moduleLoader, moduleSpecification);
        }
    }
    // install the pa-module service
    ModuleIdentifier identifyer = deploymentUnit.getAttachment(Attachments.MODULE_IDENTIFIER);
    String moduleName = identifyer.toString();
    ProcessApplicationModuleService processApplicationModuleService = new ProcessApplicationModuleService();
    ServiceName serviceName = ServiceNames.forProcessApplicationModuleService(moduleName);
    phaseContext.getServiceTarget().addService(serviceName, processApplicationModuleService).addDependency(phaseContext.getPhaseServiceName()).setInitialMode(Mode.ACTIVE).install();
}
Also used : ModuleLoader(org.jboss.modules.ModuleLoader) ProcessApplicationModuleService(org.camunda.bpm.container.impl.jboss.service.ProcessApplicationModuleService) ServiceName(org.jboss.msc.service.ServiceName) ModuleSpecification(org.jboss.as.server.deployment.module.ModuleSpecification) ModuleIdentifier(org.jboss.modules.ModuleIdentifier) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit)

Example 3 with ModuleSpecification

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

the class EESecurityDependencyProcessor method deploy.

@Override
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    final DeploymentUnit unit = phaseContext.getDeploymentUnit();
    final DeploymentUnit top = unit.getParent() == null ? unit : unit.getParent();
    final ModuleLoader moduleLoader = Module.getBootModuleLoader();
    final ModuleSpecification moduleSpec = unit.getAttachment(Attachments.MODULE_SPECIFICATION);
    moduleSpec.addSystemDependency(new ModuleDependency(moduleLoader, ModuleIdentifier.fromString("javax.security.enterprise.api"), false, false, true, false));
    Boolean securityPresent = top.getAttachment(EESecurityAnnotationProcessor.SECURITY_PRESENT);
    if (securityPresent != null && securityPresent) {
        moduleSpec.addSystemDependency(new ModuleDependency(moduleLoader, ModuleIdentifier.fromString("org.glassfish.soteria"), 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) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit)

Example 4 with ModuleSpecification

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

the class GlobalModuleDependencyProcessor method deploy.

@Override
public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    final ModuleSpecification moduleSpecification = deploymentUnit.getAttachment(Attachments.MODULE_SPECIFICATION);
    final List<GlobalModule> globalMods = this.globalModules;
    for (final GlobalModule module : globalMods) {
        final ModuleDependency dependency = new ModuleDependency(Module.getBootModuleLoader(), module.getModuleIdentifier(), false, false, module.isServices(), false);
        if (module.isMetaInf()) {
            dependency.addImportFilter(PathFilters.getMetaInfSubdirectoriesFilter(), true);
            dependency.addImportFilter(PathFilters.getMetaInfFilter(), true);
        }
        if (module.isAnnotations()) {
            deploymentUnit.addToAttachmentList(Attachments.ADDITIONAL_ANNOTATION_INDEXES, module.getModuleIdentifier());
        }
        moduleSpecification.addSystemDependency(dependency);
    }
}
Also used : GlobalModule(org.jboss.as.ee.subsystem.GlobalModulesDefinition.GlobalModule) ModuleDependency(org.jboss.as.server.deployment.module.ModuleDependency) ModuleSpecification(org.jboss.as.server.deployment.module.ModuleSpecification) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit)

Example 5 with ModuleSpecification

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

the class StaticInterceptorsDependenciesDeploymentUnitProcessor method deploy.

@Override
public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    final ModuleLoader moduleLoader = Module.getBootModuleLoader();
    final ModuleSpecification deploymentModuleSpec = deploymentUnit.getAttachment(Attachments.MODULE_SPECIFICATION);
    for (final String interceptorModule : interceptorModules) {
        final ModuleIdentifier interceptorModuleId = ModuleIdentifier.create(interceptorModule);
        deploymentModuleSpec.addSystemDependency(new ModuleDependency(moduleLoader, interceptorModuleId, 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) ModuleIdentifier(org.jboss.modules.ModuleIdentifier) 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