diff options
author | rfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68> | 2009-05-28 00:46:20 +0000 |
---|---|---|
committer | rfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68> | 2009-05-28 00:46:20 +0000 |
commit | 2d9882b30e13de374d1918e7b75487ab051f7c7c (patch) | |
tree | a727771048a7ebcb546f57639778d25a481b0a18 /java/sca/modules | |
parent | 67c5b10e2218826df5d6fd9334140a32a8e6d7e6 (diff) |
Expose the setting of schema validation to subclasses
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@779378 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/sca/modules')
2 files changed, 21 insertions, 9 deletions
diff --git a/java/sca/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/node/osgi/impl/OSGiNodeFactoryImpl.java b/java/sca/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/node/osgi/impl/OSGiNodeFactoryImpl.java index a92f7c7d77..3a698eeb4b 100644 --- a/java/sca/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/node/osgi/impl/OSGiNodeFactoryImpl.java +++ b/java/sca/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/node/osgi/impl/OSGiNodeFactoryImpl.java @@ -23,6 +23,7 @@ import java.io.StringReader; import java.net.URL; import java.util.Dictionary; import java.util.Hashtable; +import java.util.logging.Level; import org.apache.tuscany.sca.core.ExtensionPointRegistry; import org.apache.tuscany.sca.extensibility.equinox.OSGiExtensionPointRegistry; @@ -111,4 +112,9 @@ public class OSGiNodeFactoryImpl extends NodeFactoryImpl { return new OSGiExtensionPointRegistry(bundleContext); } + @Override + protected boolean isSchemaValidationEnabled() { + return logger.isLoggable(Level.FINE); + } + } diff --git a/java/sca/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeFactoryImpl.java b/java/sca/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeFactoryImpl.java index dfdbc54f13..3ee69a34bf 100644 --- a/java/sca/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeFactoryImpl.java +++ b/java/sca/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeFactoryImpl.java @@ -210,7 +210,7 @@ public class NodeFactoryImpl extends NodeFactory { } } - private static String getSystemProperty(final String name) { + protected static String getSystemProperty(final String name) { return AccessController.doPrivileged(new PrivilegedAction<String>() { public String run() { return System.getProperty(name); @@ -360,6 +360,15 @@ public class NodeFactoryImpl extends NodeFactory { return extensionPoints; } + protected boolean isSchemaValidationEnabled() { + String enabled = getSystemProperty(ValidationSchemaExtensionPoint.class.getName() + ".enabled"); + if (enabled == null) { + enabled = "true"; + } + boolean debug = logger.isLoggable(Level.FINE); + return "true".equals(enabled) || debug; + } + public synchronized void init() { if (inited) { return; @@ -370,15 +379,12 @@ public class NodeFactoryImpl extends NodeFactory { extensionPoints = createExtensionPointRegistry(); // Enable schema validation only of the logger level is FINE or higher - ValidationSchemaExtensionPoint schemas = - extensionPoints.getExtensionPoint(ValidationSchemaExtensionPoint.class); - if (schemas != null) { - String enabled = getSystemProperty(ValidationSchemaExtensionPoint.class.getName() + ".enabled"); - if (enabled == null) { - enabled = "true"; + if (isSchemaValidationEnabled()) { + ValidationSchemaExtensionPoint schemas = + extensionPoints.getExtensionPoint(ValidationSchemaExtensionPoint.class); + if (schemas != null) { + schemas.setEnabled(true); } - boolean debug = logger.isLoggable(Level.FINE); - schemas.setEnabled("true".equals(enabled) || debug); } // Use the runtime-enabled assembly factory |