Java Code Examples for org.jboss.vfs.VFS#mountZip()

The following examples show how to use org.jboss.vfs.VFS#mountZip() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ManifestClassPathProcessor.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * 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);
    }
}
 
Example 2
Source File: Seam2Processor.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Lookup Seam integration resource loader.
 * @return the Seam integration resource loader
 * @throws DeploymentUnitProcessingException for any error
 */
protected synchronized ResourceRoot getSeamIntResourceRoot() throws DeploymentUnitProcessingException {
    try {
        if (seamIntResourceRoot == null) {
            final ModuleLoader moduleLoader = Module.getBootModuleLoader();
            Module extModule = moduleLoader.loadModule(EXT_CONTENT_MODULE);
            URL url = extModule.getExportedResource(SEAM_INT_JAR);
            if (url == null)
                throw ServerLogger.ROOT_LOGGER.noSeamIntegrationJarPresent(extModule);

            File file = new File(url.toURI());
            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 {
                }

                public void stop(StopContext stopContext) {
                    VFSUtils.safeClose(mountHandle);
                }

                public Closeable getValue() throws IllegalStateException, IllegalArgumentException {
                    return mountHandle;
                }
            };
            ServiceBuilder<Closeable> builder = serviceTarget.addService(ServiceName.JBOSS.append(SEAM_INT_JAR),
                    mountHandleService);
            builder.setInitialMode(ServiceController.Mode.ACTIVE).install();
            serviceTarget = null; // our cleanup service install work is done

            MountHandle dummy = MountHandle.create(null); // actual close is done by the MSC service above
            seamIntResourceRoot = new ResourceRoot(vf, dummy);
        }
        return seamIntResourceRoot;
    } catch (Exception e) {
        throw new DeploymentUnitProcessingException(e);
    }
}
 
Example 3
Source File: MountedDeploymentOverlay.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
public void remountAsZip(boolean expanded) throws IOException {
    IoUtils.safeClose(closeable);
    if(expanded) {
        closeable = VFS.mountZipExpanded(realFile, mountPoint, tempFileProvider);
    } else {
        closeable = VFS.mountZip(realFile, mountPoint, tempFileProvider);
    }
}