final MountHandle mountHandle = new MountHandle(closable); final ResourceRoot resourceRoot = new ResourceRoot(child, mountHandle);
/** * Creates a {@link ResourceRoot} for the passed {@link VirtualFile file} and adds it to the list of {@link ResourceRoot}s * in the {@link DeploymentUnit deploymentUnit} * * @param deploymentUnit The deployment unit * @param file The file for which the resource root will be created * @param markAsSubDeployment If this is true, then the {@link ResourceRoot} that is created will be marked as a subdeployment * through a call to {@link SubDeploymentMarker#mark(org.jboss.as.server.deployment.module.ResourceRoot)} * @param explodeDuringMount If this is true then the {@link VirtualFile file} will be exploded during mount, * while creating the {@link ResourceRoot} * @return Returns the created {@link ResourceRoot} * @throws IOException */ private ResourceRoot createResourceRoot(final DeploymentUnit deploymentUnit, final VirtualFile file, final boolean markAsSubDeployment, final boolean explodeDuringMount) throws IOException { final boolean war = file.getName().toLowerCase(Locale.ENGLISH).endsWith(WAR_EXTENSION); final Closeable closable = file.isFile() ? mount(file, explodeDuringMount) : exportExplodedWar(war, file, deploymentUnit); final MountHandle mountHandle = new MountHandle(closable); final ResourceRoot resourceRoot = new ResourceRoot(file, mountHandle); deploymentUnit.addToAttachmentList(Attachments.RESOURCE_ROOTS, resourceRoot); if (markAsSubDeployment) { SubDeploymentMarker.mark(resourceRoot); } if (war) { resourceRoot.putAttachment(Attachments.INDEX_RESOURCE_ROOT, false); SubExplodedDeploymentMarker.mark(resourceRoot); } return resourceRoot; }
closable = null; final ResourceRoot webInfArchiveRoot = new ResourceRoot(archive.getName(), archive, new MountHandle(closable)); ModuleRootMarker.mark(webInfArchiveRoot); entries.add(webInfArchiveRoot);
if(overlay != null) { overlay.remountAsZip(false); mountHandle = new MountHandle(null); } else { final Closeable closable = child.isFile() ? mount(child, false) : null; mountHandle = new MountHandle(closable);
closable = VFS.mountZip(child, child, TempFileProviderService.provider()); final MountHandle mountHandle = new MountHandle(closable); final ResourceRoot childResource = new ResourceRoot(child, mountHandle); ModuleRootMarker.mark(childResource);
closable = VFS.mountZip(child, child, TempFileProviderService.provider()); final MountHandle mountHandle = new MountHandle(closable); final ResourceRoot childResource = new ResourceRoot(child, mountHandle); ModuleRootMarker.mark(childResource);
public static MountHandle create(final Closeable handle) { @SuppressWarnings("deprecation") MountHandle mountHandle = new MountHandle(handle); if (handle != null) { // Use a PhantomReference instead of overriding finalize() to ensure close gets called // CleanerReference handles ensuring there's a strong ref to itself so we can just construct it and move on new CleanerReference<MountHandle, Closeable>(mountHandle, handle, REAPER); } return mountHandle; }
MountHandle dummy = new MountHandle(null); // actual close is done by the MSC service above seamIntResourceRoot = new ResourceRoot(vf, dummy);
MountHandle dummy = new MountHandle(null); // actual close is done by the MSC service above seamIntResourceRoot = new ResourceRoot(vf, dummy);
/** * Creates a {@link ResourceRoot} for the passed {@link VirtualFile file} and adds it to the list of {@link ResourceRoot}s * in the {@link DeploymentUnit deploymentUnit} * * @param deploymentUnit The deployment unit * @param file The file for which the resource root will be created * @param markAsSubDeployment If this is true, then the {@link ResourceRoot} that is created will be marked as a subdeployment * through a call to {@link SubDeploymentMarker#mark(org.jboss.as.server.deployment.module.ResourceRoot)} * @param explodeDuringMount If this is true then the {@link VirtualFile file} will be exploded during mount, * while creating the {@link ResourceRoot} * @return Returns the created {@link ResourceRoot} * @throws IOException */ private ResourceRoot createResourceRoot(final DeploymentUnit deploymentUnit, final VirtualFile file, final boolean markAsSubDeployment, final boolean explodeDuringMount) throws IOException { final boolean war = file.getName().toLowerCase(Locale.ENGLISH).endsWith(WAR_EXTENSION); final Closeable closable = file.isFile() ? mount(file, explodeDuringMount) : null; final MountHandle mountHandle = new MountHandle(closable); final ResourceRoot resourceRoot = new ResourceRoot(file, mountHandle); deploymentUnit.addToAttachmentList(Attachments.RESOURCE_ROOTS, resourceRoot); if (markAsSubDeployment) { SubDeploymentMarker.mark(resourceRoot); } if (war) { resourceRoot.putAttachment(Attachments.INDEX_RESOURCE_ROOT, false); } return resourceRoot; }
/** * Creates a {@link ResourceRoot} for the passed {@link VirtualFile file} and adds it to the list of {@link ResourceRoot}s * in the {@link DeploymentUnit deploymentUnit} * * @param deploymentUnit The deployment unit * @param file The file for which the resource root will be created * @return Returns the created {@link ResourceRoot} * @throws java.io.IOException */ private synchronized ResourceRoot createResourceRoot(final DeploymentUnit deploymentUnit, final VirtualFile file) throws DeploymentUnitProcessingException { try { final Closeable closable = file.isFile() ? VFS.mountZip(file, file, TempFileProviderService.provider()) : null; final MountHandle mountHandle = new MountHandle(closable); final ResourceRoot resourceRoot = new ResourceRoot(file, mountHandle); deploymentUnit.addToAttachmentList(Attachments.RESOURCE_ROOTS, resourceRoot); ModuleRootMarker.mark(resourceRoot); ResourceRootIndexer.indexResourceRoot(resourceRoot); return resourceRoot; } catch (IOException e) { throw new RuntimeException(e); } }
/** * Creates a {@link ResourceRoot} for the passed {@link VirtualFile file} and adds it to the list of {@link ResourceRoot}s * in the {@link DeploymentUnit deploymentUnit} * * @param deploymentUnit The deployment unit * @param file The file for which the resource root will be created * @param markAsSubDeployment If this is true, then the {@link ResourceRoot} that is created will be marked as a subdeployment * through a call to {@link SubDeploymentMarker#mark(org.jboss.as.server.deployment.module.ResourceRoot)} * @param explodeDuringMount If this is true then the {@link VirtualFile file} will be exploded during mount, * while creating the {@link ResourceRoot} * @return Returns the created {@link ResourceRoot} * @throws IOException */ private ResourceRoot createResourceRoot(final DeploymentUnit deploymentUnit, final VirtualFile file, final boolean markAsSubDeployment, final boolean explodeDuringMount) throws IOException { final boolean war = file.getName().toLowerCase(Locale.ENGLISH).endsWith(WAR_EXTENSION); final Closeable closable = file.isFile() ? mount(file, explodeDuringMount) : exportExplodedWar(war, file, deploymentUnit); final MountHandle mountHandle = new MountHandle(closable); final ResourceRoot resourceRoot = new ResourceRoot(file, mountHandle); deploymentUnit.addToAttachmentList(Attachments.RESOURCE_ROOTS, resourceRoot); if (markAsSubDeployment) { SubDeploymentMarker.mark(resourceRoot); } if (war) { resourceRoot.putAttachment(Attachments.INDEX_RESOURCE_ROOT, false); SubExplodedDeploymentMarker.mark(resourceRoot); } return resourceRoot; }
/** * Creates a {@link ResourceRoot} for the passed {@link VirtualFile file} and adds it to the list of {@link ResourceRoot}s * in the {@link DeploymentUnit deploymentUnit} * * * @param file The file for which the resource root will be created * @return Returns the created {@link ResourceRoot} * @throws java.io.IOException */ private synchronized ResourceRoot createResourceRoot(final VirtualFile file, final DeploymentUnit deploymentUnit, final VirtualFile deploymentRoot) throws DeploymentUnitProcessingException { try { Map<String, MountedDeploymentOverlay> overlays = deploymentUnit.getAttachment(Attachments.DEPLOYMENT_OVERLAY_LOCATIONS); String relativeName = file.getPathNameRelativeTo(deploymentRoot); MountedDeploymentOverlay overlay = overlays.get(relativeName); Closeable closable = null; if(overlay != null) { overlay.remountAsZip(false); } else if(file.isFile()) { closable = VFS.mountZip(file, file, TempFileProviderService.provider()); } final MountHandle mountHandle = new MountHandle(closable); final ResourceRoot resourceRoot = new ResourceRoot(file, mountHandle); ModuleRootMarker.mark(resourceRoot); ResourceRootIndexer.indexResourceRoot(resourceRoot); return resourceRoot; } catch (IOException e) { throw new RuntimeException(e); } }
/** * Creates a {@link ResourceRoot} for the passed {@link VirtualFile file} and adds it to the list of {@link ResourceRoot}s * in the {@link DeploymentUnit deploymentUnit} * * @param deploymentUnit The deployment unit * @param file The file for which the resource root will be created * @param markAsSubDeployment If this is true, then the {@link ResourceRoot} that is created will be marked as a subdeployment * through a call to {@link SubDeploymentMarker#mark(org.jboss.as.server.deployment.module.ResourceRoot)} * @param explodeDuringMount If this is true then the {@link VirtualFile file} will be exploded during mount, * while creating the {@link ResourceRoot} * @return Returns the created {@link ResourceRoot} * @throws IOException */ private ResourceRoot createResourceRoot(final DeploymentUnit deploymentUnit, final VirtualFile file, final boolean markAsSubDeployment, final boolean explodeDuringMount) throws IOException { final boolean war = file.getName().toLowerCase(Locale.ENGLISH).endsWith(WAR_EXTENSION); final Closeable closable = file.isFile() ? mount(file, explodeDuringMount) : exportExplodedWar(war, file, deploymentUnit); final MountHandle mountHandle = new MountHandle(closable); final ResourceRoot resourceRoot = new ResourceRoot(file, mountHandle); deploymentUnit.addToAttachmentList(Attachments.RESOURCE_ROOTS, resourceRoot); if (markAsSubDeployment) { SubDeploymentMarker.mark(resourceRoot); } if (war) { resourceRoot.putAttachment(Attachments.INDEX_RESOURCE_ROOT, false); SubExplodedDeploymentMarker.mark(resourceRoot); } return resourceRoot; }
/** * Creates a {@link ResourceRoot} for the passed {@link VirtualFile file} and adds it to the list of {@link ResourceRoot}s * in the {@link DeploymentUnit deploymentUnit} * * * @param file The file for which the resource root will be created * @return Returns the created {@link ResourceRoot} * @throws java.io.IOException */ private synchronized ResourceRoot createResourceRoot(final VirtualFile file, final DeploymentUnit deploymentUnit, final VirtualFile deploymentRoot) throws DeploymentUnitProcessingException { try { Map<String, MountedDeploymentOverlay> overlays = deploymentUnit.getAttachment(Attachments.DEPLOYMENT_OVERLAY_LOCATIONS); String relativeName = file.getPathNameRelativeTo(deploymentRoot); MountedDeploymentOverlay overlay = overlays.get(relativeName); Closeable closable = null; if(overlay != null) { overlay.remountAsZip(false); } else if(file.isFile()) { closable = VFS.mountZip(file, file, TempFileProviderService.provider()); } final MountHandle mountHandle = new MountHandle(closable); final ResourceRoot resourceRoot = new ResourceRoot(file, mountHandle); ModuleRootMarker.mark(resourceRoot); ResourceRootIndexer.indexResourceRoot(resourceRoot); return resourceRoot; } catch (IOException e) { throw new RuntimeException(e); } }
@Override public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException { DeploymentUnit unit = phaseContext.getDeploymentUnit(); ApplicationMetaData appMetaData = unit.getAttachment( ApplicationMetaData.ATTACHMENT_KEY ); if (appMetaData == null && !ArchivedDeploymentMarker.isMarked( unit )) { return; } ResourceRoot resourceRoot = unit.getAttachment( Attachments.DEPLOYMENT_ROOT ); VirtualFile root = resourceRoot.getRoot(); try { for (String scanRoot : this.scanRoots) { for (VirtualFile child : getJarFiles( root.getChild( scanRoot ) )) { this.mountedJars.add( child ); final Closeable closable = child.isFile() ? mount( child, false ) : null; final MountHandle mountHandle = new MountHandle( closable ); final ResourceRoot childResource = new ResourceRoot( child, mountHandle ); ModuleRootMarker.mark(childResource); unit.addToAttachmentList( Attachments.RESOURCE_ROOTS, childResource ); } } } catch (IOException e) { log.error( "Error processing jars", e ); } }
} else { final Closeable closable = appClientRoot.isFile() ? mount(appClientRoot, false) : null; final MountHandle mountHandle = new MountHandle(closable); final ResourceRoot childResource = new ResourceRoot(appClientRoot, mountHandle); ModuleRootMarker.mark(childResource);
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(RAR_EXTENSION)) { return; } //this violates the spec, but everyone expects it to work ModuleRootMarker.mark(resourceRoot, true); try { final List<VirtualFile> childArchives = deploymentRoot.getChildren(CHILD_ARCHIVE_FILTER); for (final VirtualFile child : childArchives) { final Closeable closable = child.isFile() ? VFS.mountZip(child, child, TempFileProviderService.provider()) : NO_OP_CLOSEABLE; 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 MESSAGES.failedToProcessRaChild(e, deploymentRoot); } }
closable = VFS.mountZip(child, child, TempFileProviderService.provider()); final MountHandle mountHandle = new MountHandle(closable); final ResourceRoot childResource = new ResourceRoot(child, mountHandle); ModuleRootMarker.mark(childResource);
try { handle = deploymentMountProvider.mountDeploymentContent( deploymentContents, deploymentRoot, MountType.REAL ); mountHandle = new MountHandle( handle ); } catch (IOException e) { failed = true;