You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jena.apache.org by Paul Blakeley <pb...@gmail.com> on 2023/06/06 11:10:29 UTC

How to configure Fuseki with event handler

I am new to this and struggling to find any information relating to
configuring fuseki so that I can listen to the events when inserting into
the triple store.  I have the following code which I can see is running
from the logs.   But the listener doesn't seem to be triggered.  Any help
would be appreciated.

public class Listener {

    public static void init() {
        System.err.println("Starting process...");
        Model m = ModelFactory.createDefaultModel();

        m.register(new ChangedListener() {
            @Override
            public void addedStatement(Statement statement) {
                System.err.println("New statement added: " + statement);
            }
            @Override
            public void removedStatement(Statement statement) {
                System.err.println("Statement removed: " + statement);
            }
        });

        System.err.println("Registered ChangedListener 0...");

}

Re: How to configure Fuseki with event handler

Posted by Andy Seaborne <an...@apache.org>.
Paul,

How are you running your code in the Fuseki server?

     Andy

On 06/06/2023 21:36, Paul Blakeley wrote:
> Thanks, Bruno for your response.  Yeah, I've looked at them.  They seem to
> work ok when the context of the model is known.  But not sure how to
> integrate it with fuseki.  It might be because I am setting the model
> through configuration.  Cant find many examples though. : (
> 
> On Tue, Jun 6, 2023 at 7:53 PM Bruno Kinoshita <ki...@apache.org> wrote:
> 
>> Hi Paul,
>>
>> I haven't used listeners with Jena. Have you had a look at the docs
>> already?
>> https://jena.apache.org/documentation/notes/event-handler-howto.html
>>
>> Cheers
>>
>> Bruno
>>
>> On Tue, 6 Jun 2023 at 13:11, Paul Blakeley <pb...@gmail.com> wrote:
>>
>>> I am new to this and struggling to find any information relating to
>>> configuring fuseki so that I can listen to the events when inserting into
>>> the triple store.  I have the following code which I can see is running
>>> from the logs.   But the listener doesn't seem to be triggered.  Any help
>>> would be appreciated.
>>>
>>> public class Listener {
>>>
>>>      public static void init() {
>>>          System.err.println("Starting process...");
>>>          Model m = ModelFactory.createDefaultModel();
>>>
>>>          m.register(new ChangedListener() {
>>>              @Override
>>>              public void addedStatement(Statement statement) {
>>>                  System.err.println("New statement added: " + statement);
>>>              }
>>>              @Override
>>>              public void removedStatement(Statement statement) {
>>>                  System.err.println("Statement removed: " + statement);
>>>              }
>>>          });
>>>
>>>          System.err.println("Registered ChangedListener 0...");
>>>
>>> }
>>>
>>
> 

Re: How to configure Fuseki with event handler

Posted by Paul Blakeley <pb...@gmail.com>.
Thanks, Bruno for your response.  Yeah, I've looked at them.  They seem to
work ok when the context of the model is known.  But not sure how to
integrate it with fuseki.  It might be because I am setting the model
through configuration.  Cant find many examples though. : (

On Tue, Jun 6, 2023 at 7:53 PM Bruno Kinoshita <ki...@apache.org> wrote:

> Hi Paul,
>
> I haven't used listeners with Jena. Have you had a look at the docs
> already?
> https://jena.apache.org/documentation/notes/event-handler-howto.html
>
> Cheers
>
> Bruno
>
> On Tue, 6 Jun 2023 at 13:11, Paul Blakeley <pb...@gmail.com> wrote:
>
> > I am new to this and struggling to find any information relating to
> > configuring fuseki so that I can listen to the events when inserting into
> > the triple store.  I have the following code which I can see is running
> > from the logs.   But the listener doesn't seem to be triggered.  Any help
> > would be appreciated.
> >
> > public class Listener {
> >
> >     public static void init() {
> >         System.err.println("Starting process...");
> >         Model m = ModelFactory.createDefaultModel();
> >
> >         m.register(new ChangedListener() {
> >             @Override
> >             public void addedStatement(Statement statement) {
> >                 System.err.println("New statement added: " + statement);
> >             }
> >             @Override
> >             public void removedStatement(Statement statement) {
> >                 System.err.println("Statement removed: " + statement);
> >             }
> >         });
> >
> >         System.err.println("Registered ChangedListener 0...");
> >
> > }
> >
>

Re: How to configure Fuseki with event handler

Posted by Bruno Kinoshita <ki...@apache.org>.
Hi Paul,

I haven't used listeners with Jena. Have you had a look at the docs
already?
https://jena.apache.org/documentation/notes/event-handler-howto.html

Cheers

Bruno

On Tue, 6 Jun 2023 at 13:11, Paul Blakeley <pb...@gmail.com> wrote:

> I am new to this and struggling to find any information relating to
> configuring fuseki so that I can listen to the events when inserting into
> the triple store.  I have the following code which I can see is running
> from the logs.   But the listener doesn't seem to be triggered.  Any help
> would be appreciated.
>
> public class Listener {
>
>     public static void init() {
>         System.err.println("Starting process...");
>         Model m = ModelFactory.createDefaultModel();
>
>         m.register(new ChangedListener() {
>             @Override
>             public void addedStatement(Statement statement) {
>                 System.err.println("New statement added: " + statement);
>             }
>             @Override
>             public void removedStatement(Statement statement) {
>                 System.err.println("Statement removed: " + statement);
>             }
>         });
>
>         System.err.println("Registered ChangedListener 0...");
>
> }
>