[jboss-cvs] JBossAS SVN: r92964 - in projects/jboss-osgi/projects/bundles/apache-xerces/trunk: src/main/java/org/jboss/osgi/xml and 1 other directory.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Fri Aug 28 11:28:28 EDT 2009


Author: thomas.diesler at jboss.com
Date: 2009-08-28 11:28:28 -0400 (Fri, 28 Aug 2009)
New Revision: 92964

Modified:
   projects/jboss-osgi/projects/bundles/apache-xerces/trunk/pom.xml
   projects/jboss-osgi/projects/bundles/apache-xerces/trunk/src/main/java/org/jboss/osgi/xml/XMLParserActivatorExt.java
   projects/jboss-osgi/projects/bundles/apache-xerces/trunk/src/main/java/org/jboss/osgi/xml/XMLParserCapability.java
Log:
Add support for service (provider=jboss.osgi)

Modified: projects/jboss-osgi/projects/bundles/apache-xerces/trunk/pom.xml
===================================================================
--- projects/jboss-osgi/projects/bundles/apache-xerces/trunk/pom.xml	2009-08-28 15:27:02 UTC (rev 92963)
+++ projects/jboss-osgi/projects/bundles/apache-xerces/trunk/pom.xml	2009-08-28 15:28:28 UTC (rev 92964)
@@ -21,21 +21,21 @@
   <artifactId>jboss-osgi-apache-xerces</artifactId>
   <packaging>bundle</packaging>
 
-  <version>2.9.1.SP1</version>
+  <version>2.9.1-SNAPSHOT</version>
 
   <!-- Parent -->
   <parent>
     <groupId>org.jboss.osgi</groupId>
     <artifactId>jboss-osgi-parent</artifactId>
-    <version>1.0.1</version>
+    <version>1.0.2-SNAPSHOT</version>
   </parent>
 
   <properties>
     <version.apache.xerces>2.9.1</version.apache.xerces>
-    <version.jboss.osgi.common>1.0.0</version.jboss.osgi.common>
+    <version.jboss.osgi.common>1.0.1-SNAPSHOT</version.jboss.osgi.common>
     <version.wutka.dtdparser>1.2.1</version.wutka.dtdparser>
     <version.xml.resolver>1.2</version.xml.resolver>
-    <version.osgi>r4v41</version.osgi>
+    <version.osgi>r4v42-20090728</version.osgi>
   </properties>
 
   <dependencies>

Modified: projects/jboss-osgi/projects/bundles/apache-xerces/trunk/src/main/java/org/jboss/osgi/xml/XMLParserActivatorExt.java
===================================================================
--- projects/jboss-osgi/projects/bundles/apache-xerces/trunk/src/main/java/org/jboss/osgi/xml/XMLParserActivatorExt.java	2009-08-28 15:27:02 UTC (rev 92963)
+++ projects/jboss-osgi/projects/bundles/apache-xerces/trunk/src/main/java/org/jboss/osgi/xml/XMLParserActivatorExt.java	2009-08-28 15:28:28 UTC (rev 92964)
@@ -42,56 +42,29 @@
  */
 public class XMLParserActivatorExt extends XMLParserActivator
 {
-   /*
-    * Service property specifying if factory is configured to support XInclude aware parsers. 
-    * The value is of type <code>Boolean</code>.
-    */
-   public static final String PARSER_XINCLUDEAWARE = "parser.xincludeAware";
-   
    private LogService log;
 
    public void start(BundleContext context) throws Exception
    {
       log = new LogServiceTracker(context);
-      
+
       super.start(context);
-      
+
       logSAXParserFactory(context);
       logDOMParserFactory(context);
    }
-   
+
    @Override
    @SuppressWarnings("unchecked")
    public void setDOMProperties(DocumentBuilderFactory factory, Hashtable props)
    {
-      // check if this parser can be configured to validate
-      boolean validating = true;
-      factory.setValidating(true);
-      factory.setNamespaceAware(false);
-      try
-      {
-         factory.newDocumentBuilder();
-      }
-      catch (Exception pce_val)
-      {
-         validating = false;
-      }
+      super.setDOMProperties(factory, props);
 
-      // check if this parser can be configured to be namespaceaware
-      boolean namespaceaware = true;
-      factory.setValidating(false);
-      factory.setNamespaceAware(true);
-      try
-      {
-         factory.newDocumentBuilder();
-      }
-      catch (Exception pce_nsa)
-      {
-         namespaceaware = false;
-      }
+      boolean xinclude = true;
+      Boolean validating = (Boolean)props.get(PARSER_VALIDATING);
+      Boolean namespaceaware = (Boolean)props.get(PARSER_NAMESPACEAWARE);
 
       // check if this parser can be configured to be xinclude aware
-      boolean xinclude = true;
       factory.setValidating(validating);
       factory.setNamespaceAware(namespaceaware);
       factory.setXIncludeAware(true);
@@ -105,49 +78,24 @@
       }
 
       // set the factory values
-      factory.setValidating(validating);
-      factory.setNamespaceAware(namespaceaware);
       factory.setXIncludeAware(xinclude);
-
+      
       // set the OSGi service properties
-      props.put(PARSER_VALIDATING, new Boolean(validating));
-      props.put(PARSER_NAMESPACEAWARE, new Boolean(namespaceaware));
-      props.put(PARSER_XINCLUDEAWARE, new Boolean(xinclude));
+      props.put(XMLParserCapability.PARSER_XINCLUDEAWARE, new Boolean(xinclude));
+      props.put(XMLParserCapability.PARSER_PROVIDER, XMLParserCapability.PROVIDER_JBOSS_OSGI);
    }
 
-
    @Override
    @SuppressWarnings("unchecked")
    public void setSAXProperties(SAXParserFactory factory, Hashtable props)
    {
-      // check if this parser can be configured to validate
-      boolean validating = true;
-      factory.setValidating(true);
-      factory.setNamespaceAware(false);
-      try
-      {
-         factory.newSAXParser();
-      }
-      catch (Exception pce_val)
-      {
-         validating = false;
-      }
+      super.setSAXProperties(factory, props);
 
-      // check if this parser can be configured to be namespaceaware
-      boolean namespaceaware = true;
-      factory.setValidating(false);
-      factory.setNamespaceAware(true);
-      try
-      {
-         factory.newSAXParser();
-      }
-      catch (Exception pce_nsa)
-      {
-         namespaceaware = false;
-      }
-
-      // check if this parser can be configured to be xinclude aware
       boolean xinclude = true;
+      Boolean validating = (Boolean)props.get(PARSER_VALIDATING);
+      Boolean namespaceaware = (Boolean)props.get(PARSER_NAMESPACEAWARE);
+      
+      // check if this parser can be configured to be xinclude aware
       factory.setValidating(validating);
       factory.setNamespaceAware(namespaceaware);
       factory.setXIncludeAware(true);
@@ -161,14 +109,11 @@
       }
 
       // set the factory values
-      factory.setValidating(validating);
-      factory.setNamespaceAware(namespaceaware);
       factory.setXIncludeAware(xinclude);
 
       // set the OSGi service properties
-      props.put(PARSER_NAMESPACEAWARE, new Boolean(namespaceaware));
-      props.put(PARSER_VALIDATING, new Boolean(validating));
-      props.put(PARSER_XINCLUDEAWARE, new Boolean(xinclude));
+      props.put(XMLParserCapability.PARSER_XINCLUDEAWARE, new Boolean(xinclude));
+      props.put(XMLParserCapability.PARSER_PROVIDER, XMLParserCapability.PROVIDER_JBOSS_OSGI);
    }
 
    private void logSAXParserFactory(BundleContext context)
@@ -178,7 +123,7 @@
       {
          Object factory = context.getService(saxRef);
          log.log(LogService.LOG_DEBUG, "SAXParserFactory: " + factory.getClass().getName());
-         
+
          for (String key : saxRef.getPropertyKeys())
          {
             Object value = saxRef.getProperty(key);
@@ -191,7 +136,6 @@
       }
    }
 
-
    private void logDOMParserFactory(BundleContext context)
    {
       ServiceReference domRef = context.getServiceReference(DocumentBuilderFactory.class.getName());
@@ -199,7 +143,7 @@
       {
          Object factory = context.getService(domRef);
          log.log(LogService.LOG_DEBUG, "DocumentBuilderFactory: " + factory.getClass().getName());
-         
+
          for (String key : domRef.getPropertyKeys())
          {
             Object value = domRef.getProperty(key);

Modified: projects/jboss-osgi/projects/bundles/apache-xerces/trunk/src/main/java/org/jboss/osgi/xml/XMLParserCapability.java
===================================================================
--- projects/jboss-osgi/projects/bundles/apache-xerces/trunk/src/main/java/org/jboss/osgi/xml/XMLParserCapability.java	2009-08-28 15:27:02 UTC (rev 92963)
+++ projects/jboss-osgi/projects/bundles/apache-xerces/trunk/src/main/java/org/jboss/osgi/xml/XMLParserCapability.java	2009-08-28 15:28:28 UTC (rev 92964)
@@ -29,8 +29,7 @@
 import org.jboss.osgi.spi.testing.OSGiRuntime;
 
 /**
- * Adds the XML parser capability to the {@link OSGiRuntime}
- * under test. 
+ * Adds the XML parser capability to the {@link OSGiRuntime} under test.
  * 
  * It is ignored if the {@link SAXParserFactory} is already registered.
  * 
@@ -41,10 +40,26 @@
  */
 public class XMLParserCapability extends Capability
 {
+   /*
+    * Service property key for the 'provider' of this service. 
+    */
+   public static final String PARSER_PROVIDER = "provider";
+   /*
+    * Service property value for the 'provider' of this service. 
+    * The value is <code>jboss.osgi</code>.
+    */
+   public static final String PROVIDER_JBOSS_OSGI = "jboss.osgi";
+   /*
+    * Service property specifying if factory is configured to support XInclude aware parsers. 
+    * The value is of type <code>Boolean</code>.
+    */
+   public static final String PARSER_XINCLUDEAWARE = "parser.xincludeAware";
+
    public XMLParserCapability()
    {
       super(SAXParserFactory.class.getName());
-      
+      setFilter("(" + PARSER_PROVIDER + "=" + PROVIDER_JBOSS_OSGI + ")");
+
       addBundle("bundles/jboss-osgi-apache-xerces.jar");
    }
 }
\ No newline at end of file




More information about the jboss-cvs-commits mailing list