tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rf...@apache.org
Subject svn commit: r747607 - in /tuscany/java/sca/modules: extensibility-equinox/src/main/java/org/apache/tuscany/sca/extensibility/equinox/ extensibility/src/main/java/org/apache/tuscany/sca/extensibility/ extensibility/src/test/java/org/apache/tuscany/sca/e...
Date Tue, 24 Feb 2009 23:17:59 GMT
Author: rfeng
Date: Tue Feb 24 23:17:59 2009
New Revision: 747607

URL: http://svn.apache.org/viewvc?rev=747607&view=rev
Log:
A more complete fix for TUSCANY-2869

Modified:
    tuscany/java/sca/modules/extensibility-equinox/src/main/java/org/apache/tuscany/sca/extensibility/equinox/EquinoxServiceDiscoverer.java
    tuscany/java/sca/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/ContextClassLoaderServiceDiscoverer.java
    tuscany/java/sca/modules/extensibility/src/test/java/org/apache/tuscany/sca/extensibility/ContextClassLoaderServiceDiscovererTestCase.java

Modified: tuscany/java/sca/modules/extensibility-equinox/src/main/java/org/apache/tuscany/sca/extensibility/equinox/EquinoxServiceDiscoverer.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/extensibility-equinox/src/main/java/org/apache/tuscany/sca/extensibility/equinox/EquinoxServiceDiscoverer.java?rev=747607&r1=747606&r2=747607&view=diff
==============================================================================
--- tuscany/java/sca/modules/extensibility-equinox/src/main/java/org/apache/tuscany/sca/extensibility/equinox/EquinoxServiceDiscoverer.java
(original)
+++ tuscany/java/sca/modules/extensibility-equinox/src/main/java/org/apache/tuscany/sca/extensibility/equinox/EquinoxServiceDiscoverer.java
Tue Feb 24 23:17:59 2009
@@ -32,6 +32,7 @@
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Map;
+import java.util.Properties;
 import java.util.Set;
 import java.util.StringTokenizer;
 import java.util.logging.Level;
@@ -198,6 +199,8 @@
         boolean debug = logger.isLoggable(Level.FINE);
         Set<ServiceDeclaration> descriptors = new HashSet<ServiceDeclaration>();
 
+        // http://java.sun.com/j2se/1.5.0/docs/api/javax/xml/xpath/XPathFactory.html
+        boolean isPropertyFile = "javax.xml.xpath.XPathFactory".equals(serviceName);
         serviceName = "META-INF/services/" + serviceName;
 
         for (Bundle bundle : context.getBundles()) {
@@ -253,6 +256,30 @@
                     } catch (PrivilegedActionException e) {
                         throw (IOException)e.getException();
                     }
+                    if (isPropertyFile) {
+                        // Load as a property file
+                        Properties props = new Properties();
+                        props.load(is);
+                        is.close();
+                        for (Map.Entry<Object, Object> e : props.entrySet()) {
+                            Map<String, String> attributes = new HashMap<String,
String>();
+                            String key = (String)e.getKey();
+                            String value = (String)e.getValue();
+                            // Unfortunately, the xalan file only has the classname
+                            if ("".equals(value)) {
+                                value = key;
+                                key = "";
+                            }
+                            if (!"".equals(key)) {
+                                attributes.put(key, value);
+                                attributes.put("uri", key);
+                            }
+                            attributes.put("class", value);
+                            ServiceDeclarationImpl descriptor = new ServiceDeclarationImpl(bundle,
url, value, attributes);
+                            descriptors.add(descriptor);
+                        }
+                        continue;
+                    }
                     BufferedReader reader = null;
                     try {
                         reader = new BufferedReader(new InputStreamReader(is));

Modified: tuscany/java/sca/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/ContextClassLoaderServiceDiscoverer.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/ContextClassLoaderServiceDiscoverer.java?rev=747607&r1=747606&r2=747607&view=diff
==============================================================================
--- tuscany/java/sca/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/ContextClassLoaderServiceDiscoverer.java
(original)
+++ tuscany/java/sca/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/ContextClassLoaderServiceDiscoverer.java
Tue Feb 24 23:17:59 2009
@@ -35,6 +35,7 @@
 import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
+import java.util.Properties;
 import java.util.Set;
 import java.util.StringTokenizer;
 import java.util.logging.Level;
@@ -141,15 +142,8 @@
         } else {
             int j = declaration.indexOf('=');
             if (j == -1) {
-                // TUSCANY-xxx: handle Saxon xpath jar funny
-                if (declaration.startsWith("http\\://")) {
-                    int k = declaration.lastIndexOf(':');
-                    attributes.put("class", declaration.substring(k+1).trim());
-                    return attributes;
-                } else {
-                    attributes.put("class", declaration.trim());
-                    return attributes;
-                }
+                attributes.put("class", declaration.trim());
+                return attributes;
             } else {
                 declaration = ";" + declaration;
             }
@@ -179,6 +173,8 @@
     public Set<ServiceDeclaration> getServiceDeclarations(String serviceName) {
         Set<ServiceDeclaration> descriptors = new HashSet<ServiceDeclaration>();
 
+        // http://java.sun.com/j2se/1.5.0/docs/api/javax/xml/xpath/XPathFactory.html
+        boolean isPropertyFile = "javax.xml.xpath.XPathFactory".equals(serviceName);
         String name = "META-INF/services/" + serviceName;
         boolean debug = logger.isLoggable(Level.FINE);
         try {
@@ -206,6 +202,30 @@
                 } catch (PrivilegedActionException e) {
                     throw (IOException)e.getException();
                 }
+                if (isPropertyFile) {
+                    // Load as a property file
+                    Properties props = new Properties();
+                    props.load(is);
+                    is.close();
+                    for (Map.Entry<Object, Object> e : props.entrySet()) {
+                        Map<String, String> attributes = new HashMap<String, String>();
+                        String key = (String)e.getKey();
+                        String value = (String)e.getValue();
+                        // Unfortunately, the xalan file only has the classname
+                        if ("".equals(value)) {
+                            value = key;
+                            key = "";
+                        }
+                        if (!"".equals(key)) {
+                            attributes.put(key, value);
+                            attributes.put("uri", key);
+                        }
+                        attributes.put("class", value);
+                        ServiceDeclarationImpl descriptor = new ServiceDeclarationImpl(url,
value, attributes);
+                        descriptors.add(descriptor);
+                    }
+                    continue;
+                }
                 BufferedReader reader = null;
                 try {
                     reader = new BufferedReader(new InputStreamReader(is));

Modified: tuscany/java/sca/modules/extensibility/src/test/java/org/apache/tuscany/sca/extensibility/ContextClassLoaderServiceDiscovererTestCase.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/extensibility/src/test/java/org/apache/tuscany/sca/extensibility/ContextClassLoaderServiceDiscovererTestCase.java?rev=747607&r1=747606&r2=747607&view=diff
==============================================================================
--- tuscany/java/sca/modules/extensibility/src/test/java/org/apache/tuscany/sca/extensibility/ContextClassLoaderServiceDiscovererTestCase.java
(original)
+++ tuscany/java/sca/modules/extensibility/src/test/java/org/apache/tuscany/sca/extensibility/ContextClassLoaderServiceDiscovererTestCase.java
Tue Feb 24 23:17:59 2009
@@ -59,6 +59,16 @@
         descriptor = discover.getFirstServiceDeclaration("notthere");
         Assert.assertNull(descriptor);
     }
+    
+    @Test
+    public void testXPathFactory() {
+        Set<ServiceDeclaration> discriptors = discover.getServiceDeclarations("javax.xml.xpath.XPathFactory");
+        if (!discriptors.isEmpty()) {
+            ServiceDeclaration d = discriptors.iterator().next();
+            Assert.assertNotNull(d.getClassName());
+            Assert.assertTrue(d.getAttributes().containsKey("class"));
+        }
+    }
 
 
     /**



Mime
View raw message