Posted By

narkisr on 05/04/10


Tagged

class java lookup classpath


Versions (?)

Finding classes


 / Published in: Java
 

Using http://www.clapper.org/software/java/util/javadocs/util/api/org/clapper/util/classutil/ClassFinder.html in order to find a class in class path.

  1. File moduleFile = new File(Catalog.class.getProtectionDomain().getCodeSource().getLocation().toURI());
  2. final ClassFinder finder = new ClassFinder();
  3. finder.clear();
  4. assertTrue(finder.add(moduleFile));
  5. final ClassFilter filter = new AndClassFilter(new NotClassFilter(new InterfaceOnlyClassFilter()), new NotClassFilter(new AbstractClassFilter()), new SubclassClassFilter(UpdateTask.class));
  6. Collection<ClassInfo> foundClasses = new ArrayList<ClassInfo>();
  7. finder.findClasses(foundClasses, filter);

Report this snippet  

You need to login to post a comment.