List of usage examples for javax.tools StandardJavaFileManager list
Iterable<JavaFileObject> list(Location location, String packageName, Set<Kind> kinds, boolean recurse) throws IOException;
From source file:edu.harvard.i2b2.fhir.FhirUtil.java
public static List<Class> getAllFhirResourceClasses(String packageName) throws IOException { // logger.trace("Running getAllFhirResourceClasses for:" + // packageName); List<Class> commands = new ArrayList<Class>(); JavaCompiler compiler = ToolProvider.getSystemJavaCompiler(); StandardJavaFileManager fileManager = compiler.getStandardFileManager(null, null, null); Location location = StandardLocation.CLASS_PATH; Set<JavaFileObject.Kind> kinds = new HashSet<JavaFileObject.Kind>(); kinds.add(JavaFileObject.Kind.CLASS); boolean recurse = false; Iterable<JavaFileObject> list = fileManager.list(location, packageName, kinds, recurse); for (JavaFileObject javaFileObject : list) { // commands.add(javaFileObject.getClass()); }/* www .j a v a 2 s. c om*/ Class c = null; for (String x : Arrays.asList(RESOURCE_LIST_REGEX.replace("(", "").replace(")", "").split("\\|"))) { x = "org.hl7.fhir." + x; // logger.trace("X:"+x); c = Utils.getClassFromClassPath(x); if (c != null) commands.add(c); } // logger.trace(commands.toString()); return commands; }