On 19/10/11 10:41, Paolo Castagna wrote:
Hi,
I am using TDB and I'd like to be notified when a triple is added or
deleted
to/from a Graph. I am not sure what is the best way to achieve this.

Here is a first attempt (which is not working):

InputStream in = ...
DatasetGraphTDB dsg = TDBFactory.createDatasetGraph();

GraphListener listener = new MyListener();
dsg.getDefaultGraph().getEventManager().register(listener);
Iterator<Node> iter = dsg.listGraphNodes();
while ( iter.hasNext() ) {
Graph graph = dsg.getGraph(iter.next());
graph.getEventManager().register(listener);
}

TDBLoader.load(dsg, in, false);

MyListener extends GraphListenerBase implements GraphListener.

I don't understand why, even for triples added to the default graph, it
seems the addEvent(Triple t) and the deleteEvent(Triple t) methods in
MyListener are not called.

Is there a better alternative?

I found an EventManager in the ARQ's org.openjena.atlas.event package.
However, I don't think that is actually used to deliver events to
listeners as data is added/removed to/from a Jena Graph.

Thanks,
Paolo

See LangBase<X>.parse() [which does not tie it back to the dataset] and experimental/maybe: DSG_Notify

but note TDBLoader works by cutting through the layering to reduce overhead.

TDBloader could so start/finish but if you want to see every quad, use a sink. Do you want object churn on every quad?

GraphListener may well work for model.read.

        Andy

Reply via email to