Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

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
Java
Java

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);
	}
    }
}