Skip to content

Instantly share code, notes, and snippets.

@brunoadacosta
Created February 15, 2011 21:03
Show Gist options
  • Save brunoadacosta/828233 to your computer and use it in GitHub Desktop.
Save brunoadacosta/828233 to your computer and use it in GitHub Desktop.
Scan de classes do classpath
public class SearchClasses {
private final Logger logger = Logger.getLogger(SearchClasses.class);
public Collection<String> scan() throws IOException {
ClasspathResolver pathResolver = new StandaloneClasspathResolver();
final URL webInfClasses = pathResolver.findWebInfClassesLocation();
AnnotationDB db = createAnnotationDB();
db.scanArchives(webInfClasses);
return db.getAnnotationIndex().get(
javax.persistence.Entity.class.getName());
}
private AnnotationDB createAnnotationDB() {
AnnotationDB db = new AnnotationDB();
db.setScanClassAnnotations(true);
db.setScanFieldAnnotations(false);
db.setScanMethodAnnotations(false);
db.setScanParameterAnnotations(false);
return db;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment