@Override public String toString() { String lineSep = System.getProperty("line.separator"); StringBuilder result = new StringBuilder(); result.append(this.getClass().getName() + ": " + lineSep); result.append(" isJWS: " + isJWS); result.append(" archive file: " + appClientArchive.getURI().toASCIIString() + lineSep); result.append(" archive type: " + appClientArchive.getClass().getName() + lineSep); result.append(" archivist type: " + appClientArchivist.getClass().getName() + lineSep); result.append(" main class to be run: " + mainClassNameToRun + lineSep); result.append(" temporary archive directory: " + appClientArchive.getURI() + lineSep); result.append(" class loader type: " + getClassLoader().getClass().getName() + lineSep); return result.toString(); }
/** * Returns the classpath URIs for this archive. * * @param archive file * @return classpath URIs for this archive */ @Override public List<URI> getClassPathURIs(ReadableArchive archive) { List<URI> uris = super.getClassPathURIs(archive); try { File archiveFile = new File(archive.getURI()); if (archiveFile.exists() && archiveFile.isDirectory()) { uris.add(new URI(archive.getURI().toString() + "WEB-INF/classes/")); File webInf = new File(archiveFile, "WEB-INF"); File webInfLib = new File(webInf, "lib"); if (webInfLib.exists()) { uris.addAll(ASClassLoaderUtil.getLibDirectoryJarURIs(webInfLib)); } } } catch (Exception e) { logger.log(Level.WARNING, e.getMessage(), e); } return uris; }
/** * This scanner will scan the archiveFile for annotation processing. * * @param readableArchive the archive to process * @param webBundleDesc existing bundle descriptor to add to * @param classLoader classloader to load archive classes with. */ @Override public void process( ReadableArchive readableArchive, WebBundleDescriptor webBundleDesc, ClassLoader classLoader, Parser parser) throws IOException { this.archiveFile = new File(readableArchive.getURI()); this.classLoader = classLoader; setParser(parser); if (AnnotationUtils.getLogger().isLoggable(Level.FINE)) { AnnotationUtils.getLogger().fine("archiveFile is " + archiveFile); AnnotationUtils.getLogger().fine("webBundle is " + webBundleDesc); AnnotationUtils.getLogger().fine("classLoader is " + classLoader); } if (!archiveFile.isDirectory()) { // on client side return; } if (isScanOtherLibraries()) { addLibraryJars(webBundleDesc, readableArchive); calculateResults(); return; } File webinf = new File(archiveFile, "WEB-INF"); if (webBundleDesc instanceof WebFragmentDescriptor) { WebFragmentDescriptor webFragmentDesc = (WebFragmentDescriptor) webBundleDesc; File lib = new File(webinf, "lib"); if (lib.exists()) { File jarFile = new File(lib, webFragmentDesc.getJarName()); if (jarFile.exists()) { // support exploded jar file if (jarFile.isDirectory()) { addScanDirectory(jarFile); } else { addScanJar(jarFile); } } } } else { File classes = new File(webinf, "classes"); if (classes.exists()) { addScanDirectory(classes); } scanXmlDefinedClassesIfNecessary(webBundleDesc); } calculateResults(); }
public void postConstruct() { Archivist archivist = archivistFactory.getArchivist(ModuleType.CAR.toString(), getClassLoader()); if (!(archivist instanceof AppClientArchivist)) { throw new IllegalArgumentException( "expected an app client module but " + appClientArchive.getURI().toASCIIString() + " was recognized by " + archivist.getClass().getName()); } appClientArchivist = (AppClientArchivist) archivist; setDescriptor(appClientArchivist.getDescriptor()); }
WebXmlParser(ReadableArchive archive) throws XMLStreamException, IOException { if (archive.exists(getXmlFileName())) { try (InputStream is = archive.getEntry(getXmlFileName())) { init(is); } catch (Throwable t) { String msg = localStrings.getLocalString( "web.deployment.exception_parsing_webxml", "Error in parsing {0} for archive [{1}]: {2}", getXmlFileName(), archive.getURI(), t.getMessage()); throw new RuntimeException(msg); } } }
/** * Reads persistence.xml from spec defined pu roots of an ear. Spec defined pu roots are - (1)Non * component jars in root of ear (2)jars in lib of ear */ @Override public Object open( Archivist main, ReadableArchive earArchive, final RootDeploymentDescriptor descriptor) throws IOException, SAXParseException { if (deplLogger.isLoggable(Level.FINE)) { deplLogger.logp( Level.FINE, "EarArchivist", "readPersistenceDeploymentDescriptors", "archive = {0}", earArchive.getURI()); } Map<String, ReadableArchive> probablePersitenceArchives = new HashMap<String, ReadableArchive>(); try { if (!(descriptor instanceof Application)) { return null; } final Application app = Application.class.cast(descriptor); // TODO: need to compute includeRoot, not hard-code it, in the next invocation. The flag // should be set to true if operating in v2 compatibility mode false otherwise. // Check with Hong how to get hold of the flag here? EARBasedPersistenceHelper.addLibraryAndTopLevelCandidates( earArchive, app, true /* includeRoot */, probablePersitenceArchives); for (Map.Entry<String, ReadableArchive> pathToArchiveEntry : probablePersitenceArchives.entrySet()) { readPersistenceDeploymentDescriptor( main, pathToArchiveEntry.getValue(), pathToArchiveEntry.getKey(), descriptor); } } finally { for (Archive subArchive : probablePersitenceArchives.values()) { subArchive.close(); } } return null; }