jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mreut...@apache.org
Subject svn commit: r428267 - in /jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/query: QueryManagerImpl.java QueryTreeBuilder.java QueryTreeBuilderRegistry.java sql/QueryBuilder.java xpath/QueryBuilder.java
Date Thu, 03 Aug 2006 07:08:13 GMT
Author: mreutegg
Date: Thu Aug  3 00:08:12 2006
New Revision: 428267

URL: http://svn.apache.org/viewvc?rev=428267&view=rev
Log:
JCR-523: QueryManagerImpl hardwires supported query languages
- applied Julian Reschke's patch

Modified:
    jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/query/QueryManagerImpl.java
    jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/query/QueryTreeBuilder.java
    jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/query/QueryTreeBuilderRegistry.java
    jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/query/sql/QueryBuilder.java
    jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/query/xpath/QueryBuilder.java

Modified: jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/query/QueryManagerImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/query/QueryManagerImpl.java?rev=428267&r1=428266&r2=428267&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/query/QueryManagerImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/query/QueryManagerImpl.java
Thu Aug  3 00:08:12 2006
@@ -37,9 +37,7 @@
     /**
      * Defines all supported query languages
      */
-    private static final String[] SUPPORTED_QUERIES = new String[]{
-        Query.SQL, Query.XPATH
-    };
+    private static final String[] SUPPORTED_QUERIES = QueryTreeBuilderRegistry.getSupportedLanguages();
 
     /**
      * List of all supported query languages

Modified: jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/query/QueryTreeBuilder.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/query/QueryTreeBuilder.java?rev=428267&r1=428266&r2=428267&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/query/QueryTreeBuilder.java
(original)
+++ jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/query/QueryTreeBuilder.java
Thu Aug  3 00:08:12 2006
@@ -46,6 +46,13 @@
      *         <code>false</code> otherwise.
      */
     boolean canHandle(String language);
+    
+    /**
+     * Returns the set of query languages supported by this builder.
+     * 
+     * @return String array containing the names of the supported languages.
+     */
+    String[] getSupportedLanguages();
 
     /**
      * Creates a String representation of the query node tree in the syntax this

Modified: jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/query/QueryTreeBuilderRegistry.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/query/QueryTreeBuilderRegistry.java?rev=428267&r1=428266&r2=428267&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/query/QueryTreeBuilderRegistry.java
(original)
+++ jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/query/QueryTreeBuilderRegistry.java
Thu Aug  3 00:08:12 2006
@@ -22,8 +22,12 @@
 import javax.imageio.spi.ServiceRegistry;
 import javax.jcr.query.InvalidQueryException;
 import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashSet;
 import java.util.List;
 import java.util.Iterator;
+import java.util.Set;
 
 /**
  * Implements a central access to QueryTreeBuilder instances.
@@ -39,17 +43,26 @@
      * List of <code>QueryTreeBuilder</code> instances known to the classloader.
      */
     private static final List BUILDERS = new ArrayList();
+    
+    /**
+     * Set of languages known to the registered builders.
+     */
+    private static final Set LANGUAGES;
 
     static {
+        Set languages = new HashSet();
         try {
             Iterator it = ServiceRegistry.lookupProviders(QueryTreeBuilder.class,
                     QueryTreeBuilderRegistry.class.getClassLoader());
             while (it.hasNext()) {
-                BUILDERS.add(it.next());
+                QueryTreeBuilder qtb = (QueryTreeBuilder) it.next();
+                BUILDERS.add(qtb);
+                languages.addAll(Arrays.asList(qtb.getSupportedLanguages()));
             }
         } catch (Error e) {
             log.warn("Unable to load providers for QueryTreeBuilder: " + e);
         }
+        LANGUAGES = Collections.unmodifiableSet(languages);
     }
 
     /**
@@ -69,5 +82,15 @@
             }
         }
         throw new InvalidQueryException("Unsupported language: " + language);
+    }
+    
+    /**
+     * Returns the set of query languages supported by all registered
+     * {@link QueryTreeBuilder} implementations.
+     * 
+     * @return String array containing the names of the supported languages.
+     */
+    public static String[] getSupportedLanguages() {
+        return (String[]) LANGUAGES.toArray(new String[LANGUAGES.size()]);
     }
 }

Modified: jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/query/sql/QueryBuilder.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/query/sql/QueryBuilder.java?rev=428267&r1=428266&r2=428267&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/query/sql/QueryBuilder.java
(original)
+++ jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/query/sql/QueryBuilder.java
Thu Aug  3 00:08:12 2006
@@ -45,6 +45,14 @@
     }
 
     /**
+     * This builder supports {@link Query#SQL}.
+     * @inheritDoc
+     */
+    public String[] getSupportedLanguages() {
+        return new String[]{Query.SQL};
+    }
+
+    /**
      * @inheritDoc
      */
     public String toString(QueryRootNode root, NamespaceResolver resolver)

Modified: jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/query/xpath/QueryBuilder.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/query/xpath/QueryBuilder.java?rev=428267&r1=428266&r2=428267&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/query/xpath/QueryBuilder.java
(original)
+++ jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/query/xpath/QueryBuilder.java
Thu Aug  3 00:08:12 2006
@@ -45,6 +45,14 @@
     }
 
     /**
+     * This builder supports {@link Query#XPATH}.
+     * @inheritDoc
+     */
+    public String[] getSupportedLanguages() {
+        return new String[]{Query.XPATH};
+    }
+
+    /**
      * @inheritDoc
      */
     public String toString(QueryRootNode root, NamespaceResolver resolver)



Mime
View raw message