Package org.osgi.service.indexer.impl

Examples of org.osgi.service.indexer.impl.RepoIndex


            indexFile = new File(target, INDEX_FILENAME);

            IFile indexPath = wsroot.getFile(Central.toPath(indexFile));

            // Create the indexer and add ResourceAnalyzers from plugins
            RepoIndex indexer = new RepoIndex(logAdapter);
            List<ResourceAnalyzer> analyzers = Central.getWorkspace().getPlugins(ResourceAnalyzer.class);
            for (ResourceAnalyzer analyzer : analyzers) {
                indexer.addAnalyzer(analyzer, null);
            }

            // Use an analyzer to add a marker capability to workspace resources
            indexer.addAnalyzer(new ResourceAnalyzer() {
                public void analyzeResource(Resource resource, List<Capability> capabilities, List<Requirement> requirements) throws Exception {
                    Capability cap = new Builder().setNamespace("bndtools.workspace").addAttribute("bndtools.workspace", workspaceRootUri.toString()).addAttribute("project.path", project.getFullPath().toString()).buildCapability();
                    capabilities.add(cap);
                }
            }, null);

            Map<String,String> config = new HashMap<String,String>();
            config.put(ResourceIndexer.REPOSITORY_NAME, project.getName());
            config.put(ResourceIndexer.ROOT_URL, project.getLocation().toFile().toURI().toString());
            config.put(ResourceIndexer.PRETTY, "true");

            output = new FileOutputStream(indexFile);
            indexer.index(files, output, config);
            IO.close(output);
            indexPath.refreshLocal(IResource.DEPTH_ZERO, null);
            if (indexPath.exists())
                indexPath.setDerived(true, null);
        } catch (Exception e) {
View Full Code Here


            indexFile = new File(target, INDEX_FILENAME);

            IFile indexPath = wsroot.getFile(Central.toPath(indexFile));

            // Create the indexer and add ResourceAnalyzers from plugins
            RepoIndex indexer = new RepoIndex(logAdapter);
            List<ResourceAnalyzer> analyzers = Central.getWorkspace().getPlugins(ResourceAnalyzer.class);
            for (ResourceAnalyzer analyzer : analyzers) {
                indexer.addAnalyzer(analyzer, null);
            }

            // Use an analyzer to add a marker capability to workspace resources
            indexer.addAnalyzer(new ResourceAnalyzer() {
                public void analyzeResource(Resource resource, List<Capability> capabilities, List<Requirement> requirements) throws Exception {
                    Capability cap = new Builder().setNamespace("bndtools.workspace").addAttribute("bndtools.workspace", workspaceRootUri.toString()).addAttribute("project.path", project.getFullPath().toString()).buildCapability();
                    capabilities.add(cap);
                }
            }, null);

            Map<String,String> config = new HashMap<String,String>();
            config.put(ResourceIndexer.REPOSITORY_NAME, project.getName());
            config.put(ResourceIndexer.ROOT_URL, project.getLocation().toFile().toURI().toString());
            config.put(ResourceIndexer.PRETTY, "true");

            output = new FileOutputStream(indexFile);
            indexer.index(files, output, config);
            IO.close(output);
            indexPath.refreshLocal(IResource.DEPTH_ZERO, null);
            if (indexPath.exists())
                indexPath.setDerived(true);
        } catch (Exception e) {
View Full Code Here

                    files.add(file);
                }
            }
        }

        RepoIndex indexer = new RepoIndex();
        Map<String, String> config = new HashMap<String, String>();
        config.put(ResourceIndexer.REPOSITORY_NAME, "empty");
        config.put(ResourceIndexer.PRETTY, "true");
        config.put(ResourceIndexer.ROOT_URL, rootDir.getAbsoluteFile().toURI().toURL().toString());

        FileOutputStream out = new FileOutputStream(indexFile);
        try {
            indexer.index(files, out, config);
        }
        finally {
            out.close();
        }
        return indexFile.toURI().toURL();
View Full Code Here

import org.osgi.service.indexer.impl.RepoIndex;

public class TestStandaloneLibrary extends TestCase {

  public void testBasicServiceInvocation() throws Exception {
    ResourceIndexer indexer = new RepoIndex();

    StringWriter writer = new StringWriter();
    File tempDir = createTempDir();
    File tempFile = copyToTempFile(tempDir, "testdata/01-bsn+version.jar");

    Map<String, String> config = new HashMap<String, String>();
    config.put(ResourceIndexer.ROOT_URL, tempDir.getAbsoluteFile().toURI().toString());
    indexer.indexFragment(Collections.singleton(tempFile), writer, config);

    assertEquals(readStream(TestStandaloneLibrary.class.getResourceAsStream("/testdata/fragment-basic.txt")), writer.toString().trim());

    deleteWithException(tempDir);
  }
View Full Code Here

    deleteWithException(tempDir);
  }

  public void testKnownBundleRecognition() throws Exception {
    RepoIndex indexer = new RepoIndex();
    indexer.addAnalyzer(new KnownBundleAnalyzer(), FrameworkUtil.createFilter("(name=*)"));

    StringWriter writer = new StringWriter();
    File tempDir = createTempDir();
    File tempFile = copyToTempFile(tempDir, "testdata/org.eclipse.equinox.ds-1.4.0.jar");

    Map<String, String> config = new HashMap<String, String>();
    config.put(ResourceIndexer.ROOT_URL, tempDir.getAbsoluteFile().toURI().toString());
    indexer.indexFragment(Collections.singleton(tempFile), writer, config);

    assertEquals(readStream(TestStandaloneLibrary.class.getResourceAsStream("/testdata/org.eclipse.equinox.ds-1.4.0.fragment.txt")), writer.toString().trim());

    deleteWithException(tempDir);
  }
View Full Code Here

    extras.setProperty("org.eclipse.equinox.ds;[1.4,1.5)", "cap=extra;extra=wibble");

    KnownBundleAnalyzer knownBundlesAnalyzer = new KnownBundleAnalyzer();
    knownBundlesAnalyzer.setKnownBundlesExtra(extras);

    RepoIndex indexer = new RepoIndex();
    indexer.addAnalyzer(knownBundlesAnalyzer, FrameworkUtil.createFilter("(name=*)"));

    StringWriter writer = new StringWriter();
    File tempDir = createTempDir();
    File tempFile = copyToTempFile(tempDir, "testdata/org.eclipse.equinox.ds-1.4.0.jar");

    Map<String, String> config = new HashMap<String, String>();
    config.put(ResourceIndexer.ROOT_URL, tempDir.getAbsoluteFile().toURI().toString());
    indexer.indexFragment(Collections.singleton(tempFile), writer, config);

    assertEquals(readStream(TestStandaloneLibrary.class.getResourceAsStream("/testdata/org.eclipse.equinox.ds-1.4.0.extra-fragment.txt")), writer.toString().trim());

    deleteWithException(tempDir);
  }
View Full Code Here

    deleteWithException(tempDir);
  }

  public void testPlainJar() throws Exception {
    RepoIndex indexer = new RepoIndex();

    StringWriter writer = new StringWriter();
    File tempDir = createTempDir();
    File tempFile = copyToTempFile(tempDir, "testdata/jcip-annotations.jar");

    Map<String, String> config = new HashMap<String, String>();
    config.put(ResourceIndexer.ROOT_URL, tempDir.getAbsoluteFile().toURI().toString());
    indexer.indexFragment(Collections.singleton(tempFile), writer, config);

    assertEquals(readStream(TestStandaloneLibrary.class.getResourceAsStream("/testdata/plainjar.fragment.txt")), writer.toString().trim());

    deleteWithException(tempDir);
  }
View Full Code Here

  public void start(BundleContext context) throws Exception {
    logTracker = new LogTracker(context);
    logTracker.open();

    RepoIndex indexer = new RepoIndex(logTracker);
   
    analyzerTracker = new AnalyzerTracker(context, indexer, logTracker);
    analyzerTracker.open();

    registration = context.registerService(ResourceIndexer.class.getName(), indexer, null);
View Full Code Here

  public void start(BundleContext context) throws Exception {
    logTracker = new LogTracker(context);
    logTracker.open();

    RepoIndex indexer = new RepoIndex(logTracker);

    analyzerTracker = new AnalyzerTracker(context, indexer, logTracker);
    analyzerTracker.open();

    registration = context.registerService(ResourceIndexer.class.getName(), indexer, null);
View Full Code Here

TOP

Related Classes of org.osgi.service.indexer.impl.RepoIndex

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.