You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stanbol.apache.org by rw...@apache.org on 2012/07/25 14:21:19 UTC

svn commit: r1365550 - /incubator/stanbol/branches/contenthub-two-layered-structure/commons/semanticindex/core/src/main/java/org/apache/stanbol/commons/semanticindex/core/index/SemanticIndexManagerImpl.java

Author: rwesten
Date: Wed Jul 25 12:21:18 2012
New Revision: 1365550

URL: http://svn.apache.org/viewvc?rev=1365550&view=rev
Log:
SemanticIndexManager does no longer get Servcices from the BundleContext but instead uses the ServiceTracker (STANBOL-471)

Modified:
    incubator/stanbol/branches/contenthub-two-layered-structure/commons/semanticindex/core/src/main/java/org/apache/stanbol/commons/semanticindex/core/index/SemanticIndexManagerImpl.java

Modified: incubator/stanbol/branches/contenthub-two-layered-structure/commons/semanticindex/core/src/main/java/org/apache/stanbol/commons/semanticindex/core/index/SemanticIndexManagerImpl.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/branches/contenthub-two-layered-structure/commons/semanticindex/core/src/main/java/org/apache/stanbol/commons/semanticindex/core/index/SemanticIndexManagerImpl.java?rev=1365550&r1=1365549&r2=1365550&view=diff
==============================================================================
--- incubator/stanbol/branches/contenthub-two-layered-structure/commons/semanticindex/core/src/main/java/org/apache/stanbol/commons/semanticindex/core/index/SemanticIndexManagerImpl.java (original)
+++ incubator/stanbol/branches/contenthub-two-layered-structure/commons/semanticindex/core/src/main/java/org/apache/stanbol/commons/semanticindex/core/index/SemanticIndexManagerImpl.java Wed Jul 25 12:21:18 2012
@@ -29,7 +29,6 @@ import org.apache.felix.scr.annotations.
 import org.apache.stanbol.commons.semanticindex.index.IndexManagementException;
 import org.apache.stanbol.commons.semanticindex.index.SemanticIndex;
 import org.apache.stanbol.commons.semanticindex.index.SemanticIndexManager;
-import org.osgi.framework.BundleContext;
 import org.osgi.framework.Constants;
 import org.osgi.framework.ServiceReference;
 import org.osgi.service.component.ComponentContext;
@@ -45,7 +44,6 @@ import org.osgi.util.tracker.ServiceTrac
 @Service
 public class SemanticIndexManagerImpl implements SemanticIndexManager {
     
-	private ComponentContext componentContext;
 	/**
 	 * Compares ServiceReferences based on their {@link Constants#SERVICE_RANKING} and
 	 * {@link Constants#SERVICE_ID}. This is internally used to ensure that methods that
@@ -79,7 +77,6 @@ public class SemanticIndexManagerImpl im
 
     @Activate
     protected void activate(ComponentContext componentContext) {
-        this.componentContext = componentContext;
         semanticIndexTracker = new ServiceTracker(componentContext.getBundleContext(),
                 SemanticIndex.class.getName(), null);
         semanticIndexTracker.open();
@@ -129,7 +126,6 @@ public class SemanticIndexManagerImpl im
     }
 
     private List<SemanticIndex<?>> getIndexList(String name, String endpointType, boolean multiple) {
-        BundleContext bundleContext = componentContext.getBundleContext();
         List<SemanticIndex<?>> results = new ArrayList<SemanticIndex<?>>();
         ServiceReference[] refs = semanticIndexTracker.getServiceReferences();
         if (refs != null) {
@@ -138,7 +134,7 @@ public class SemanticIndexManagerImpl im
                 Arrays.sort(refs, SERVICE_REFERENCE_COMPARATOR);
             }
             for (ServiceReference ref : refs) {
-                SemanticIndex<?> si = (SemanticIndex<?>) bundleContext.getService(ref);
+                SemanticIndex<?> si = (SemanticIndex<?>) semanticIndexTracker.getService(ref);
                 if (name == null || name.equals(si.getName())) {
                     if (endpointType == null) {
                         results.add(si);
@@ -151,8 +147,6 @@ public class SemanticIndexManagerImpl im
                             endpointTypes = si.getSearchEndPoints().keySet();
                             if (endpointTypes != null && endpointTypes.contains(endpointType)) {
                                 results.add(si);
-                            } else { // service does not match requirements -> unget the service
-                                bundleContext.ungetService(ref);
                             }
                         }
                     }