Created
February 15, 2011 21:03
-
-
Save brunoadacosta/828233 to your computer and use it in GitHub Desktop.
Scan de classes do classpath
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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