...
This example Context implementation allows files to be read from a local filesystem, by mapping BLOB URI's with a certain prefix to pathnames:
Code Block | ||||
---|---|---|---|---|
| ||||
package org.tupeloproject.kernel;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
public class ExampleContext extends Context {
public void doPerform(BlobFetcher bf) throws OperatorException {
String pathname = bf.getUri().toString().replaceFirst("http://foo.bar.baz/quux", "/usr/share/data/fbbq");
try {
bf.setInputStream(new FileInputStream(pathname));
} catch (FileNotFoundException e) {
throw new NotFoundException("no file found for URI "+bf.getUri(), e);
}
}
}
|