From: Tuukka Lehtonen Date: Mon, 16 Oct 2017 20:03:46 +0000 (+0300) Subject: Only validate adapter definitions against schema in development mode X-Git-Tag: v1.31.0~117 X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=54e147a9b8b68465a682df135f64f9ea5bac29aa;p=simantics%2Fplatform.git Only validate adapter definitions against schema in development mode refs #7552 Change-Id: I107e25931fecc922b73586b97ce9be1cda4ecb7a --- diff --git a/bundles/org.simantics.db.services/src/org/simantics/db/services/adaption/AdapterRegistry2.java b/bundles/org.simantics.db.services/src/org/simantics/db/services/adaption/AdapterRegistry2.java index 1eb007044..0e52b8a41 100644 --- a/bundles/org.simantics.db.services/src/org/simantics/db/services/adaption/AdapterRegistry2.java +++ b/bundles/org.simantics.db.services/src/org/simantics/db/services/adaption/AdapterRegistry2.java @@ -354,7 +354,7 @@ public class AdapterRegistry2 { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); - if(schemaURL != null) { + if(schemaURL != null && validateAgainstSchema()) { 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(); - 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())