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); } }
private boolean isEntryPresent(ReadableArchive location, String entry) { boolean entryPresent = false; try { entryPresent = location.exists(entry); } catch (IOException e) { // ignore } return entryPresent; }
@Override public String getDefaultApplicationName(ReadableArchive archive) { String appName = archive.getName(); int lastDot = appName.lastIndexOf('.'); if (lastDot != -1) { appName = appName.substring(0, lastDot); } return appName; }
public static String getApplicationName(DeploymentContext context) { String applicationName = null; ReadableArchive parentArchive = context.getSource().getParentArchive(); if (parentArchive != null) { applicationName = parentArchive.getName(); }else{ applicationName = context.getSource().getName(); } return applicationName; }
/** * 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(); }
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(); }
@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); }
DeploymentContext context) throws IOException { Enumeration<String> e = source.entries(); while (e.hasMoreElements()) { String entryName = e.nextElement(); InputStream is = new BufferedInputStream(source.getEntry(entryName)); OutputStream os = null; try { os = target.putNextEntry(entryName); FileUtils.copy(is, os, source.getEntrySize(entryName)); } finally { if (os!=null) { target.closeEntry(); is.close(); Manifest m = source.getManifest(); if (m!=null) { OutputStream os = target.putNextEntry(JarFile.MANIFEST_NAME);
int crFlags = ClassReader.SKIP_CODE | ClassReader.SKIP_DEBUG | ClassReader.SKIP_FRAMES; Enumeration<String> entries = archive.entries(); while (entries.hasMoreElements()) { String entryName = entries.nextElement(); if (entryName.endsWith(".class")) { InputStream is = archive.getEntry(entryName); try { ClassReader cr = new ClassReader(is); cr.accept(this, crFlags); } finally { is.close(); ReadableArchive jarSubArchive = null; try { jarSubArchive = archive.getSubArchive(entryName); Enumeration<String> jarEntries = jarSubArchive.entries(); while (jarEntries.hasMoreElements()) { String jarEntryName = jarEntries.nextElement(); if (jarEntryName.endsWith(".class")) { InputStream is = jarSubArchive.getEntry(jarEntryName); try { ClassReader cr = new ClassReader(is); cr.accept(this, crFlags); } finally { is.close();
ReadableArchive source = archiveFactory.openArchive(moduleDir); WritableArchive target = archiveFactory.createArchive("jar", tempJar); Enumeration<String> e = source.entries(); while (e.hasMoreElements()) { String entryName = e.nextElement(); if (isSigFile(entryName)) { logger.log(Level.INFO, "Excluding signature file: " InputStream sis = source.getEntry(entryName); if (sis != null) { InputStream is = new BufferedInputStream(sis); try { os = target.putNextEntry(entryName); FileUtils.copy(is, os, source.getEntrySize(entryName)); } finally { if (os!=null) { target.closeEntry(); Manifest m = source.getManifest(); if (m!=null) { processManifest(m, moduleName); source.close(); target.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; }
throws IOException { Vector entriesAdded = new Vector(); for (ModuleDescriptor aModule : a.getModules()) { entriesAdded.add(aModule.getArchiveUri()); ReadableArchive subSource = source.getSubArchive(aModule.getArchiveUri()); WritableArchive subTarget = target.createSubArchive(aModule.getArchiveUri()); Archivist newArchivist = archivistFactory.get().getArchivist(aModule.getModuleType()); ReadableArchive subArchive = archiveFactory.openArchive(subTarget.getURI()); subSource.setParentArchive(subArchive); newArchivist.copyInto(subSource, subTarget, overwriteManifest); target.closeEntry(subTarget); String subModulePath = subSource.getURI().getSchemeSpecificPart(); String parentPath = source.getURI().getSchemeSpecificPart(); if (subModulePath.startsWith(parentPath)) { subModulePath = subModulePath.substring(parentPath.length()+File.separator.length()); for (Enumeration subEntries = subSource.entries();subEntries.hasMoreElements();) { String anEntry = (String) subEntries.nextElement(); entriesAdded.add(subModulePath + "/" + anEntry); subSource.close(); subArchive.close();
throws IOException { Vector entriesAdded = new Vector(); for (ModuleDescriptor aModule : a.getModules()) { entriesAdded.add(aModule.getArchiveUri()); ReadableArchive subSource = source.getSubArchive(aModule.getArchiveUri()); WritableArchive subTarget = target.createSubArchive(aModule.getArchiveUri()); Archivist newArchivist = archivistFactory.get().getPrivateArchivistFor(aModule.getModuleType()); newArchivist.copyInto(subSource, subTarget, overwriteManifest); target.closeEntry(subTarget); String subModulePath = subSource.getURI().getSchemeSpecificPart(); String parentPath = source.getURI().getSchemeSpecificPart(); if (subModulePath.startsWith(parentPath)) { subModulePath = subModulePath.substring(parentPath.length()+File.separator.length()); for (Enumeration subEntries = subSource.entries();subEntries.hasMoreElements();) { String anEntry = (String) subEntries.nextElement(); entriesAdded.add(subModulePath + "/" + anEntry); subSource.close();
String compatProp = context.getAppProps().getProperty( DeploymentProperties.COMPATIBILITY); compatProp = gfEjbJarXMLParser.getCompatibilityValue(); if (compatProp != null) { context.getAppProps().put( DeploymentProperties.COMPATIBILITY, compatProp); compatProp = sunEjbJarXMLParser.getCompatibilityValue(); if (compatProp != null) { context.getAppProps().put( DeploymentProperties.COMPATIBILITY, compatProp); cloader.addURL(context.getSource().getURI().toURL()); cloader.addURL(context.getScratchDir("ejb").toURI().toURL());
for (Enumeration alreadyWritten = out.entries(); alreadyWritten.hasMoreElements();) { String elementName = (String) alreadyWritten.nextElement(); filesToSkip.add(elementName); for (ModuleDescriptor aModule : descriptor.getModules()) { Archivist subArchivist = archivistFactory.get().getArchivist(aModule.getModuleType()); subArchivist.initializeContext(this); subArchivist.setModuleDescriptor(aModule); if(DOLUtils.getDefaultLogger().isLoggable(Level.FINE)) { DOLUtils.getDefaultLogger().info("Write " + aModule.getArchiveUri() + " with " + subArchivist); WritableArchive internalJar = out.createSubArchive(aModule.getArchiveUri()); try (InputStream is = in.getEntry(aModule.getArchiveUri())){ if (in instanceof WritableArchive) { subArchivist.setArchiveUri(internalJar.getURI().getSchemeSpecificPart()); } else { tmpFile = getTempFile(path);
appRegisteredName = application.getRegistrationName(); deploymentContextProps.setProperty(APPLICATION_NAME, appRegisteredName); appRegisteredName = deploymentContextProps.getProperty(APPLICATION_NAME); ctx.getSource().getURI().getSchemeSpecificPart() + File.separator;
protected void handleEntry(String name, Entry entry, Logger logger /*ignored*/, EntryTask entryTask) throws IOException { InputStream is = null; try { try { is = archive.getEntry(name); if (is==null) { alogger.log(Level.SEVERE, KernelLoggerInfo.invalidInputStream, name); return; } entryTask.on(entry, is); } catch (Exception e) { alogger.log(Level.SEVERE, KernelLoggerInfo.exceptionWhileParsing, new Object[] { entry.name, archive.getURI(), entry.size, e}); } } finally { if (is!=null) is.close(); } }
classpath.append(ctx.getSourceDir().toURI().getPath()); classpath.append(File.pathSeparator); classpath.append(ctx.getScratchDir("ejb").toURI().getPath()); classpath.append(File.pathSeparator); if (!app.isVirtual()) { ReadableArchive parentArchive = ctx.getSource().getParentArchive(); String compatProp = ctx.getAppProps().getProperty( DeploymentProperties.COMPATIBILITY); parentArchive.getURI()), app.getLibraryDirectory(), compatProp); classpath.append(url.toURI().getPath()); classpath.append(File.pathSeparator);
Map<String, Properties> modulePropsMap = app.getModulePropertiesMap(); ApplicationConfigInfo savedAppConfig = new ApplicationConfigInfo(app); URI uri = new URI(app.getLocation()); File file = new File(uri); archive = archiveFactory.openArchive(file); appProps.putAll(contextProps); savedAppConfig.store(appProps); try { if (archive != null) { archive.close();