com.manydesigns.portofino.stripes.ResolverUtil Maven / Gradle / Ivy
package com.manydesigns.portofino.stripes;
import net.sourceforge.stripes.vfs.VFS;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.util.List;
/**
* @author Paolo Predonzani - [email protected]
* @author Angelo Lupo - [email protected]
* @author Giampiero Granatella - [email protected]
* @author Alessio Stalla - [email protected]
*/
public class ResolverUtil extends net.sourceforge.stripes.util.ResolverUtil {
public static final Logger logger = LoggerFactory.getLogger(ResolverUtil.class);
protected String[] extensions = { ".class" };
@Override
public ResolverUtil find(Test test, String packageName) {
String path = getPackagePath(packageName);
ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
try {
ClassLoader classLoader = getClassLoader();
Thread.currentThread().setContextClassLoader(classLoader);
logger.debug("Listing path {} using classloader {}", path, classLoader);
List children = VFS.getInstance().list(path);
logger.debug("Found: {}", children);
for (String child : children) {
for(String extension : extensions) {
if (child.endsWith(extension)) {
addIfMatching(test, child);
break;
}
}
}
} catch (IOException ioe) {
logger.warn("Could not read package: " + packageName, ioe);
} finally {
Thread.currentThread().setContextClassLoader(contextClassLoader);
}
return this;
}
public String[] getExtensions() {
return extensions;
}
public void setExtensions(String... extensions) {
this.extensions = extensions;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy