Using a transaction listener with an embedded instance

Hi, after a bit of struggling with Maven I'm now able to run an application using an embedded Stardog.
Now I'd like to attach a transaction listener to it.
I see there is a good example here: stardog-examples/examples/connectable at develop · stardog-union/stardog-examples · GitHub however I cannot understand how to attach the listener to the embedded instance of Stardog I just created. I see the example uses a guice to inject the the listener but the missing part is how to use the injector configured with this module: ExampleModule.java.
Should the injector configured with that module return a Connection, an AdminConnection?
Do you have a simple two-liners to show how to use it?

BTW the link to " 9. Transaction Listener" in List of Examples here GitHub - stardog-union/stardog-examples: Examples for working with and extending Stardog is wrong (404).

I don’t believed that the listener is defined for a specific connection but listens on all connections. It will be looked up my the service definition and injected. There shouldn’t be anything specific you need to do for embedded mode. It’s all automagic.

But do I have to create an Injector or I don't?

The example you refer to is for an embedded connection already. You need the Guice module definition as in that example but do not need to create an injector explicitly which is done by Stardog internals. You need the service loader file [1] so Stardog will include use your Guice module.

Best,
Evren

[1] stardog-examples/examples/connectable/main/resources/META-INF/services at develop · stardog-union/stardog-examples · GitHub

Gotcha. That was the piece I was missing. Thanks.

The correct link would most likely be https://github.com/stardog-union/stardog-examples/tree/develop/examples/connectable

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.