use of org.apache.wicket.util.collections.UrlExternalFormComparator in project wicket by apache.
the class AbstractClassResolver method getResources.
@Override
public Iterator<URL> getResources(final String name) {
Set<URL> resultSet = new TreeSet<>(new UrlExternalFormComparator());
try {
// Try the classloader for the wicket jar/bundle
Enumeration<URL> resources = Application.class.getClassLoader().getResources(name);
loadResources(resources, resultSet);
// Try the classloader for the user's application jar/bundle
resources = Application.get().getClass().getClassLoader().getResources(name);
loadResources(resources, resultSet);
// Try the context class loader
resources = getClassLoader().getResources(name);
loadResources(resources, resultSet);
} catch (Exception e) {
throw new WicketRuntimeException(e);
}
return resultSet.iterator();
}
use of org.apache.wicket.util.collections.UrlExternalFormComparator in project wicket by apache.
the class CompoundClassResolver method getResources.
/**
* {@inheritDoc}
* <p>
* This implementation iterates through all {@link IClassResolver}s added, and combines the
* results into one {@link Set} of {@link URL}s, and returns an {@link Iterator} for the set.
* {@link URL}s are unique in the set.
*
* @param name
* The name of the resource to find.
* @return An {@link Iterator} of all the {@link URL}s matching the resource name.
*/
@Override
public Iterator<URL> getResources(final String name) {
Args.notNull(name, "name");
Set<URL> urls = new TreeSet<URL>(new UrlExternalFormComparator());
for (IClassResolver resolver : resolvers) {
Iterator<URL> it = resolver.getResources(name);
while (it.hasNext()) {
URL url = it.next();
urls.add(url);
}
}
return urls.iterator();
}
Aggregations