use of org.jboss.as.server.deployment.module.MountHandle 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);
}
use of org.jboss.as.server.deployment.module.MountHandle in project wildfly by wildfly.
the class SarStructureProcessor method deploy.
@Override
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
final ResourceRoot resourceRoot = deploymentUnit.getAttachment(Attachments.DEPLOYMENT_ROOT);
if (resourceRoot == null) {
return;
}
final VirtualFile deploymentRoot = resourceRoot.getRoot();
if (deploymentRoot == null || !deploymentRoot.exists()) {
return;
}
final String deploymentRootName = deploymentRoot.getName().toLowerCase(Locale.ENGLISH);
if (!deploymentRootName.endsWith(SAR_EXTENSION)) {
return;
}
ModuleRootMarker.mark(resourceRoot, true);
Map<String, MountedDeploymentOverlay> overlays = deploymentUnit.getAttachment(Attachments.DEPLOYMENT_OVERLAY_LOCATIONS);
try {
final List<VirtualFile> childArchives = deploymentRoot.getChildren(CHILD_ARCHIVE_FILTER);
for (final VirtualFile child : childArchives) {
String relativeName = child.getPathNameRelativeTo(deploymentRoot);
MountedDeploymentOverlay overlay = overlays.get(relativeName);
Closeable closable = NO_OP_CLOSEABLE;
if (overlay != null) {
overlay.remountAsZip(false);
} else if (child.isFile()) {
closable = VFS.mountZip(child, child, TempFileProviderService.provider());
}
final MountHandle mountHandle = new MountHandle(closable);
final ResourceRoot childResource = new ResourceRoot(child, mountHandle);
ModuleRootMarker.mark(childResource);
deploymentUnit.addToAttachmentList(Attachments.RESOURCE_ROOTS, childResource);
resourceRoot.addToAttachmentList(Attachments.INDEX_IGNORE_PATHS, child.getPathNameRelativeTo(deploymentRoot));
}
} catch (IOException e) {
throw SarLogger.ROOT_LOGGER.failedToProcessSarChild(e, deploymentRoot);
}
}
Aggregations