You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stanbol.apache.org by su...@apache.org on 2012/04/10 09:36:44 UTC

svn commit: r1311616 - /incubator/stanbol/trunk/commons/web/sparql/src/main/java/org/apache/stanbol/commons/web/sparql/resource/SparqlEndpointResource.java

Author: suat
Date: Tue Apr 10 07:36:44 2012
New Revision: 1311616

URL: http://svn.apache.org/viewvc?rev=1311616&view=rev
Log:
STANBOL-580: Used directly BundleContext instead of ServiceTracker

Modified:
    incubator/stanbol/trunk/commons/web/sparql/src/main/java/org/apache/stanbol/commons/web/sparql/resource/SparqlEndpointResource.java

Modified: incubator/stanbol/trunk/commons/web/sparql/src/main/java/org/apache/stanbol/commons/web/sparql/resource/SparqlEndpointResource.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/commons/web/sparql/src/main/java/org/apache/stanbol/commons/web/sparql/resource/SparqlEndpointResource.java?rev=1311616&r1=1311615&r2=1311616&view=diff
==============================================================================
--- incubator/stanbol/trunk/commons/web/sparql/src/main/java/org/apache/stanbol/commons/web/sparql/resource/SparqlEndpointResource.java (original)
+++ incubator/stanbol/trunk/commons/web/sparql/src/main/java/org/apache/stanbol/commons/web/sparql/resource/SparqlEndpointResource.java Tue Apr 10 07:36:44 2012
@@ -56,14 +56,13 @@ import org.osgi.framework.BundleContext;
 import org.osgi.framework.Constants;
 import org.osgi.framework.InvalidSyntaxException;
 import org.osgi.framework.ServiceReference;
-import org.osgi.util.tracker.ServiceTracker;
 
 import com.sun.jersey.api.view.Viewable;
 
 /**
- * This is the SPARQL endpoint which is used throughout the Stanbol. It tracks the {@link TripleCollection}s,
- * using a {@link ServiceTracker}, registered to OSGi environment. To be able to execute SPARQL queries on
- * triple collections, they should be registered to the OSGi environment with the following parameters:
+ * This is the SPARQL endpoint which is used throughout the Stanbol. It uses {@link BundleContext} to retrive
+ * {@link TripleCollection} s registered to OSGi environment. To be able to execute SPARQL queries on triple
+ * collections, they should be registered to the OSGi environment with the following parameters:
  * 
  * <p>
  * <ul>
@@ -189,19 +188,16 @@ public class SparqlEndpointResource exte
     private LinkedHashMap<ServiceReference,TripleCollection> getServices(String graphUri) throws InvalidSyntaxException {
         LinkedHashMap<ServiceReference,TripleCollection> registeredGraphs = new LinkedHashMap<ServiceReference,TripleCollection>();
         BundleContext bundleContext = ContextHelper.getBundleContext(servletContext);
-        ServiceTracker graphTracker = new ServiceTracker(bundleContext,
-                bundleContext.createFilter(getFilter(graphUri)), null);
-        graphTracker.open();
-        ServiceReference[] refs = graphTracker.getServiceReferences();
+        ServiceReference[] refs = bundleContext.getServiceReferences(TripleCollection.class.getName(),
+            getFilter(graphUri));
         if (refs != null) {
             if (refs.length > 1) {
                 Arrays.sort(refs, ServiceReferenceRankingComparator.INSTANCE);
             }
             for (ServiceReference ref : refs) {
-                registeredGraphs.put(ref, (TripleCollection) graphTracker.getService(ref));
+                registeredGraphs.put(ref, (TripleCollection) bundleContext.getService(ref));
             }
         }
-        graphTracker.close();
         return registeredGraphs;
     }