From 9f662e69e1065b7a0fdc0dfe1a9b28363adbbf86 Mon Sep 17 00:00:00 2001 From: Ostrzyciel Date: Tue, 10 Oct 2023 10:32:11 +0200 Subject: [PATCH] Use Jena's initialization mechanism for subsystems https://jena.apache.org/documentation/notes/system-initialization.html --- .../org.apache.jena.sys.JenaSubsystemLifecycle | 1 + .../jelly/convert/jena/riot/JellyLanguage.scala | 3 ++- .../jena/riot/JellySubsystemLifecycle.scala | 17 +++++++++++++++++ 3 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 jena/src/main/resources/META-INF/services/org.apache.jena.sys.JenaSubsystemLifecycle create mode 100644 jena/src/main/scala/eu/ostrzyciel/jelly/convert/jena/riot/JellySubsystemLifecycle.scala diff --git a/jena/src/main/resources/META-INF/services/org.apache.jena.sys.JenaSubsystemLifecycle b/jena/src/main/resources/META-INF/services/org.apache.jena.sys.JenaSubsystemLifecycle new file mode 100644 index 00000000..de01b4e3 --- /dev/null +++ b/jena/src/main/resources/META-INF/services/org.apache.jena.sys.JenaSubsystemLifecycle @@ -0,0 +1 @@ +eu.ostrzyciel.jelly.convert.jena.riot.JellySubsystemLifecycle diff --git a/jena/src/main/scala/eu/ostrzyciel/jelly/convert/jena/riot/JellyLanguage.scala b/jena/src/main/scala/eu/ostrzyciel/jelly/convert/jena/riot/JellyLanguage.scala index df6bd32e..60290e51 100644 --- a/jena/src/main/scala/eu/ostrzyciel/jelly/convert/jena/riot/JellyLanguage.scala +++ b/jena/src/main/scala/eu/ostrzyciel/jelly/convert/jena/riot/JellyLanguage.scala @@ -20,7 +20,8 @@ object JellyLanguage: /** * Register the Jelly language and formats in Jena. * - * This method is idempotent and should be called automatically when the class is loaded. + * This method is idempotent and should be called automatically when Jena is initialized. + * See: https://jena.apache.org/documentation/notes/system-initialization.html * However, you may also want to call this manually if Jena doesn't load the language automatically. */ def register(): Unit = this.synchronized { diff --git a/jena/src/main/scala/eu/ostrzyciel/jelly/convert/jena/riot/JellySubsystemLifecycle.scala b/jena/src/main/scala/eu/ostrzyciel/jelly/convert/jena/riot/JellySubsystemLifecycle.scala new file mode 100644 index 00000000..5deecbd1 --- /dev/null +++ b/jena/src/main/scala/eu/ostrzyciel/jelly/convert/jena/riot/JellySubsystemLifecycle.scala @@ -0,0 +1,17 @@ +package eu.ostrzyciel.jelly.convert.jena.riot + +import org.apache.jena.sys.JenaSubsystemLifecycle + +/** + * Subsystem lifecycle for registering the Jelly language in Jena. + * See: https://jena.apache.org/documentation/notes/system-initialization.html + */ +class JellySubsystemLifecycle extends JenaSubsystemLifecycle: + override def start(): Unit = JellyLanguage.register() + + override def stop(): Unit = () + + // "Application code should use level above 500." + // Not clear whether the plugins should use > 500 or < 500... + // Let's use 501, this should make Jelly load before the other application subsystems. + override def level() = 501