You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jena.apache.org by an...@apache.org on 2024/12/31 10:27:45 UTC
(jena) 04/05: JenaSystem.init with optional tracing
This is an automated email from the ASF dual-hosted git repository.
andy pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/jena.git
commit 0a07f63e6bf91e6add5df3ea5e95af08c36322c2
Author: Andy Seaborne <an...@apache.org>
AuthorDate: Thu Nov 28 11:51:43 2024 +0000
JenaSystem.init with optional tracing
---
.../main/java/org/apache/jena/sys/JenaSystem.java | 44 +++++++++++++++-------
1 file changed, 31 insertions(+), 13 deletions(-)
diff --git a/jena-core/src/main/java/org/apache/jena/sys/JenaSystem.java b/jena-core/src/main/java/org/apache/jena/sys/JenaSystem.java
index 5602bcbf56..417d4c3c33 100644
--- a/jena-core/src/main/java/org/apache/jena/sys/JenaSystem.java
+++ b/jena-core/src/main/java/org/apache/jena/sys/JenaSystem.java
@@ -46,18 +46,6 @@ public class JenaSystem {
private static Subsystem<JenaSubsystemLifecycle> singleton = null;
- // Don't rely on class initialization.
- private static void setup() {
- // Called inside synchronized
- if ( singleton == null ) {
- singleton = new Subsystem<>(JenaSubsystemLifecycle.class);
- SubsystemRegistry<JenaSubsystemLifecycle> reg =
- new SubsystemRegistryServiceLoader<>(JenaSubsystemLifecycle.class);
- singleton.setSubsystemRegistry(reg);
- reg.add(new JenaInitLevel0());
- }
- }
-
public JenaSystem() { }
/**
@@ -76,13 +64,34 @@ public class JenaSystem {
System.err.println() ;
}
+ /**
+ * Initialize Jena. This call can be made several times. Only the first causes
+ * the one-time initialization.
+ */
public static void init() {
+ init(false);
+ }
+
+ /**
+ * Initialize Jena. This call can be made several times. Only the first causes
+ * the one-time initialization.
+ * <p>
+ * Optionally, output initialization steps (prints to stderr).
+ */
+ public static void init(boolean withTracing) {
if ( initialized )
return ;
+ if ( withTracing )
+ DEBUG_INIT = true;
+
// Access the initialized flag to trigger class loading
var unused = LazyInitializer.IS_INITIALIZED;
}
+ public static void shutdown() {
+ singleton.shutdown();
+ }
+
private static class LazyInitializer {
static final boolean IS_INITIALIZED = jenaSystemInitialization();
@@ -97,7 +106,16 @@ public class JenaSystem {
}
}
- public static void shutdown() { singleton.shutdown(); }
+ private static void setup() {
+ // Called inside synchronized
+ if ( singleton == null ) {
+ singleton = new Subsystem<>(JenaSubsystemLifecycle.class);
+ SubsystemRegistry<JenaSubsystemLifecycle> reg =
+ new SubsystemRegistryServiceLoader<>(JenaSubsystemLifecycle.class);
+ singleton.setSubsystemRegistry(reg);
+ reg.add(new JenaInitLevel0());
+ }
+ }
/** The level 0 subsystem - inserted without using the Registry load function.
* There should be only one such level 0 handler.