/** * Create a temporary file provider for a given type. * <p/> * This is the same as calling {@link #create(String, java.util.concurrent.ScheduledExecutorService, boolean) create(final String providerType, final ScheduledExecutorService executor, false)} * * @param providerType the provider type string (used as a prefix in the temp file dir name) * @param executor the executor * @return the new provider * @throws IOException if an I/O error occurs */ public static TempFileProvider create(String providerType, ScheduledExecutorService executor) throws IOException { return create(providerType, executor, false); }
@PostConstruct public void postConstruct() throws IOException { this.tempDir = this.tempFileProvider.createTempDir("wildfly-swarm-deployments.tmp"); }
@PreDestroy void close() { try { this.tempFileProvider.close(); } catch (IOException e) { SwarmMessages.MESSAGES.errorCleaningUpTempFileProvider(e); } }
if (possiblyExistingProviderRoot.exists()) { final File toBeDeletedProviderRoot = new File(TMP_ROOT, createTempName(providerType + "-to-be-deleted-", "")); final boolean renamed = possiblyExistingProviderRoot.renameTo(toBeDeletedProviderRoot); if (!renamed) { return new TempFileProvider(createTempDir(providerType, "", providerRoot), executor);
/** * @return * @throws IOException */ private TempFileProvider getTempFileProvider() throws IOException { if (tempFileProvider == null) { tempFileProvider = TempFileProvider.create("temp", Executors.newSingleThreadScheduledExecutor()); } return tempFileProvider; }
@PostConstruct public void postConstruct() throws IOException { this.tempDir = this.tempFileProvider.createTempDir("wildfly-swarm-deployments.tmp"); }
@PreDestroy void close() { try { this.tempFileProvider.close(); } catch (IOException e) { SwarmMessages.MESSAGES.errorCleaningUpTempFileProvider(e); } }
private static TempFileProvider getTempFileProvider() throws IOException { if (tempFileProvider == null) { tempFileProvider = TempFileProvider.create("automount", Executors.newScheduledThreadPool(2)); } return tempFileProvider; }
@PostConstruct public void postConstruct() throws IOException { this.tempDir = this.tempFileProvider.createTempDir("wildfly-swarm-deployments.tmp"); }
@PreDestroy void close() { try { this.tempFileProvider.close(); } catch (IOException e) { SwarmMessages.MESSAGES.errorCleaningUpTempFileProvider(e); } }
/** * * @return * @throws IOException */ private TempFileProvider getTempFileProvider() throws IOException { if (tempFileProvider == null) { tempFileProvider = TempFileProvider.create("temp", Executors.newSingleThreadScheduledExecutor()); } return tempFileProvider; }
/** * Create and mount a zip file into the filesystem, returning a single handle which will unmount and close the file * system when closed. * * @param zipFile the zip file to mount * @param mountPoint the point at which the filesystem should be mounted * @param tempFileProvider the temporary file provider * @return a handle * @throws IOException if an error occurs */ public static Closeable mountZip(File zipFile, VirtualFile mountPoint, TempFileProvider tempFileProvider) throws IOException { boolean ok = false; final TempDir tempDir = tempFileProvider.createTempDir(zipFile.getName()); try { final MountHandle handle = doMount(new JavaZipFileSystem(zipFile, tempDir), mountPoint); ok = true; return handle; } finally { if (!ok) { VFSUtils.safeClose(tempDir); } } }
@PostConstruct void init() { File serverTmp; try { serverTmp = TempFileManager.INSTANCE.newTempDirectory(TEMP_DIR_NAME, ".d"); System.setProperty("jboss.server.temp.dir", serverTmp.getAbsolutePath()); ScheduledExecutorService tempFileExecutor = Executors.newSingleThreadScheduledExecutor(); this.tempFileProvider = TempFileProvider.create(TEMP_DIR_NAME, tempFileExecutor, true); } catch (IOException e) { SwarmMessages.MESSAGES.errorSettingUpTempFileProvider(e); } }
@Override public URL getStreamURL() throws IOException { if (vfsFile.isFile() == true) return vfsFile.toURL(); synchronized (this) { if (streamFile == null) { streamDir = tmpProvider.createTempDir("urlstream"); streamFile = streamDir.getFile(getName()); JarOutputStream jarOut = new JarOutputStream(new FileOutputStream(streamFile)); VirtualJarInputStream jarIn = (VirtualJarInputStream) vfsFile.openStream(); ZipEntry nextEntry = jarIn.getNextEntry(); while (nextEntry != null) { jarOut.putNextEntry(nextEntry); VFSUtils.copyStream(jarIn, jarOut); nextEntry = jarIn.getNextEntry(); } jarOut.close(); jarIn.close(); } } return streamFile.toURI().toURL(); }
@PostConstruct void init() { File serverTmp; try { serverTmp = TempFileManager.INSTANCE.newTempDirectory(TEMP_DIR_NAME, ".d"); System.setProperty("jboss.server.temp.dir", serverTmp.getAbsolutePath()); ScheduledExecutorService tempFileExecutor = Executors.newSingleThreadScheduledExecutor(); this.tempFileProvider = TempFileProvider.create(TEMP_DIR_NAME, tempFileExecutor, true); } catch (IOException e) { SwarmMessages.MESSAGES.errorSettingUpTempFileProvider(e); } }
/** * Create and mount an expanded zip file in a temporary file system, returning a single handle which will unmount and * close the filesystem when closed. * * @param zipFile the zip file to mount * @param mountPoint the point at which the filesystem should be mounted * @param tempFileProvider the temporary file provider * @return a handle * @throws IOException if an error occurs */ public static Closeable mountZipExpanded(File zipFile, VirtualFile mountPoint, TempFileProvider tempFileProvider) throws IOException { boolean ok = false; final TempDir tempDir = tempFileProvider.createTempDir(zipFile.getName()); try { final File rootFile = tempDir.getRoot(); VFSUtils.unzip(zipFile, rootFile); final MountHandle handle = doMount(new RealFileSystem(rootFile), mountPoint, tempDir); ok = true; return handle; } finally { if (!ok) { VFSUtils.safeClose(tempDir); } } }
@PostConstruct void init() { File serverTmp; try { serverTmp = TempFileManager.INSTANCE.newTempDirectory(TEMP_DIR_NAME, ".d"); System.setProperty("jboss.server.temp.dir", serverTmp.getAbsolutePath()); ScheduledExecutorService tempFileExecutor = Executors.newSingleThreadScheduledExecutor(); this.tempFileProvider = TempFileProvider.create(TEMP_DIR_NAME, tempFileExecutor, true); } catch (IOException e) { SwarmMessages.MESSAGES.errorSettingUpTempFileProvider(e); } }
/** * Create and mount a temporary file system, returning a single handle which will unmount and close the filesystem * when closed. * * @param mountPoint the point at which the filesystem should be mounted * @param tempFileProvider the temporary file provider * @return a handle * @throws IOException if an error occurs */ public static Closeable mountTemp(VirtualFile mountPoint, TempFileProvider tempFileProvider) throws IOException { boolean ok = false; final TempDir tempDir = tempFileProvider.createTempDir("tmpfs"); try { final MountHandle handle = doMount(new RealFileSystem(tempDir.getRoot()), mountPoint, tempDir); ok = true; return handle; } finally { if (!ok) { VFSUtils.safeClose(tempDir); } } }