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 2023/01/07 15:49:48 UTC

[jena-site] branch system-init created (now e1a8753d8)

This is an automated email from the ASF dual-hosted git repository.

andy pushed a change to branch system-init
in repository https://gitbox.apache.org/repos/asf/jena-site.git


      at e1a8753d8 Update system-initialization.md

This branch includes the following new commits:

     new e1a8753d8 Update system-initialization.md

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[jena-site] 01/01: Update system-initialization.md

Posted by an...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

andy pushed a commit to branch system-init
in repository https://gitbox.apache.org/repos/asf/jena-site.git

commit e1a8753d838b2c885cc985d16ebdc15141b4c3b8
Author: Andy Seaborne <an...@apache.org>
AuthorDate: Sat Jan 7 15:49:38 2023 +0000

    Update system-initialization.md
---
 .../documentation/notes/system-initialization.md   | 100 +++++++--------------
 1 file changed, 31 insertions(+), 69 deletions(-)

diff --git a/source/documentation/notes/system-initialization.md b/source/documentation/notes/system-initialization.md
index 8766a01cd..ad3b11d67 100644
--- a/source/documentation/notes/system-initialization.md
+++ b/source/documentation/notes/system-initialization.md
@@ -2,29 +2,34 @@
 title: Apache Jena Initialization
 ---
 
-Jena has a simple initialization sequence that is
+Jena has an initialization sequence that is
 used to setup components available at runtime.
 
 Application code is welcome to also use this mechanism. This
-must be done with care. Java initialization can lead to
+must be done with care. During Jena initialization, there is 
 visibility of uninitialized data.
 
 The standard initialization sequence is  
 Core -> RIOT -> ARQ -> TDB -> other (including jena text)
 
-The sequence from core to TDB should be executed before application
+The sequence from core to level 500 should be executed before application
 components. See below for how to control the order.
 
 Initialization occurs when `JenaSystem.init()` is first called.  Jena ensures that this
 is done when the application first uses any Jena code by using class
 initializers.
 
+Application can call `JenaSystem.init()`. 
+
 See [notes on repacking Jena code](jena-repack.html) for how to deal
-with ServiceLoader files in repacked jars.
+with `ServiceLoader` files in repacked jars.
 
 ## Initialization code
 
-Initialization code is an implementation of `JenaSubsystemLifecycle`.
+Initialization code is an implementation of `JenaSubsystemLifecycle` which
+itself extends `SubsystemLifecycle`.
+
+
 For use in the default initialization, the class must have a zero-argument constructor
 
     public interface JenaSubsystemLifecycle {
@@ -38,18 +43,32 @@ The levels used by Jena are:
 
 * 0 - reserved
 * 10 - Used by jena-core
+* 15 - CLI Commands registry
 * 20 - RIOT
 * 30 - ARQ
-* 40 - TDB
-* 9999 - other
+* 40 - Text indexing
+* 40 - TDB1
+* 42 - TDB1
+* 60 - Additional HTTP configuration
+* 60 - RDFPAtch
+* 96 - SHACL
+* 96 - ShEx
+* 101 - Fuseki
+* 9999 - Default.
+
+Levels up to 500 are considered to be "Jena system level", Application code
+should use level above 500.
+
+Fuseki initialization includes [Fuseki
+Modules](/documentation/fuseki2/fuseki-modules) which uses `SubsystemLifecycle`
+for different Java interface.
 
 ## The Initialization Process
 
-The process followed by `JenaSystem.init()` is to obtain an instance of
-`JenaSubsystemRegistry`, ask it to `load()` initialization code, then call
-that code in an order based on declared level. The order of invocation
-of different initialization code within the same level is undefined
-and may be different from run to run.
+The process followed by `JenaSystem.init()` is to load all java `ServiceLoader`
+regsitered `JenaSubsystemLifecycle`, osrt into level order, then call `init`.
+Initialization code unit at the same level can be called in any order and the
+order may be different between runs.
 
 Only the first call of `JenaSystem.init()` causes the process to run.
 Any subsequent calls are cheap, so calling `JenaSystem.init()`
@@ -58,19 +77,6 @@ when in doubt about the initialization state is safe.
 Overlapping concurrent calls to `JenaSystem.init()` are thread-safe.
 On a return from `JenaSystem.init()`, Jena has been initialized at some point.
 
-## The Standard Subsystem Registry
-
-The `JenaSubsystemRegistry` normally used is based on `java.util.ServiceLoader`.
-It looks for class resources
-`META-INF/services/org.apache.jena.sys.JenaSubsystemLifecycle`
-on the classpath during the load step.
-
-See the javadoc for `java.util.ServiceLoader` for more details.
-
-See also the javadoc for
-[JenaSystem](/documentation/javadoc/jena/org/apache/jena/system/JenaSystem.html)
-and the source code.
-
 ## Debugging
 
 There is a flag `JenaSystem.DEBUG_INIT` to help with development. It is not
@@ -78,47 +84,3 @@ intended for runtime logging.
 
 Jena components print their initialization beginning and end points on
 `System.err` to help track down ordering issues.
-
-## Modifying the Standard Process
-
-It is possible, with care, to alter the way
-that initialization code is discovered.
-
-An application can change the `JenaSubsystemRegistry` instance.
-This must be done before any Jena code is called anywhere
-in the current JVM.
-
-    // Example alternative registry.
-    JenaSubsystemRegistry r = new JenaSubsystemRegistryBasic() {
-        @Override
-        public void load() {
-            if ( JenaSystem.DEBUG_INIT )
-                System.err.println("Example custom load") ;
-            super.load();
-        }
-    } ;
-
-    // Set the sub-system registry
-    JenaSystem.setSubsystemRegistry(r);
-
-    // Enable output if required
-    // JenaSystem.DEBUG_INIT = true ;
-
-    // Initialize Jena
-    JenaSystem.init() ;
-
-## Jena initialization in multi-classloader environments
-
-In some applications with multiple classloaders, or different classloader strategies, Jena initialization may
-not work as expected. If the Jena initialization debug information shows that components were not loaded correctly,
-trying to switch the context class loader may fix the initialization process.
-
-    ClassLoader contextClassLoader = null;
-    try {
-        contextClassLoader = Thread.currentThread().getContextClassLoader();
-        Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
-        JenaSystem.DEBUG_INIT = true;
-        // ...
-    } finally {
-        Thread.currentThread().setContextClassLoader(contextClassLoader);
-    }