Examples of ResourceIndexer


Examples of org.osgi.service.indexer.ResourceIndexer

        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);
    }
View Full Code Here

Examples of org.osgi.service.indexer.ResourceIndexer

        ResourceIndexer indexer = doGetIndexer();
        indexer.indexFragment(files, out, config);
    }

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

Examples of org.osgi.service.indexer.ResourceIndexer

        ResourceIndexer indexer = doGetIndexer();
        return indexer.indexFile(file);
    }

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

Examples of org.osgi.service.indexer.ResourceIndexer

    deleteWithException(tempDir);
  }

  public void testBasicServiceInvocation() throws Exception {
    ServiceReference ref = context.getServiceReference(ResourceIndexer.class.getName());
    ResourceIndexer indexer = (ResourceIndexer) context.getService(ref);

    StringWriter writer = new StringWriter();

    Map<String, String> config = new HashMap<String, String>();
    config.put(ResourceIndexer.ROOT_URL, tempDir.getAbsoluteFile().toURI().toString());
    indexer.indexFragment(Collections.singleton(copyToTempFile(tempDir, "testdata/01-bsn+version.jar")), writer, config);

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

    context.ungetService(ref);
  }
View Full Code Here

Examples of org.osgi.service.indexer.ResourceIndexer

  // Test whiteboard registration of Resource Analyzers.
  public void testWhiteboardAnalyzer() throws Exception {
    ServiceRegistration reg = context.registerService(ResourceAnalyzer.class.getName(), new WibbleAnalyzer(), null);

    ServiceReference ref = context.getServiceReference(ResourceIndexer.class.getName());
    ResourceIndexer indexer = (ResourceIndexer) context.getService(ref);
    StringWriter writer = new StringWriter();

    Map<String, String> config = new HashMap<String, String>();
    config.put(ResourceIndexer.ROOT_URL, tempDir.getAbsoluteFile().toURI().toString());
    indexer.indexFragment(Collections.singleton(copyToTempFile(tempDir, "testdata/01-bsn+version.jar")), writer, config);

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

    context.ungetService(ref);
    reg.unregister();
View Full Code Here

Examples of org.osgi.service.indexer.ResourceIndexer

    Dictionary<String, Object> analyzerProps = new Hashtable<String, Object>();
    analyzerProps.put(ResourceAnalyzer.FILTER, "(location=*sion.jar)");
    ServiceRegistration reg = context.registerService(ResourceAnalyzer.class.getName(), new WibbleAnalyzer(), analyzerProps);

    ServiceReference ref = context.getServiceReference(ResourceIndexer.class.getName());
    ResourceIndexer indexer = (ResourceIndexer) context.getService(ref);
    StringWriter writer = new StringWriter();

    Set<File> files = new LinkedHashSet<File>();
    files.add(copyToTempFile(tempDir, "testdata/01-bsn+version.jar"));
    files.add(copyToTempFile(tempDir, "testdata/02-localization.jar"));

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

    assertEquals(readStream(TestOSGiServices.class.getResourceAsStream("/testdata/fragment-wibble-filtered.txt")), writer.toString().trim());

    context.ungetService(ref);
    reg.unregister();
View Full Code Here

Examples of org.osgi.service.indexer.ResourceIndexer

    };
    ServiceRegistration mockAnalyzerReg = context.registerService(ResourceAnalyzer.class.getName(), brokenAnalyzer, null);

    // Call the indexer
    ServiceReference ref = context.getServiceReference(ResourceIndexer.class.getName());
    ResourceIndexer indexer = (ResourceIndexer) context.getService(ref);
    StringWriter writer = new StringWriter();
    Set<File> files = Collections.singleton(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(files, writer, config);

    // Verify log output
    ArgumentCaptor<Exception> exceptionCaptor = ArgumentCaptor.forClass(Exception.class);
    verify(mockLog).log(any(ServiceReference.class), eq(LogService.LOG_ERROR), anyString(), exceptionCaptor.capture());
    assertEquals("Bang!", exceptionCaptor.getValue().getMessage());
View Full Code Here

Examples of org.osgi.service.indexer.ResourceIndexer

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

Examples of org.osgi.service.indexer.ResourceIndexer

      framework.start();
     
      // Look for indexer and run index generation
      ServiceTracker tracker = new ServiceTracker(framework.getBundleContext(), ResourceIndexer.class.getName(), null);
      tracker.open();
      ResourceIndexer index = (ResourceIndexer) tracker.waitForService(1000);
      if (index == null)
        throw new IllegalStateException("Timed out waiting for ResourceIndexer service.");

      // Process arguments
      Set<File> fileList = new LinkedHashSet<File>();
      Map<String, String> config = new HashMap<String, String>();
      File outputFile = processArgs(args, config, fileList, framework.getBundleContext());
     
      // Run
      if (fileList.isEmpty())
        printUsage();
      else try {
        index.index(fileList, new FileOutputStream(outputFile), config);
      } catch (Exception e) {
        e.printStackTrace();
      }
    } catch (Exception e) {
      System.err.println(e.getMessage());
View Full Code Here

Examples of org.osgi.service.indexer.ResourceIndexer

      framework.start();

      // Look for indexer and run index generation
      ServiceTracker tracker = new ServiceTracker(framework.getBundleContext(), ResourceIndexer.class.getName(), null);
      tracker.open();
      ResourceIndexer index = (ResourceIndexer) tracker.waitForService(1000);
      if (index == null)
        throw new IllegalStateException("Timed out waiting for ResourceIndexer service.");

      // Process arguments
      Set<File> fileList = new LinkedHashSet<File>();
      Map<String, String> config = new HashMap<String, String>();
      File outputFile = processArgs(args, System.err, config, fileList, framework.getBundleContext());
      if (outputFile == null) {
        System.exit(1);
      }

      boolean verbose = Boolean.parseBoolean(config.get(ResourceIndexer.VERBOSE));
      if (verbose) {
        printCopyright(System.err);
      }

      FileOutputStream fos = null;
      try {
        fos = new FileOutputStream(outputFile);
        index.index(fileList, fos, config);
      } catch (Exception e) {
        e.printStackTrace();
      } finally {
        if (fos != null) {
          try {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.