final ResourceRoot deploymentRoot = phaseContext.getDeploymentUnit().getAttachment(Attachments.DEPLOYMENT_ROOT); final VirtualFile virtualFile = deploymentRoot.getRoot(); deploymentRoot.putAttachment(Attachments.INDEX_RESOURCE_ROOT, false); ModuleRootMarker.mark(deploymentRoot, false); final boolean appXmlPresent = deploymentRoot.getRoot().getChild("META-INF/application.xml").exists(); final EarMetaData earMetaData = deploymentUnit.getAttachment(org.jboss.as.ee.structure.Attachments.EAR_METADATA); if (earMetaData != null) { final String xmlLibDirName = earMetaData.getLibraryDirectory(); Map<String, MountedDeploymentOverlay> overlays = deploymentUnit.getAttachment(Attachments.DEPLOYMENT_OVERLAY_LOCATIONS); try { final VirtualFile libDir; libDir = virtualFile.getChild(libDirName); if (libDir.exists()) { List<VirtualFile> libArchives = libDir.getChildren(CHILD_ARCHIVE_FILTER); final MountHandle mountHandle; if(overlay != null) { overlay.remountAsZip(false); mountHandle = new MountHandle(null); } else { final Closeable closable = child.isFile() ? mount(child, false) : null; mountHandle = new MountHandle(closable); final ResourceRoot childResource = new ResourceRoot(child, mountHandle);
case XMLStreamConstants.END_ELEMENT: { try { final ResourceRoot deploymentRoot = deploymentUnit.getAttachment(Attachments.DEPLOYMENT_ROOT); final VirtualFile deploymentRootFile = deploymentRoot.getRoot(); final VirtualFile child = deploymentRootFile.getChild(path); Map<String, MountedDeploymentOverlay> overlays = deploymentUnit.getAttachment(Attachments.DEPLOYMENT_OVERLAY_LOCATIONS); MountedDeploymentOverlay overlay = overlays.get(path); Closeable closable = null; 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 resourceRoot = new ResourceRoot(name, child, mountHandle); for (final FilterSpecification filter : resourceFilters) { resourceRoot.getExportFilters().add(filter); resourceRoot.setUsePhysicalCodeSource(usePhysicalCodeSource);
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; Map<String, MountedDeploymentOverlay> overlays = deploymentUnit.getAttachment(Attachments.DEPLOYMENT_OVERLAY_LOCATIONS); try { final List<VirtualFile> childArchives = deploymentRoot.getChildren(CHILD_ARCHIVE_FILTER); 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));
final List<ResourceRoot> entries = new ArrayList<ResourceRoot>(); final VirtualFile webinfClasses = deploymentRoot.getChild(WEB_INF_CLASSES); if (webinfClasses.exists()) { final ResourceRoot webInfClassesRoot = new ResourceRoot(webinfClasses.getName(), webinfClasses, null); ModuleRootMarker.mark(webInfClassesRoot); entries.add(webInfClassesRoot); Map<String, MountedDeploymentOverlay> overlays = deploymentUnit.getAttachment(Attachments.DEPLOYMENT_OVERLAY_LOCATIONS); final VirtualFile webinfLib = deploymentRoot.getChild(WEB_INF_LIB); if (webinfLib.exists()) { Closeable closable = null; if(overlay != null) { overlay.remountAsZip(false); } else if (archive.isFile()) { closable = VFS.mountZip(archive, archive, TempFileProviderService.provider()); } else { closable = null; final ResourceRoot webInfArchiveRoot = new ResourceRoot(archive.getName(), archive, new MountHandle(closable)); ModuleRootMarker.mark(webInfArchiveRoot); entries.add(webInfArchiveRoot);
@Override public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException { final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit(); if (deploymentUnit.getName().toLowerCase(Locale.ENGLISH).endsWith(".ear")) { final Map<VirtualFile, ResourceRoot> existing = new HashMap<VirtualFile, ResourceRoot>(); for (final ResourceRoot additional : deploymentUnit.getAttachmentList(Attachments.RESOURCE_ROOTS)) { existing.put(additional.getRoot(), additional); final ResourceRoot root = deploymentUnit.getAttachment(Attachments.DEPLOYMENT_ROOT); final VirtualFile appClientRoot = root.getRoot().getChild(deployment); if (appClientRoot.exists()) { if (existing.containsKey(appClientRoot)) { final ResourceRoot existingRoot = existing.get(appClientRoot); ModuleRootMarker.mark(existingRoot); } 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); SubDeploymentMarker.mark(childResource);
DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit(); if (deploymentUnit.getAttachment( Attachments.DEPLOYMENT_ROOT ) != null || !deploymentUnit.getName().endsWith( this.fileSuffix )) { return; final DeploymentMountProvider deploymentMountProvider = deploymentUnit.getAttachment( Attachments.SERVER_DEPLOYMENT_REPOSITORY ); if(deploymentMountProvider == null) { throw new DeploymentUnitProcessingException( "No deployment repository available." ); String deploymentName = deploymentUnit.getName(); final VirtualFile deploymentRoot = VFS.getChild( "content/" + deploymentName ); Closeable handle = null; final MountHandle mountHandle; try { handle = deploymentMountProvider.mountDeploymentContent( deploymentContents, deploymentRoot, MountType.REAL ); mountHandle = new MountHandle( handle ); } catch (IOException e) { failed = true; final ResourceRoot resourceRoot = new ResourceRoot( deploymentRoot, mountHandle ); deploymentUnit.putAttachment( Attachments.DEPLOYMENT_ROOT, resourceRoot ); deploymentUnit.putAttachment( DESCRIPTOR_ROOT, resourceRoot );
throw new OperationFailedException(ConnectorLogger.ROOT_LOGGER.compressedRarNotSupportedInModuleRA(moduleName)); } else { child = VFS.getChild(path.getPath().split("META-INF")[0]); closable = VFS.mountReal(new File(path.getPath().split("META-INF")[0]), child); final MountHandle mountHandle = new MountHandle(closable); final ResourceRoot resourceRoot = new ResourceRoot(child, mountHandle); final VirtualFile deploymentRoot = resourceRoot.getRoot(); if (deploymentRoot == null || !deploymentRoot.exists()) return; ConnectorXmlDescriptor connectorXmlDescriptor = RaDeploymentParsingProcessor.process(resolveProperties, deploymentRoot, null, name); Map<ResourceRoot, Index> annotationIndexes = new HashMap<ResourceRoot, Index>(); ResourceRootIndexer.indexResourceRoot(resourceRoot); Index index = resourceRoot.getAttachment(Attachments.ANNOTATION_INDEX); if (index != null) { annotationIndexes.put(resourceRoot, index);
@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 ); } }
/** * 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; }
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException { final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit(); if(deploymentUnit.getAttachment(Attachments.DEPLOYMENT_ROOT) != null) { return; final DeploymentMountProvider deploymentMountProvider = deploymentUnit.getAttachment(Attachments.SERVER_DEPLOYMENT_REPOSITORY); if(deploymentMountProvider == null) { throw ServerLogger.ROOT_LOGGER.noDeploymentRepositoryAvailable(); final String deploymentName = deploymentUnit.getName(); final VirtualFile deploymentContents = deploymentUnit.getAttachment(Attachments.DEPLOYMENT_CONTENTS); if (deploymentContents.isDirectory()) { deploymentRoot = VFS.getChild("content/" + deploymentName); mountHandle = MountHandle.create(handle); } catch (IOException e) { failed = true; final ResourceRoot resourceRoot = new ResourceRoot(deploymentRoot, mountHandle); ModuleRootMarker.mark(resourceRoot); deploymentUnit.putAttachment(Attachments.DEPLOYMENT_ROOT, resourceRoot);
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException { DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit(); if (deploymentUnit.getParent() != null) { return; deploymentUnits.addAll(deploymentUnit.getAttachmentList(Attachments.SUB_DEPLOYMENTS)); WarMetaData warMetaData = unit.getAttachment(WarMetaData.ATTACHMENT_KEY); if (warMetaData == null) { continue; MountHandle mh = new MountHandle(null); // actual close is done by the MSC service above ResourceRoot resourceRoot = new ResourceRoot(getResteasySpringVirtualFile(), mh); ModuleRootMarker.mark(resourceRoot); deploymentUnit.addToAttachmentList(Attachments.RESOURCE_ROOTS, 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 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 = MountHandle.create(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 * @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); } }
VirtualFile vf = VFS.getChild(file.toURI()); final Closeable mountHandle = VFS.mountZip(file, vf, TempFileProviderService.provider()); Service<Closeable> mountHandleService = new Service<Closeable>() { public void start(StartContext startContext) throws StartException { MountHandle dummy = new MountHandle(null); // actual close is done by the MSC service above seamIntResourceRoot = new ResourceRoot(vf, dummy);
VirtualFile vf = VFS.getChild(file.toURI()); final Closeable mountHandle = VFS.mountZip(file, vf, TempFileProviderService.provider()); Service<Closeable> mountHandleService = new Service<Closeable>() { public void start(StartContext startContext) throws StartException { MountHandle dummy = MountHandle.create(null); // actual close is done by the MSC service above seamIntResourceRoot = new ResourceRoot(vf, dummy);
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; }
case XMLStreamConstants.END_ELEMENT: { try { final ResourceRoot deploymentRoot = deploymentUnit.getAttachment(Attachments.DEPLOYMENT_ROOT); final VirtualFile deploymentRootFile = deploymentRoot.getRoot(); final VirtualFile child = deploymentRootFile.getChild(path); Map<String, MountedDeploymentOverlay> overlays = deploymentUnit.getAttachment(Attachments.DEPLOYMENT_OVERLAY_LOCATIONS); MountedDeploymentOverlay overlay = overlays.get(path); Closeable closable = null; 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 resourceRoot = new ResourceRoot(name, child, mountHandle); for (final FilterSpecification filter : resourceFilters) { resourceRoot.getExportFilters().add(filter); resourceRoot.setUsePhysicalCodeSource(usePhysicalCodeSource);
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; final ModuleSpecification moduleSpecification = deploymentUnit.getAttachment(Attachments.MODULE_SPECIFICATION); moduleSpecification.setPublicModule(true); Map<String, MountedDeploymentOverlay> overlays = deploymentUnit.getAttachment(Attachments.DEPLOYMENT_OVERLAY_LOCATIONS); final List<VirtualFile> childArchives = deploymentRoot.getChildren(CHILD_ARCHIVE_FILTER); 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));
final List<ResourceRoot> entries = new ArrayList<ResourceRoot>(); final VirtualFile webinfClasses = deploymentRoot.getChild(WEB_INF_CLASSES); if (webinfClasses.exists()) { final ResourceRoot webInfClassesRoot = new ResourceRoot(webinfClasses.getName(), webinfClasses, null); ModuleRootMarker.mark(webInfClassesRoot); entries.add(webInfClassesRoot); Map<String, MountedDeploymentOverlay> overlays = deploymentUnit.getAttachment(Attachments.DEPLOYMENT_OVERLAY_LOCATIONS); final VirtualFile webinfLib = deploymentRoot.getChild(WEB_INF_LIB); if (webinfLib.exists()) { Closeable closable = null; if(overlay != null) { overlay.remountAsZip(false); } else if (archive.isFile()) { closable = VFS.mountZip(archive, archive, TempFileProviderService.provider()); } else { closable = null; final ResourceRoot webInfArchiveRoot = new ResourceRoot(archive.getName(), archive, new MountHandle(closable)); ModuleRootMarker.mark(webInfArchiveRoot); entries.add(webInfArchiveRoot);