/** @return true of given path is probable pu root */ public static boolean isProbablePuRootJar(String path) { return isJarEntry(path) && checkIsInRootOfArchive(path); }
@Override public Object open(Archivist main, ReadableArchive archive, RootDeploymentDescriptor descriptor) throws IOException, SAXException { String puRoot = getPuRoot(archive); readPersistenceDeploymentDescriptor(main, archive, puRoot, descriptor); return null; // return null so that the descritor does not get added twice to extensions }
boolean isProbablePuRootJar(String jarName) { // all jars in root of subarchive are probable pu roots boolean probablePuRootJar = PersistenceArchivist.isProbablePuRootJar(jarName); if(!probablePuRootJar && isJarEntry(jarName) ) { // A jar that is not in root of archive. Log that it will not be scanned if (deplLogger.isLoggable(Level.FINE)) { deplLogger.logp(Level.FINE, "PersistenceArchivist", "readPersistenceDeploymentDescriptors", "skipping {0} as it exists inside a directory in {1}.", new Object[]{jarName, getPathOfSubArchiveToScan()}); } } return probablePuRootJar; } }
/** * Adds candidate persistence archives from the EAR's library directory * and, if selected, from the top-level. * @param earArchive ReadableArchive for the EAR * @param app application's descriptor * @param includeTopLevel whether or not to include top-level JARs for scanning * @param probablePersistentArchives map to which new candidates will be added */ protected static void addLibraryAndTopLevelCandidates(final ReadableArchive earArchive, final Application app, final boolean includeTopLevel, final Map<String,ReadableArchive> probablePersistentArchives) { //Get probable archives from root of the ear if (includeTopLevel) { SubArchivePURootScanner earRootScanner = new EARTopLevelJARPURootScanner(app); probablePersistentArchives.putAll( PersistenceArchivist.getProbablePersistenceRoots(earArchive, earRootScanner)); } //Geather all jars in lib of ear SubArchivePURootScanner libPURootScannerScanner = new EARLibraryPURootScanner(app); probablePersistentArchives.putAll( PersistenceArchivist.getProbablePersistenceRoots(earArchive, libPURootScannerScanner)); }
/** * 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; }
boolean isProbablePuRootJar(String jarName) { // all jars in root of subarchive are probable pu roots boolean probablePuRootJar = PersistenceArchivist.isProbablePuRootJar(jarName); if(!probablePuRootJar && isJarEntry(jarName) ) { // A jar that is not in root of archive. Log that it will not be scanned if (st_logger.isLoggable(Level.FINE)) { st_logger.logp(Level.FINE, "PersistenceArchivist", "readPersistenceDeploymentDescriptors", "skipping {0} as it exists inside a directory in {1}.", new Object[]{jarName, getPathOfSubArchiveToScan()}); } } return probablePuRootJar; } }
/** * Adds candidate persistence archives from the EAR's library directory * and, if selected, from the top-level. * @param earArchive ReadableArchive for the EAR * @param app application's descriptor * @param includeTopLevel whether or not to include top-level JARs for scanning * @param probablePersistentArchives map to which new candidates will be added */ protected static void addLibraryAndTopLevelCandidates(final ReadableArchive earArchive, final Application app, final boolean includeTopLevel, final Map<String,ReadableArchive> probablePersistentArchives) { //Get probable archives from root of the ear if (includeTopLevel) { SubArchivePURootScanner earRootScanner = new EARTopLevelJARPURootScanner(app); probablePersistentArchives.putAll( PersistenceArchivist.getProbablePersistenceRoots(earArchive, earRootScanner)); } //Geather all jars in lib of ear SubArchivePURootScanner libPURootScannerScanner = new EARLibraryPURootScanner(app); probablePersistentArchives.putAll( PersistenceArchivist.getProbablePersistenceRoots(earArchive, libPURootScannerScanner)); }
/** * 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; }
@Override public Object open(Archivist main, ReadableArchive archive, RootDeploymentDescriptor descriptor) throws IOException, SAXParseException { String puRoot = getPuRoot(archive); readPersistenceDeploymentDescriptor(main, archive, puRoot, descriptor); return null; // return null so that the descritor does not get added twice to extensions }
/** @return true of given path is probable pu root */ public static boolean isProbablePuRootJar(String path) { return isJarEntry(path) && checkIsInRootOfArchive(path); }
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; } }