package bndtools;

import java.io.File;
import java.io.OutputStream;
import java.io.Writer;
import java.util.Map;
import java.util.Set;

import org.osgi.framework.BundleContext;
import org.osgi.service.indexer.ResourceIndexer;
import org.osgi.util.tracker.ServiceTracker;

public class ResourceIndexerTracker extends ServiceTracker implements ResourceIndexer {

    private final long timeout;

    public ResourceIndexerTracker(BundleContext context, long timeout) {
        super(context, ResourceIndexer.class.getName(), null);
        this.timeout = timeout;
    }

    public void index(Set<File> files, OutputStream out, Map<String,String> config) throws Exception {
        ResourceIndexer indexer = doGetIndexer();
        indexer.index(files, out, config);
    }

    public void indexFragment(Set<File> files, Writer out, Map<String,String> config) throws Exception {
        ResourceIndexer indexer = doGetIndexer();
        indexer.indexFragment(files, out, config);
    }

    private ResourceIndexer doGetIndexer() throws InterruptedException {
        ResourceIndexer indexer = (ResourceIndexer) waitForService(timeout);
        if (indexer == null)
            throw new IllegalStateException("Resource indexer service not available.");
        return indexer;
    }

}

package bndtools;

import java.io.File;
import java.io.OutputStream;
import java.io.Writer;
import java.util.Map;
import java.util.Set;

import org.osgi.framework.BundleContext;
import org.osgi.service.indexer.ResourceIndexer;
import org.osgi.util.tracker.ServiceTracker;

public class ResourceIndexerTracker extends ServiceTracker implements ResourceIndexer {

    private final long timeout;

    public ResourceIndexerTracker(BundleContext context, long timeout) {
        super(context, ResourceIndexer.class.getName(), null);
        this.timeout = timeout;
    }

    public void index(Set<File> files, OutputStream out, Map<String,String> config) throws Exception {
        ResourceIndexer indexer = doGetIndexer();
        indexer.index(files, out, config);
    }

    public void indexFragment(Set<File> files, Writer out, Map<String,String> config) throws Exception {
        ResourceIndexer indexer = doGetIndexer();
        indexer.indexFragment(files, out, config);
    }

    public IndexResult indexFile(File file) throws Exception {
        ResourceIndexer indexer = doGetIndexer();
        return indexer.indexFile(file);
    }

    private ResourceIndexer doGetIndexer() throws InterruptedException {
        ResourceIndexer indexer = (ResourceIndexer) waitForService(timeout);
        if (indexer == null)
            throw new IllegalStateException("Resource indexer service not available.");
        return indexer;
    }
}

Fix the build: latest bnd includes the most recent repoindex
Fix the build: latest bnd includes the most recent repoindex

Signed-off-by: Ferry Huberts <66e11f9f5d965b69497c7e73d5e808f8b13c1218@pelagic.nl>
