aQute.lib.osgi.WriteResource Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of bndlib Show documentation
Show all versions of bndlib Show documentation
A Swiss Army Knife for OSGi
package aQute.lib.osgi;
import java.io.*;
public abstract class WriteResource implements Resource {
long lastModified;
String extra;
public InputStream openInputStream() throws Exception {
PipedInputStream pin = new PipedInputStream();
final PipedOutputStream pout = new PipedOutputStream(pin);
Thread t = new Thread() {
public void run() {
try {
write(pout);
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
pout.close();
} catch (IOException e) {
// Ignore
}
}
}
};
t.start();
return pin;
}
public abstract void write(OutputStream out) throws IOException, Exception;
public abstract long lastModified();
public String getExtra() {
return extra;
}
public void setExtra(String extra) {
this.extra = extra;
}
}