コード例 #1
0
  protected List<? extends Extension> loadExtensions(final ClassLoader classLoader) {
    final List<Extension> list = loaderService.load(Extension.class, classLoader);
    final Collection<String> additional = ADDITIONAL_EXTENSIONS.get();
    if (additional != null) {
      for (final String name : additional) {
        try {
          list.add(Extension.class.cast(classLoader.loadClass(name).newInstance()));
        } catch (final Exception ignored) {
          // no-op
        }
      }
    }

    final Collection<Extension> extensionCopy = new ArrayList<>(list);

    final Iterator<Extension> it = list.iterator();
    while (it.hasNext()) {
      if (it.hasNext()) {
        if (isFiltered(extensionCopy, it.next())) {
          it.remove();
        }
      }
    }
    return list;
  }
コード例 #2
0
  @Override
  public <T> List<T> load(final Class<T> serviceType, final ClassLoader classLoader) {
    // ServiceLoader is expensive (can take up to a half second).  This is an optimization
    if (OpenWebBeansPlugin.class.equals(serviceType)) {
      return (List<T>) loadWebBeansPlugins(classLoader);
    }

    // As far as we know, this only is reached for CDI Extension discovery
    if (Extension.class.equals(serviceType)) {
      return (List<T>) loadExtensions(classLoader);
    }
    return loaderService.load(serviceType, classLoader);
  }