registerListener

3 views
Skip to first unread message

jako

unread,
Feb 8, 2010, 10:50:22 AM2/8/10
to OpenAnzo
Hi,
I need information to implement a registerListener on a graph. I'm
actually using a listener like this:

graph.registerListener(new IStatementListener<INamedGraph>() {

@Override
public void statementsAdded(INamedGraph source,
org.openanzo.rdf.Statement... statements) {
// TODO Auto-generated method stub
System.err.println("Statements added to: " +
source.getNamedGraphUri());
for (int i = 0; i < statements.length; i++) {
System.err.println(statements[i]);
}
}
@Override
public void statementsRemoved(INamedGraph source,
org.openanzo.rdf.Statement... statements) {
// TODO Auto-generated method stub
System.err.println("Statements removed from: " +
source.getNamedGraphUri());
for (int i = 0; i < statements.length; i++) {
System.err.println(statements[i]);
}
}});

but I want to use listener for run an inference process when some
statements has been changed? is this the right method to use?
Has someone documentation to suggest me? I 've not found anything
about it on the wiki...

jako

Jordi Albornoz Mulligan

unread,
Feb 8, 2010, 1:34:27 PM2/8/10
to open...@googlegroups.com

Hi jako,

Yes. That method will work for listening for statements changing within
a graph. Keep in mind that the graph on which you are registering a
listener needs to be a 'replicaGraph' for it to work like that.
There is a code sample in the org.openanzo.client.sample project that
shows this in action. You can get a copy of that project using SVN by
doing something like:
svn export
http://svn.openanzo.org/svn/openanzo/openanzo/branches/releases/openanzo-3.1.0/org.openanzo.client.sample/

The relevant sample code is in the
org.openanzo.client.sample.ReplicaGraph class.

If you can't use a replicaGraph for some reason, such as its contents
are too big to reasonably store a replica of it in client memory, then
you can still monitor changes to it using the 'real time updates'
mechanism. There is a sample of that mechanism in the
org.openanzo.client.sample.RealtimeUpdates class.

--
Jordi Albornoz Mulligan
Founding Engineer - Cambridge Semantics
jo...@cambridgesemantics.com
(617) 401-7321

Jordi Albornoz Mulligan

unread,
Feb 8, 2010, 1:42:15 PM2/8/10
to open...@googlegroups.com
Jordi Albornoz Mulligan wrote:
> jako wrote:
>> Hi,
>> I need information to implement a registerListener on a graph. I'm
>> actually using a listener like this:
[snip]

>> but I want to use listener for run an inference process when some
>> statements has been changed? is this the right method to use?
>> Has someone documentation to suggest me? I 've not found anything
>> about it on the wiki...
>
> Hi jako,
>
> Yes. That method will work for listening for statements changing within
> a graph. Keep in mind that the graph on which you are registering a
> listener needs to be a 'replicaGraph' for it to work like that.

Actually, I was mistaken in saying that it must be a replicaGraph. It
can either be a replicaGraph or a serverGraph. You'll get the events in
both cases and, with the serverGraph you won't be limited in the size of
the graph since it won't keep a client copy of the data. So you can
choose whichever is more appropriate. The
org.openanzo.client.sample.ServerGraph class has an example using server
graphs.

jako

unread,
Feb 9, 2010, 9:02:53 AM2/9/10
to OpenAnzo
Hi Jordi,
I have seen the documentation, it's very helpful.
Thanks,

J

On 8 Feb, 19:42, Jordi Albornoz Mulligan

Reply all
Reply to author
Forward
0 new messages