Search in sources :

Example 56 with ModuleSpecification

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

the class WarStructureDeploymentProcessor method deploy.

@Override
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    if (!DeploymentTypeMarker.isType(DeploymentType.WAR, deploymentUnit)) {
        // Skip non web deployments
        return;
    }
    final ResourceRoot deploymentResourceRoot = deploymentUnit.getAttachment(Attachments.DEPLOYMENT_ROOT);
    final VirtualFile deploymentRoot = deploymentResourceRoot.getRoot();
    if (deploymentRoot == null) {
        return;
    }
    // set the child first behaviour
    final ModuleSpecification moduleSpecification = deploymentUnit.getAttachment(Attachments.MODULE_SPECIFICATION);
    if (moduleSpecification == null) {
        return;
    }
    moduleSpecification.setPrivateModule(true);
    // other sub deployments should not have access to classes in the war module
    PrivateSubDeploymentMarker.mark(deploymentUnit);
    // we do not want to index the resource root, only WEB-INF/classes and WEB-INF/lib
    deploymentResourceRoot.putAttachment(Attachments.INDEX_RESOURCE_ROOT, false);
    // Make sure the root does not end up in the module, only META-INF
    deploymentResourceRoot.getExportFilters().add(new FilterSpecification(PathFilters.getMetaInfFilter(), true));
    deploymentResourceRoot.getExportFilters().add(new FilterSpecification(PathFilters.getMetaInfSubdirectoriesFilter(), true));
    deploymentResourceRoot.getExportFilters().add(new FilterSpecification(PathFilters.acceptAll(), false));
    ModuleRootMarker.mark(deploymentResourceRoot, true);
    // TODO: This needs to be ported to add additional resource roots the standard way
    final MountHandle mountHandle = deploymentResourceRoot.getMountHandle();
    try {
        // add standard resource roots, this should eventually replace ClassPathEntry
        final List<ResourceRoot> resourceRoots = createResourceRoots(deploymentRoot, deploymentUnit);
        for (ResourceRoot root : resourceRoots) {
            deploymentUnit.addToAttachmentList(Attachments.RESOURCE_ROOTS, root);
        }
    } catch (Exception e) {
        throw new DeploymentUnitProcessingException(e);
    }
    // Add the war metadata
    final WarMetaData warMetaData = new WarMetaData();
    deploymentUnit.putAttachment(WarMetaData.ATTACHMENT_KEY, warMetaData);
    String deploymentName;
    if (deploymentUnit.getParent() == null) {
        deploymentName = deploymentUnit.getName();
    } else {
        deploymentName = deploymentUnit.getParent().getName() + "." + deploymentUnit.getName();
    }
    PathManager pathManager = deploymentUnit.getAttachment(Attachments.PATH_MANAGER);
    File tempDir = new File(pathManager.getPathEntry(TEMP_DIR).resolvePath(), deploymentName);
    tempDir.mkdirs();
    warMetaData.setTempDir(tempDir);
    moduleSpecification.addPermissionFactory(new ImmediatePermissionFactory(new FilePermission(tempDir.getAbsolutePath() + File.separatorChar + "-", "read,write,delete")));
    // Add the shared TLDs metadata
    final TldsMetaData tldsMetaData = new TldsMetaData();
    tldsMetaData.setSharedTlds(sharedTldsMetaData);
    deploymentUnit.putAttachment(TldsMetaData.ATTACHMENT_KEY, tldsMetaData);
    processExternalMounts(deploymentUnit, deploymentRoot);
}
Also used : VirtualFile(org.jboss.vfs.VirtualFile) DeploymentUnitProcessingException(org.jboss.as.server.deployment.DeploymentUnitProcessingException) PathManager(org.jboss.as.controller.services.path.PathManager) MountHandle(org.jboss.as.server.deployment.module.MountHandle) FilterSpecification(org.jboss.as.server.deployment.module.FilterSpecification) WarMetaData(org.jboss.as.web.common.WarMetaData) FilePermission(java.io.FilePermission) DeploymentUnitProcessingException(org.jboss.as.server.deployment.DeploymentUnitProcessingException) IOException(java.io.IOException) ResourceRoot(org.jboss.as.server.deployment.module.ResourceRoot) ModuleSpecification(org.jboss.as.server.deployment.module.ModuleSpecification) ImmediatePermissionFactory(org.jboss.modules.security.ImmediatePermissionFactory) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit) VirtualFile(org.jboss.vfs.VirtualFile) File(java.io.File)

Example 57 with ModuleSpecification

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

the class WSDependenciesProcessor method deploy.

public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    final DeploymentUnit unit = phaseContext.getDeploymentUnit();
    final ModuleLoader moduleLoader = Module.getBootModuleLoader();
    final ModuleSpecification moduleSpec = unit.getAttachment(Attachments.MODULE_SPECIFICATION);
    if (addJBossWSDependencies) {
        moduleSpec.addSystemDependency(new ModuleDependency(moduleLoader, JBOSSWS_API, false, true, true, false));
        moduleSpec.addSystemDependency(new ModuleDependency(moduleLoader, JBOSSWS_SPI, false, true, true, false));
    }
    for (ModuleIdentifier api : JAVAEE_APIS) {
        moduleSpec.addSystemDependency(new ModuleDependency(moduleLoader, api, false, false, true, false));
    }
    // After jboss modules 2.0, the xercers module is not added
    moduleSpec.addSystemDependency(new ModuleDependency(moduleLoader, XERCES_IMPL, 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 58 with ModuleSpecification

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

the class WeldDependencyProcessor method deploy.

/**
 * Add dependencies for modules required for weld deployments, if managed weld configurations are attached to the deployment
 */
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();
    addDependency(moduleSpecification, moduleLoader, JAVAX_ENTERPRISE_API);
    addDependency(moduleSpecification, moduleLoader, JAVAX_INJECT_API);
    if (!WeldDeploymentMarker.isPartOfWeldDeployment(deploymentUnit)) {
        // Skip if there are no beans.xml files in the deployment
        return;
    }
    addDependency(moduleSpecification, moduleLoader, JAVAX_PERSISTENCE_API_ID);
    addDependency(moduleSpecification, moduleLoader, WELD_CORE_ID);
    addDependency(moduleSpecification, moduleLoader, WELD_PROBE_ID, true);
    addDependency(moduleSpecification, moduleLoader, WELD_API_ID);
    addDependency(moduleSpecification, moduleLoader, WELD_SPI_ID);
    ModuleDependency weldSubsystemDependency = new ModuleDependency(moduleLoader, JBOSS_AS_WELD_ID, false, false, false, false);
    weldSubsystemDependency.addImportFilter(PathFilters.getMetaInfFilter(), true);
    weldSubsystemDependency.addImportFilter(PathFilters.is("org/jboss/as/weld/injection"), true);
    weldSubsystemDependency.addImportFilter(PathFilters.acceptAll(), false);
    weldSubsystemDependency.addExportFilter(PathFilters.getMetaInfFilter(), true);
    moduleSpecification.addSystemDependency(weldSubsystemDependency);
    // Due to serialization of Jakarta Enterprise Beans
    ModuleDependency weldEjbDependency = new ModuleDependency(moduleLoader, JBOSS_AS_WELD_EJB_ID, true, false, false, false);
    weldEjbDependency.addImportFilter(PathFilters.is("org/jboss/as/weld/ejb"), true);
    weldEjbDependency.addImportFilter(PathFilters.acceptAll(), false);
    moduleSpecification.addSystemDependency(weldEjbDependency);
}
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