/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.apache.jena.riot;


import com.hp.hpl.jena.query.ARQ ;
import com.hp.hpl.jena.sparql.SystemARQ ;
import com.hp.hpl.jena.sparql.mgt.ARQMgt ;
import com.hp.hpl.jena.sparql.mgt.SystemInfo ;

public class RIOT
{
    /** IRI for ARQ */  
    public static final String riotIRI = "http://jena.apache.org/#riot" ;

    /** The product name */   
    public static final String NAME = "RIOT";
    
    /** 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 ;
    
    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.
    }
    
    private static boolean registered = false ;
    public static void register()
    {
        if ( registered )
            return ;
        registered = true ;
        String NS = RIOT.PATH ;
        SystemInfo sysInfo2 = new SystemInfo(RIOT.riotIRI, RIOT.VERSION, RIOT.BUILD_DATE) ;
        ARQMgt.register(NS+".system:type=SystemInfo", sysInfo2) ;
        SystemARQ.registerSubSystem(sysInfo2) ;
    }
}

@@ -1201,121 +1201,110 @@
 T%22;%0A
-    
 %0A    /
-** The root package name for RIOT */   %0A    public static final String PATH = %22org.apache.jena.riot%22;%0A%0A
+/ Unsafe to touch ARQ in class initialization%0A    // See init().  these are set in register()%0A//
     
@@ -1344,12 +1344,14 @@
 N = 
-%22ARQ
+NAME+%22
 /%22+A
@@ -1363,16 +1363,18 @@
 RSION ;%0A
+//
     publ
@@ -1423,32 +1423,218 @@
 ILD_DATE ;%0A    %0A
+    public static String VERSION ;%0A    public static String BUILD_DATE ;%0A    %0A    /** The root package name for RIOT */   %0A    public static final String PATH = %22org.apache.jena.riot%22;%0A%0A
     public stati
@@ -1779,32 +1779,41 @@
  private static 
+volatile 
 boolean initiali
@@ -1822,24 +1822,77 @@
 d = false ;%0A
+    private static Object initLock = new Object () ;%0A
     %0A    pub
@@ -1980,29 +1980,358 @@
     
-initialized = true ;%0A
+synchronized(initLock)%0A        %7B%0A            if ( initialized )%0A                return ;%0A            initialized = true ;%0A            // Becareful with what this touches - don't touch ARQ.*%0A            // because that depends on Jena core and we may be %0A            // initializing because IO_Ctl (ie. Jena core)%0A            // called RIOT.init.%0A    
     
@@ -2364,16 +2364,20 @@
         
+   
+ 
 RDFParse
@@ -2403,16 +2403,20 @@
         
+   
+ 
 IO_Jena.
@@ -2432,24 +2432,25 @@
 ena() ;%0A
+%0A
         
 %0A       
@@ -2441,21 +2441,16 @@
         
-%0A    
     // D
@@ -2510,16 +2510,20 @@
 ialized%0A
+    
         
@@ -2575,16 +2575,20 @@
         
+    
 // This 
@@ -2629,22 +2629,32 @@
 moment.%0A
+    
     %7D%0A
+    %7D%0A
     %0A   
@@ -2845,16 +2845,89 @@
 .PATH ;%0A
+%0A        VERSION = getVersion() ;%0A        BUILD_DATE = getBuildDate() ;%0A%0A
         
@@ -2977,21 +2977,16 @@
 iotIRI, 
-RIOT.
 VERSION,
@@ -2986,21 +2986,16 @@
 ERSION, 
-RIOT.
 BUILD_DA
@@ -2996,16 +2996,17 @@
 ILD_DATE
+ 
 ) ;%0A    
@@ -3121,10 +3121,148 @@
 ;%0A    %7D%0A
+    %0A    public static String getVersion()   %7B return ARQ.VERSION ; %7D%0A    public static String getBuildDate() %7B return ARQ.BUILD_DATE ; %7D%0A
 %7D%0A

Fix initialization - main RIOT and class initialization must work without ARQ being initialized.