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 2013/02/22 14:52:13 UTC

svn commit: r1449043 - /jena/trunk/jena-arq/src/main/java/org/apache/jena/riot/RIOT.java

Author: andy
Date: Fri Feb 22 13:52:13 2013
New Revision: 1449043

URL: http://svn.apache.org/r1449043
Log:
Fix initialization - main RIOT and class initialization must work without ARQ being initialized.

Modified:
    jena/trunk/jena-arq/src/main/java/org/apache/jena/riot/RIOT.java

Modified: jena/trunk/jena-arq/src/main/java/org/apache/jena/riot/RIOT.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-arq/src/main/java/org/apache/jena/riot/RIOT.java?rev=1449043&r1=1449042&r2=1449043&view=diff
==============================================================================
--- jena/trunk/jena-arq/src/main/java/org/apache/jena/riot/RIOT.java (original)
+++ jena/trunk/jena-arq/src/main/java/org/apache/jena/riot/RIOT.java Fri Feb 22 13:52:13 2013
@@ -31,33 +31,48 @@ public class RIOT
 
     /** The product name */   
     public static final String NAME = "RIOT";
+
+    // Unsafe to touch ARQ in class initialization
+    // See init().  these are set in register()
+//    public static final String VERSION = NAME+"/"+ARQ.VERSION ;
+//    public static final String BUILD_DATE = ARQ.BUILD_DATE ;
+    
+    public static String VERSION ;
+    public static String BUILD_DATE ;
     
     /** The root package name for RIOT */   
     public static final String PATH = "org.apache.jena.riot";
 
-    public static final String VERSION = "ARQ/"+ARQ.VERSION ;
-    public static final String BUILD_DATE = ARQ.BUILD_DATE ;
-    
     public static void setStrictMode(boolean state)
     {
         SysRIOT.strictMode = state ;
         SysRIOT.StrictXSDLexicialForms = state ;
     }
 
-    private static boolean initialized = false ;
+    private static volatile boolean initialized = false ;
+    private static Object initLock = new Object () ;
     
     public static void init()
     {
         if ( initialized )
             return ;
-        initialized = true ;
-        RDFLanguages.init() ;
-        RDFParserRegistry.init() ;
-        IO_Jena.wireIntoJena() ;
-        
-        // Don't register JMX info with ARQ as it may not be initialized
-        // itself and we can get into a circularity.
-        // This is done in ARQ.init at the proper moment.
+        synchronized(initLock)
+        {
+            if ( initialized )
+                return ;
+            initialized = true ;
+            // Becareful with what this touches - don't touch ARQ.*
+            // because that depends on Jena core and we may be 
+            // initializing because IO_Ctl (ie. Jena core)
+            // called RIOT.init.
+            RDFLanguages.init() ;
+            RDFParserRegistry.init() ;
+            IO_Jena.wireIntoJena() ;
+
+            // Don't register JMX info with ARQ as it may not be initialized
+            // itself and we can get into a circularity.
+            // This is done in ARQ.init at the proper moment.
+        }
     }
     
     private static boolean registered = false ;
@@ -67,8 +82,15 @@ public class RIOT
             return ;
         registered = true ;
         String NS = RIOT.PATH ;
-        SystemInfo sysInfo2 = new SystemInfo(RIOT.riotIRI, RIOT.VERSION, RIOT.BUILD_DATE) ;
+
+        VERSION = getVersion() ;
+        BUILD_DATE = getBuildDate() ;
+
+        SystemInfo sysInfo2 = new SystemInfo(RIOT.riotIRI, VERSION, BUILD_DATE ) ;
         ARQMgt.register(NS+".system:type=SystemInfo", sysInfo2) ;
         SystemARQ.registerSubSystem(sysInfo2) ;
     }
+    
+    public static String getVersion()   { return ARQ.VERSION ; }
+    public static String getBuildDate() { return ARQ.BUILD_DATE ; }
 }