@Override public Enumeration<String> entries(String prefix) { final LinkedHashSet<String> enums = new LinkedHashSet<String>(); for (ReadableArchive ra : archives) { for (Enumeration<String> e = ra.entries(prefix); e.hasMoreElements();) { enums.add(e.nextElement()); } } return Collections.enumeration(enums); }
@Override public Enumeration<String> entries() { /* * Guard against the same entry appearing in multiple archives. * Only one will be returned so only save the name once. */ final LinkedHashSet<String> enums = new LinkedHashSet<String>(); for (ReadableArchive ra : archives) { for (Enumeration<String> e = ra.entries(); e.hasMoreElements(); ) { enums.add(e.nextElement()); } } return Collections.enumeration(enums); }
public Enumeration<String> entries(String prefix) { Enumeration<String> original = delegate.entries(prefix); Vector<String> results = new Vector<String>(); while (original.hasMoreElements()) { String entryName = original.nextElement(); if (filter.accept(delegate, entryName)) { results.add(entryName); } } return results.elements(); }
public boolean hasAnnotationInArchive(ReadableArchive archive) throws IOException { Enumeration<String> entries = archive.entries(); while (entries.hasMoreElements()) { String entryName = entries.nextElement(); if (entryName.endsWith(".class")) { if (containsAnnotation(archive, entryName)) { return true; } } } return false; }
public Enumeration<String> entries() { Enumeration<String> original = delegate.entries(); Vector<String> results = new Vector<String>(); while (original.hasMoreElements()) { String entryName = original.nextElement(); if (filter.accept(delegate, entryName)) { results.add(entryName); } } return results.elements(); }
public boolean hasAnnotationInArchive(ReadableArchive archive) throws IOException { Enumeration<String> entries = archive.entries(); while (entries.hasMoreElements()) { String entryName = entries.nextElement(); if (entryName.endsWith(".class")) { if (containsAnnotation(archive, entryName)) { return true; } } } return false; }
/** * @return a list of libraries included in the archivist */ private static Vector getArchiveLibraries(ReadableArchive archive) { Enumeration<String> entries = archive.entries(); if (entries == null) return null; Vector libs = new Vector(); while (entries.hasMoreElements()) { String entryName = entries.nextElement(); if (entryName.indexOf('/') != -1) { continue; // not on the top level } if (entryName.endsWith(".jar")) { libs.add(entryName); } } return libs; }
private void collectJarInfo(ReadableArchive archive, boolean isBeanArchive, boolean hasBeansXml) throws IOException, ClassNotFoundException { if (logger.isLoggable(FINE)) { logger.log(FINE, CDILoggerInfo.COLLECTING_JAR_INFO, new Object[]{archive.getURI()}); } Enumeration<String> entries = archive.entries(); while (entries.hasMoreElements()) { String entry = entries.nextElement(); handleEntry(archive, entry, isBeanArchive, hasBeansXml); } }
public void copyExtraElements(ReadableArchive in, WritableArchive out) throws IOException { Enumeration entries = in.entries(); if (entries != null) { for (; entries.hasMoreElements();) { String anEntry = (String) entries.nextElement(); if (anEntry.endsWith(PERSISTENCE_DD_ENTRY)) { // Don't copy persistence.xml file because they are some times // bundled inside war/WEB-INF/lib/*.jar and hence we always // read them from exploded directory. // see Integration Notice #80587 continue; } if (anEntry.indexOf(WSDL) != -1 || anEntry.indexOf(XML) != -1 || anEntry.indexOf(XSD) != -1) { copyAnEntry(in, out, anEntry); } } } }
public void copyExtraElements(ReadableArchive in, WritableArchive out) throws IOException { Enumeration entries = in.entries(); if (entries != null) { for (; entries.hasMoreElements();) { String anEntry = (String) entries.nextElement(); if (anEntry.endsWith(PERSISTENCE_DD_ENTRY)) { // Don't copy persistence.xml file because they are some times // bundled inside war/WEB-INF/lib/*.jar and hence we always // read them from exploded directory. // see Integration Notice #80587 continue; } if (anEntry.indexOf(WSDL) != -1 || anEntry.indexOf(XML) != -1 || anEntry.indexOf(XSD) != -1) { copyAnEntry(in, out, anEntry); } } } }
public MemoryMappedArchive(ReadableArchive source) throws IOException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); JarOutputStream jos = new JarOutputStream(baos); for (Enumeration elements = source.entries();elements.hasMoreElements();) { String elementName = (String) elements.nextElement(); InputStream is = source.getEntry(elementName); jos.putNextEntry(new ZipEntry(elementName)); ArchivistUtils.copyWithoutClose(is, jos); is.close(); jos.flush(); jos.closeEntry(); } jos.close(); file = baos.toByteArray(); }
/** * Read the runtime deployment descriptors (can contained in one or * many file) from a deployment plan archive, set the corresponding * information in the passed descriptor. */ public void readRuntimeDDFromDeploymentPlan( ReadableArchive planArchive, T descriptor) throws IOException, SAXParseException { // if we are not supposed to handle runtime info, just pass String runtimeDDPath = getRuntimeDeploymentDescriptorPath(); if (runtimeDDPath == null || planArchive == null) { return; } // list of entries in the deployment plan Vector dpEntries = new Vector(); for (Enumeration e = planArchive.entries(); e.hasMoreElements();) { dpEntries.add(e.nextElement()); } String entry = runtimeDDPath.substring(runtimeDDPath.lastIndexOf('/') + 1); if (dpEntries.contains(entry)) { readRuntimeDDFromDeploymentPlan(entry, planArchive, descriptor); } }
private boolean scanForPURRootsInEarRoot(DeploymentContext ctx, Set<ModuleDescriptor<BundleDescriptor>> modules) { boolean puPresentInEarRoot = false; Enumeration<String> entriesInEar = ctx.getSource().entries(); while(entriesInEar.hasMoreElements() && !puPresentInEarRoot) { String entry = entriesInEar.nextElement(); puPresentInEarRoot = PersistenceArchivist.isProbablePuRootJar(entry) && !EARBasedPersistenceHelper.isComponentJar(entry, modules); } return puPresentInEarRoot; } }
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; }
private void collectRarInfo(ReadableArchive archive) throws IOException, ClassNotFoundException { if (logger.isLoggable(FINE)) { logger.log(FINE, CDILoggerInfo.COLLECTING_RAR_INFO, new Object[]{archive.getURI()}); } Enumeration<String> entries = archive.entries(); while (entries.hasMoreElements()) { String entry = entries.nextElement(); if (entry.endsWith(JAR_SUFFIX)) { ReadableArchive jarArchive = archive.getSubArchive(entry); collectJarInfo(jarArchive, true, true); } else { handleEntry(archive, entry, true, true); } } }
public static boolean isWebArchive(ReadableArchive archive) { try { if (Util.getURIName(archive.getURI()).endsWith(WAR_EXTENSION)) { return true; } if (archive.exists(WEB_INF)) { return true; } Enumeration<String> entries = archive.entries(); while (entries.hasMoreElements()) { String entryName = entries.nextElement(); if (entryName.endsWith(JSP_SUFFIX)) { return true; } } return false; } catch (IOException ioe) { // ignore } return false; }
@Override public void onSelectedEntries(ArchiveAdapter.Selector selector, EntryTask entryTask, final Logger logger ) throws IOException { Enumeration<String> entries = archive.entries(); while (entries.hasMoreElements()) { final String name = entries.nextElement(); Entry entry = new Entry(name, archive.getEntrySize(name), false); if (selector.isSelected(entry)) { handleEntry(name, entry, logger, entryTask); } // check for non exploded jars. if (name.endsWith(".jar")) { handleJar(name, logger); } } if (logger.isLoggable(level)) { logger.log(level, "Finished parsing " + this.uri); } }
@Override public boolean handles(ReadableArchive archive) { try { if (Util.getURIName(archive.getURI()).endsWith(WAR_EXTENSION)) { return true; } if (archive.exists(WEB_INF)) { return true; } if (archive.exists(AVATAR)) { return true; } Enumeration<String> entries = archive.entries(); while (entries.hasMoreElements()) { String entryName = entries.nextElement(); if (entryName.endsWith(JSP_SUFFIX)) { return true; } } return false; } catch (IOException ioe) { // ignore } return false; }
/** * Gets probable persitence roots from given parentArchive using given subArchiveRootScanner * @param parentArchive the parentArchive within which probable persitence roots need to be scanned * @param subArchivePURootScanner the scanner instance used for the scan * @see com.sun.enterprise.deployment.archivist.EarPersistenceArchivist.SubArchivePURootScanner * @return Map of puroot path to probable puroot archive. */ protected static Map<String, ReadableArchive> getProbablePersistenceRoots(ReadableArchive parentArchive, SubArchivePURootScanner subArchivePURootScanner) { Map<String, ReadableArchive> probablePersitenceArchives = new HashMap<String, ReadableArchive>(); ReadableArchive archiveToScan = subArchivePURootScanner.getSubArchiveToScan(parentArchive); if(archiveToScan != null) { // The subarchive exists Enumeration<String> entries = archiveToScan.entries(); String puRootPrefix = subArchivePURootScanner.getPurRootPrefix(); while(entries.hasMoreElements()) { String entry = entries.nextElement(); if(subArchivePURootScanner.isProbablePuRootJar(entry)) { ReadableArchive puRootArchive = getSubArchive(archiveToScan, entry, false /* expect entry to be present */); if(puRootArchive != null) { String puRoot = puRootPrefix + entry; probablePersitenceArchives.put(puRoot, puRootArchive); } } } } return probablePersitenceArchives; }
/** * copy all contents of a jar file to a new jar file except * for all the deployment descriptors files * * @param in jar file * @param out jar file * @param ignoreList vector of entry name to not copy from to source jar file */ protected void copyJarElements(ReadableArchive in, WritableArchive out, Vector ignoreList) throws IOException { Enumeration entries = in.entries(); if (entries != null) { for (; entries.hasMoreElements();) { String anEntry = (String) entries.nextElement(); if (ignoreList == null || !ignoreList.contains(anEntry)) { InputStream is = in.getEntry(anEntry); if (is != null) { OutputStream os = out.putNextEntry(anEntry); ArchivistUtils.copyWithoutClose(is, os); is.close(); } out.closeEntry(); } } } }