use of java.util.jar.JarInputStream in project Payara by payara.
the class InputJarArchive method getManifest.
/**
* @return the manifest information for this abstract archive
*/
public Manifest getManifest() throws IOException {
if (jarFile != null) {
return jarFile.getManifest();
}
if (parentArchive != null) {
// close the current input stream
if (jarIS != null) {
jarIS.close();
}
// at the beginning of the desired element
if (jarIS == null) {
jarIS = new JarInputStream(parentArchive.jarFile.getInputStream(parentArchive.jarFile.getJarEntry(uri.getSchemeSpecificPart())));
}
Manifest m = jarIS.getManifest();
if (m == null) {
java.io.InputStream is = getEntry(java.util.jar.JarFile.MANIFEST_NAME);
if (is != null) {
m = new Manifest();
m.read(is);
is.close();
}
}
return m;
}
return null;
}
use of java.util.jar.JarInputStream in project Payara by payara.
the class InputJarArchive method getSubArchive.
/**
* @return an Archive for an embedded archive indentified with
* the name parameter
*/
public ReadableArchive getSubArchive(String name) throws IOException {
if (jarFile != null) {
// for now, I only support one level down embedded archives
InputJarArchive ija = new InputJarArchive();
JarEntry je = jarFile.getJarEntry(name);
if (je != null) {
JarInputStream jis = new JarInputStream(new BufferedInputStream(jarFile.getInputStream(je)));
try {
ija.uri = new URI("jar", name, null);
} catch (URISyntaxException e) {
// do nothing
}
ija.jarIS = jis;
ija.parentArchive = this;
return ija;
}
}
return null;
}
use of java.util.jar.JarInputStream in project Payara by payara.
the class MemoryMappedArchive method getJarEntry.
public JarEntry getJarEntry(String name) {
try {
JarInputStream jis = new JarInputStream(new ByteArrayInputStream(file));
JarEntry ze;
while ((ze = jis.getNextJarEntry()) != null) {
if (ze.getName().equals(name)) {
return ze;
}
}
} catch (IOException e) {
return null;
}
return null;
}
use of java.util.jar.JarInputStream in project Payara by payara.
the class MemoryMappedArchive method entries.
private Vector<String> entries(boolean directory) {
Vector entries = new Vector();
try {
JarInputStream jis = new JarInputStream(new ByteArrayInputStream(file));
ZipEntry ze;
while ((ze = jis.getNextEntry()) != null) {
if (ze.isDirectory() == directory) {
entries.add(ze.getName());
}
}
jis.close();
} catch (IOException ioe) {
Logger.getAnonymousLogger().log(Level.WARNING, ioe.getMessage(), ioe);
}
return entries;
}
use of java.util.jar.JarInputStream in project Payara by payara.
the class InstalledLibrariesResolver method getInstalledLibraries.
public static Set<String> getInstalledLibraries(ReadableArchive archive) throws IOException {
Set<String> libraries = new HashSet<String>();
if (archive != null) {
Manifest manifest = archive.getManifest();
// we are looking for libraries only in "applibs" directory, hence strict=false
Set<String> installedLibraries = getInstalledLibraries(archive.getURI().toString(), manifest, false, appLibsDirLibsStore);
libraries.addAll(installedLibraries);
// now check my libraries.
Vector<String> libs = getArchiveLibraries(archive);
if (libs != null) {
for (String libUri : libs) {
JarInputStream jis = null;
try {
InputStream libIs = archive.getEntry(libUri);
if (libIs == null) {
// libIs can be null if reading an exploded archive where directories are also exploded. See FileArchive.getEntry()
continue;
}
jis = new JarInputStream(libIs);
manifest = jis.getManifest();
if (manifest != null) {
// we are looking for libraries only in "applibs" directory, hence strict=false
Set<String> jarLibraries = getInstalledLibraries(archive.getURI().toString(), manifest, false, appLibsDirLibsStore);
libraries.addAll(jarLibraries);
}
} finally {
if (jis != null)
jis.close();
}
}
}
}
return libraries;
}
Aggregations