Пример #1
0
 @Override
 public List<String> getSearchComponentNames() {
   final List<String> result = new ArrayList<String>();
   for (final SearchServiceComponent cs : searchServiceComponentRegistry.getAll()) {
     result.add(cs.getClass().getName());
   }
   return result;
 }
Пример #2
0
  private List<SearchResult> search(
      final List<SearchServiceComponent> searchServiceComponents,
      final String query,
      final SessionIdentifier sessionIdentifier,
      final int maxResults) {

    final List<Thread> threads = new ArrayList<Thread>();
    final List<ThreadResult<List<SearchResult>>> threadResults =
        new ArrayList<ThreadResult<List<SearchResult>>>();

    for (final SearchServiceComponent searchServiceComponent : searchServiceComponents) {
      logger.trace(
          "search in searchServiceComponent: " + searchServiceComponent.getClass().getSimpleName());

      final ThreadResult<List<SearchResult>> threadResult = new ThreadResult<List<SearchResult>>();
      threadResults.add(threadResult);
      threads.add(
          threadRunner.run(
              "search",
              new SearchThreadRunner(
                  searchServiceComponent, threadResult, sessionIdentifier, query, maxResults)));
    }

    for (final Thread thread : threads) {
      try {
        thread.join();
      } catch (final InterruptedException e) {
        // nop
      }
    }

    final List<SearchResult> result = new ArrayList<SearchResult>();
    for (final ThreadResult<List<SearchResult>> threadResult : threadResults) {
      final List<SearchResult> list = threadResult.get();
      if (list != null) {
        result.addAll(list);
      }
    }
    Collections.sort(result, searchServiceComponentComparator);
    logger.trace("found " + result.size() + " results");
    return result;
  }