use of org.glassfish.jersey.server.internal.scanning.JarFileScanner in project jersey by jersey.
the class WebAppResourcesScanner method processPaths.
private void processPaths(final String... paths) {
for (final String path : paths) {
final Set<String> resourcePaths = sc.getResourcePaths(path);
if (resourcePaths == null) {
break;
}
compositeResourceFinder.push(new AbstractResourceFinderAdapter() {
private final Deque<String> resourcePathsStack = new LinkedList<String>() {
private static final long serialVersionUID = 3109256773218160485L;
{
for (final String resourcePath : resourcePaths) {
push(resourcePath);
}
}
};
private String current;
private String next;
@Override
public boolean hasNext() {
while (next == null && !resourcePathsStack.isEmpty()) {
next = resourcePathsStack.pop();
if (next.endsWith("/")) {
processPaths(next);
next = null;
} else if (next.endsWith(".jar")) {
try {
compositeResourceFinder.push(new JarFileScanner(sc.getResourceAsStream(next), "", true));
} catch (final IOException ioe) {
throw new ResourceFinderException(ioe);
}
next = null;
}
}
return next != null;
}
@Override
public String next() {
if (next != null || hasNext()) {
current = next;
next = null;
return current;
}
throw new NoSuchElementException();
}
@Override
public InputStream open() {
return sc.getResourceAsStream(current);
}
@Override
public void reset() {
throw new UnsupportedOperationException();
}
});
}
}
Aggregations