|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectca.infoway.messagebuilder.j5goodies.ClassFinder
public class ClassFinder
Find classes on the class path.
One of the sad limitations of Java is that you can't, say, find all classes in a
particular package. Sometimes some forms of reflection would be easier if you didn't
hafta have a master list of class names that you can consult. (An example might be
the hibernate.cfg.xml
file that lists all of your persistent entities).
One strategy for getting around this limitation of Java is to manually scan an entire target directory or jar file, looking for all of the classes and then using some rules ("predicates") to decide if it's a class that you want.
Finding the jar or directory that contains your classes is a tricky exercise, but this utility attempts to help with that.
Constructor Summary | |
---|---|
ClassFinder()
|
Method Summary | |
---|---|
List<Class<?>> |
findClasses(Class<?> context,
ClassPredicate predicate)
Find all classes in the same jar as the contextual class. |
List<Class<?>> |
findClasses(URL pathToManifest,
ClassPredicate predicate)
Find all classes in the same jar as the given manifest. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ClassFinder()
Method Detail |
---|
public List<Class<?>> findClasses(Class<?> context, ClassPredicate predicate)
Find all classes in the same jar as the contextual class.
context
- - the class whose location helps us determine the path to the jar.predicate
- - a class that determines which classes should be included in the
result
public List<Class<?>> findClasses(URL pathToManifest, ClassPredicate predicate)
Find all classes in the same jar as the given manifest.
pathToManifest
- - the resource path to the manifest filepredicate
- - a class that determines which classes should be included in the
result
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |