I think I see where this is going, but it seems a little overly
simplistic to me.  What about something like this (untested)?

@SuppressWarnings("unchecked")
@Override
public Enumeration<URL> findResources(String name) throws IOException {
  LinkedHashSet<URL> results = new LinkedHashSet<URL>();

  // Specifically for
META-INF/services/javax.xml.parsers.SAXParserFactory
  String checkName = name;
  if (checkName.startsWith(META_INF_SERVICES)) {
    checkName = checkName.substring(META_INF_SERVICES.length());
  }

  // For a system path, load from the outside world first without
warning.
  if (isSystemPath(checkName)) {
    for (Enumeration<URL> resources =
systemClassLoader.getResources(name); resources.hasMoreElements();) {
      results.add(resources.nextElement());
    }
  }

  // Check this ClassLoader.
  for (Enumeration<URL> resources = super.findResources(name);
resources.hasMoreElements();) {
    results.add(resources.nextElement());
  }

  // Add any additional system resources, but this time warn.
  if (!isSystemPath(checkName)) {
    Enumeration<URL> resources = systemClassLoader.getResources(name);
    if (resources != null) {
      while (resources.hasMoreElements()) {
        URL next = resources.nextElement();
        if (!results.contains(next)) {
          // Warn, add containing URL to our own ClassLoader.
          String warnMessage = "Server resource '" + name
              + "' was found on the system classpath";
          if (!addContainingClassPathEntry(warnMessage, next, name)) {
            return null;
          }
          results.add(next);
        }
      }
    }
  }

  return new IteratorEnumeration(results.iterator());
}

http://gwt-code-reviews.appspot.com/496802/show

--
http://groups.google.com/group/Google-Web-Toolkit-Contributors

Reply via email to