Methods Summary |
---|
public void | close()Closes the current jar file
if (jarFile!=null) {
jarFile.close();
jarFile=null;
}
|
public void | closeEntry()Closes the output jar file entry
// nothing to do
|
public void | closeEntry(AbstractArchive sub)Closes the output sub archive entry
// nothing to do...
|
public boolean | delete()Deletes the underlying jar file
File f = new File(archiveUri);
if (f.exists()) {
return FileUtils.deleteFile(f);
}
return false;
|
public java.util.Enumeration | entries()
// Deployment Plan are organized flatly,
if (elements==null) {
synchronized(this) {
elements = new Vector();
for (Enumeration e = jarFile.entries();e.hasMoreElements();) {
ZipEntry ze = (ZipEntry) e.nextElement();
if (!ze.isDirectory() && !ze.getName().equals(
JarFile.MANIFEST_NAME)) {
elements.add(ze.getName());
}
}
}
}
Vector entries = new Vector();
for (Enumeration e = elements.elements();e.hasMoreElements();) {
String entryName = (String) e.nextElement();
String mangledName = entryName;
String prefix = "META-INF/";
if (entryName.indexOf("sun-web.xml")!=-1) {
prefix = "WEB-INF/";
}
if (subArchiveUri != null && entryName.startsWith(subArchiveUri)) {
mangledName = mangledName.substring(subArchiveUri.length()+1);
}
if (entryName.endsWith(".dbschema")) {
mangledName = mangledName.replaceAll("#", "/");
} else {
mangledName = prefix + mangledName;
}
if (subArchiveUri==null) {
// top level archive
if ((entryName.indexOf(".jar.")!=-1) ||
(entryName.indexOf(".war.")!=-1) ||
(entryName.indexOf(".rar."))!=-1) {
// this element is in a sub archive
continue;
}
entries.add(mangledName);
} else {
// this is a sub archive
if (entryName.startsWith(subArchiveUri)) {
entries.add(mangledName);
}
}
}
return entries.elements();
|
public java.util.Enumeration | entries(java.util.Enumeration embeddedArchives)
return entries();
|
public boolean | exists()
File f = new File(archiveUri);
return f.exists();
|
public long | getArchiveSize()Get the size of the archive
if(getArchiveUri() == null) {
return -1;
}
File tmpFile = new File(getArchiveUri());
return(tmpFile.length());
|
public java.lang.String | getArchiveUri()
return archiveUri;
|
private java.io.InputStream | getElement(java.lang.String name)
if (elements.contains(name)) {
return jarFile.getInputStream(jarFile.getEntry(name));
} else {
return null;
}
|
public AbstractArchive | getEmbeddedArchive(java.lang.String name)
if (jarFile==null) {
return null;
}
DeploymentPlanArchive dpArchive = new DeploymentPlanArchive();
dpArchive.jarFile = new JarFile(archiveUri);
dpArchive.archiveUri = archiveUri + File.separator + name;
dpArchive.subArchiveUri = name;
dpArchive.elements = elements;
return dpArchive;
|
public java.io.InputStream | getEntry(java.lang.String name)
// we are just interested in the file name, not the
// relative path
if (name.endsWith(".dbschema")) {
name = name.replaceAll("/", "#");
} else {
name = name.substring(name.lastIndexOf('/")+1);
}
if (subArchiveUri==null) {
// we are at the "top level"
return getElement(name);
} else {
// we are in a sub archive...
// now let's mangle the name...
String mangledName = subArchiveUri + "." +
name;
return getElement(mangledName);
}
|
public java.util.jar.Manifest | getManifest()
// no manifest in DeploymentPlan
return new Manifest();
|
public java.net.URI | getURI()
File f = new File(archiveUri);
try {
return new URI("jar://" + f.toURI().getSchemeSpecificPart());
} catch(java.net.URISyntaxException e) {
return null;
}
|
public void | open(java.lang.String path)Open an existing DeploymentPlan archive and return
a abstraction for reading from it.
archiveUri = path;
File f = new File(path);
if (f.exists()) {
jarFile = new JarFile(f);
}
|
public java.io.OutputStream | putNextEntry(java.lang.String name)Add an entry to the archive
// not supported for now.
throw new UnsupportedOperationException();
|
public boolean | renameTo(java.lang.String name)rename the underlying archive
File f = new File(archiveUri);
boolean result = FileUtils.renameFile(f, new File(name));
if (result) {
archiveUri = name;
}
return result;
|