@Override public void close() throws IOException { for (ReadableArchive ra : archives) { ra.close(); } }
public void close() throws IOException { delegate.close(); }
/** *Closes the specified archive, returning any IOException encountered in the process. *@param archive the archive to be closed *@return IOException describing any error; null if the close succeeded */ private IOException closeArchive(ReadableArchive archive) { IOException errorIOE = null; if (archive != null) { try { archive.close(); } catch (IOException ioe) { errorIOE = ioe; } } return errorIOE; }
/** *Closes the specified archive, returning any IOException encountered in the process. *@param archive the archive to be closed *@return IOException describing any error; null if the close succeeded */ private IOException closeArchive(ReadableArchive archive) { IOException errorIOE = null; if (archive != null) { try { archive.close(); } catch (IOException ioe) { errorIOE = ioe; } } return errorIOE; }
private void releaseCount() throws IOException { int release = releaseCount.decrementAndGet(); if (release==0) { archive.close(); if (parent!=null) { parent.releaseCount(); } } }
/** * writes the content of an archive to a JarFile * * @param out jar output stream to write to */ protected void writeContents(WritableArchive out) throws IOException { ReadableArchive in = archiveFactory.openArchive(new File(path)); writeContents(in, out); in.close(); }
/** * extract a entry of this archive to a file * * @param entryName entry name * @param out file to copy the entry into */ public void extractEntry(String entryName, File out) throws IOException { ReadableArchive archive = archiveFactory.openArchive(new File(path)); InputStream is = archive.getEntry(entryName); OutputStream os = new BufferedOutputStream(new FileOutputStream(out)); ArchivistUtils.copy(new BufferedInputStream(is), os); archive.close(); }
/** * saves the archive * * @param outPath the file to use */ public void write(String outPath) throws IOException { ReadableArchive in = archiveFactory.openArchive(new File(path)); write(in, outPath); in.close(); }
/** * saves the archive * * @param outPath the file to use */ public void write(String outPath) throws IOException { ReadableArchive in = archiveFactory.openArchive(new File(path)); write(in, outPath); in.close(); }
/** * writes the content of an archive to a JarFile * * @param out jar output stream to write to */ protected void writeContents(WritableArchive out) throws IOException { ReadableArchive in = archiveFactory.openArchive(new File(path)); writeContents(in, out); in.close(); }
protected boolean scanForPURootsInLibDir(ReadableArchive parentArchive, String libLocation) { boolean puRootPresent = false; if (libLocation != null && !libLocation.isEmpty()) { // if an application disables lib dir by specifying <library-directory></library-directory>, do not attempt to scan lib dir Enumeration<String> entries = parentArchive.entries(libLocation); while (entries.hasMoreElements() && !puRootPresent) { String entryName = entries.nextElement(); if (entryName.endsWith(JAR_SUFFIX) && // a jar in lib dir entryName.indexOf(SEPERATOR_CHAR, libLocation.length() + 1 ) == -1 ) { // && not WEB-INf/lib/foo/bar.jar try { ReadableArchive jarInLib = parentArchive.getSubArchive(entryName); puRootPresent = isEntryPresent(jarInLib, META_INF_PERSISTENCE_XML); jarInLib.close(); } catch (IOException e) { // Something went wrong while reading the jar. Do not attempt to scan it } // catch } // if (entryName.endsWith(JAR_SUFFIX)) } // while } return puRootPresent; }
/** * open a new archive file using a file descriptor * * @param file the archive to open */ public T open(File file) throws IOException, SAXException { path = file.getAbsolutePath(); ReadableArchive archive = archiveFactory.openArchive(file); T descriptor = open(archive); archive.close(); // attempt validation validate(null); return descriptor; }
/** * open a new archive file using a file descriptor * * @param file the archive to open */ public T open(File file) throws IOException, SAXParseException { path = file.getAbsolutePath(); ReadableArchive archive = archiveFactory.openArchive(file); T descriptor = open(archive); archive.close(); // attempt validation validate(null); return descriptor; }
/** * Open a jar file and return an application object for the modules contained * in the archive/directory. If the archive/directory is a standalone module, this API will * create an empty application and add the standalone module to it * * @param archivist to use to open the archive file * @param jarFile the archive file * @param handleRuntimeInfo set to true to read configuration deployment descriptors * @return the application object */ public Application openArchive(Archivist archivist, URI jarFile, boolean handleRuntimeInfo) throws IOException, SAXException { // never read the runtime deployment descriptor before the // module type is found and the application object created ReadableArchive archive = archiveFactory.openArchive(jarFile); Application application = openArchive(archivist, archive, handleRuntimeInfo); archive.close(); return application; }
/** * Open a jar file and return an application object for the modules contained * in the archive/directory. If the archive/directory is a standalone module, this API will * create an empty application and add the standalone module to it * * @param archivist to use to open the archive file * @param jarFile the archive file * @param handleRuntimeInfo set to true to read configuration deployment descriptors * @return the application object */ public Application openArchive(Archivist archivist, URI jarFile, boolean handleRuntimeInfo) throws IOException, SAXParseException { // never read the runtime deployment descriptor before the // module type is found and the application object created ReadableArchive archive = archiveFactory.openArchive(jarFile); Application application = openArchive(archivist, archive, handleRuntimeInfo); archive.close(); return application; }
public BeanDeploymentArchiveImpl(ReadableArchive archive, Collection<com.sun.enterprise.deployment.EjbDescriptor> ejbs, DeploymentContext ctx, String bdaID) { this.beanClasses = new ArrayList<Class<?>>(); this.beanClassNames = new ArrayList<String>(); this.moduleClasses = new ArrayList<Class<?>>(); this.moduleClassNames = new ArrayList<String>(); this.beansXmlURLs = new CopyOnWriteArrayList<URL>(); this.archive = archive; if (bdaID == null) { this.id = archive.getName(); } else { this.id = bdaID; } this.friendlyId = this.id; this.ejbDescImpls = new HashSet<EjbDescriptor<?>>(); this.beanDeploymentArchives = new ArrayList<BeanDeploymentArchive>(); this.context = ctx; populate(ejbs); populateEJBsForThisBDA(ejbs); try { this.archive.close(); } catch (Exception e) { } this.archive = null; // This assigns moduleClassLoaderForBDA getClassLoader(); }
subSource.close();
public void copyAnEntry(ReadableArchive in, WritableArchive out, String entryName) throws IOException { InputStream is = null; InputStream is2 = null; ReadableArchive in2 = archiveFactory.openArchive(out.getURI()); try { is = in.getEntry(entryName); is2 = in2.getEntry(entryName); if (is != null && is2 == null) { OutputStream os = out.putNextEntry(entryName); ArchivistUtils.copyWithoutClose(is, os); } } finally { /* *Close any streams that were opened. */ in2.close(); if (is != null) { is.close(); } if (is2 != null) { is2.close(); } out.closeEntry(); } }
public void copyAnEntry(ReadableArchive in, WritableArchive out, String entryName) throws IOException { InputStream is = null; InputStream is2 = null; ReadableArchive in2 = archiveFactory.openArchive(out.getURI()); try { is = in.getEntry(entryName); is2 = in2.getEntry(entryName); if (is != null && is2 == null) { OutputStream os = out.putNextEntry(entryName); ArchivistUtils.copyWithoutClose(is, os); } } finally { /* *Close any streams that were opened. */ in2.close(); if (is != null) { is.close(); } if (is2 != null) { is2.close(); } out.closeEntry(); } }
public void saveRuntimeInfo(File output) throws IOException { // if output file is null, we overwrite the current archive... File outputFile = output; if (outputFile == null) { outputFile = getTempFile(path); } // copy all entries from source to target except the // runtime descriptor file WritableArchive out = archiveFactory.createArchive(outputFile); ReadableArchive in = archiveFactory.openArchive(new File(path)); Vector skipFiles = new Vector(); skipFiles.add(getRuntimeDeploymentDescriptorPath()); copyInto(in, out, skipFiles); in.close(); // now save the runtime deployment descriptor... OutputStream os = out.putNextEntry(getRuntimeDeploymentDescriptorPath()); writeRuntimeDeploymentDescriptors(os); out.closeEntry(); out.close(); // if we overwrote the old archive, need to rename the tmp now if (output == null) { ReadableArchive finalArchive = archiveFactory.openArchive(new File(path)); finalArchive.delete(); ReadableArchive tmpArchive = archiveFactory.openArchive(outputFile); tmpArchive.renameTo(path); } }