Пример #1
0
  @Override
  public Set<DefDescriptor<?>> find(DescriptorFilter matcher) {
    final String filterKey = matcher.toString();
    Set<DefRegistry<?>> registries = delegateRegistries.getRegistries(matcher);
    Set<DefDescriptor<?>> matched = Sets.newHashSet();

    for (DefRegistry<?> reg : registries) {
      //
      // This could be a little dangerous, but unless we force all of our
      // registries to implement find, this is necessary.
      //
      if (reg.hasFind()) {
        Set<DefDescriptor<?>> registryResults = null;

        if (reg.isCacheable()) {
          // cache results per registry
          String cacheKey = filterKey + "|" + reg.toString();
          registryResults = descriptorFilterCache.getIfPresent(cacheKey);
          if (registryResults == null) {
            registryResults = reg.find(matcher);
            descriptorFilterCache.put(cacheKey, registryResults);
          }
        } else {
          registryResults = reg.find(matcher);
        }

        matched.addAll(registryResults);
      }
    }
    if (localDescs != null) {
      for (DefDescriptor<? extends Definition> desc : localDescs) {
        if (matcher.matchDescriptor(desc)) {
          matched.add(desc);
        }
      }
    }

    return matched;
  }
Пример #2
0
 private boolean isCacheable(DefRegistry<?> reg) {
   return useCache && reg.isCacheable();
 }