]> gerrit.simantics Code Review - simantics/platform.git/commitdiff
Only validate adapter definitions against schema in development mode 14/1114/1
authorTuukka Lehtonen <tuukka.lehtonen@semantum.fi>
Mon, 16 Oct 2017 20:03:46 +0000 (23:03 +0300)
committerTuukka Lehtonen <tuukka.lehtonen@semantum.fi>
Mon, 16 Oct 2017 20:03:46 +0000 (23:03 +0300)
refs #7552

Change-Id: I107e25931fecc922b73586b97ce9be1cda4ecb7a

bundles/org.simantics.db.services/src/org/simantics/db/services/adaption/AdapterRegistry2.java

index 1eb00704409ab15b5f3291af22afc76874b54026..0e52b8a417da4ebecf82c27369cf7581171c58e4 100644 (file)
@@ -354,7 +354,7 @@ public class AdapterRegistry2 {
             DocumentBuilderFactory factory =
                 DocumentBuilderFactory.newInstance();
             
             DocumentBuilderFactory factory =
                 DocumentBuilderFactory.newInstance();
             
-            if(schemaURL != null) {
+            if(schemaURL != null && validateAgainstSchema()) {
             
                    factory.setValidating(true);
                    factory.setAttribute(
             
                    factory.setValidating(true);
                    factory.setAttribute(
@@ -410,20 +410,27 @@ public class AdapterRegistry2 {
         }
        
     }
         }
        
     }
-    
-    public void initialize(BundleContext context) {
+
+    private boolean validateAgainstSchema() {
+        return Platform.inDevelopmentMode();
+    }
+
+       public void initialize(BundleContext context) {
        
         try {
                
             DocumentBuilderFactory factory =
                 DocumentBuilderFactory.newInstance();
        
         try {
                
             DocumentBuilderFactory factory =
                 DocumentBuilderFactory.newInstance();
-            factory.setValidating(true);
-            factory.setAttribute(
-                    "http://java.sun.com/xml/jaxp/properties/schemaLanguage",
-            "http://www.w3.org/2001/XMLSchema");
-            factory.setAttribute(
-                    "http://java.sun.com/xml/jaxp/properties/schemaSource",
-                    context.getBundle().getResource("adapters.xsd").toString());
+
+            if (validateAgainstSchema()) {
+                factory.setValidating(true);
+                factory.setAttribute(
+                        "http://java.sun.com/xml/jaxp/properties/schemaLanguage",
+                        "http://www.w3.org/2001/XMLSchema");
+                factory.setAttribute(
+                        "http://java.sun.com/xml/jaxp/properties/schemaSource",
+                        context.getBundle().getResource("adapters.xsd").toString());
+            }
 
             // TODO Listen bundles (install/uninstall)
             if (exceptions.isEmpty())
 
             // TODO Listen bundles (install/uninstall)
             if (exceptions.isEmpty())