ResolverUtil is used to locate classes that are available in the/a class path and meet arbitrary conditions. The two most common conditions are that a class implements/extends another class, or that is it annotated with a specific annotation. However, through the use of the {@link Test} class it ispossible to search using arbitrary conditions.
A ClassLoader is used to locate all locations (directories and jar files) in the class path that contain classes within certain packages, and then to load those classes and check them. By default the ClassLoader returned by {@code Thread.currentThread().getContextClassLoader()} is used, but this canbe overridden by calling {@link #setClassLoader(ClassLoader)} prior toinvoking any of the {@code find()} methods.
General searches are initiated by calling the {@link #find(ResolverUtil.Test,String)} ()} method and supplying a packagename and a Test instance. This will cause the named package and all sub-packages to be scanned for classes that meet the test. There are also utility methods for the common use cases of scanning multiple packages for extensions of particular classes, or classes annotated with a specific annotation.
The standard usage pattern for the ResolverUtil class is as follows:
esolverUtil<ActionBean> resolver = new ResolverUtil<ActionBean>(); esolver.findImplementation(ActionBean.class, pkg1, pkg2); esolver.find(new CustomTest(), pkg1); esolver.find(new CustomTest(), pkg2); ollection<ActionBean> beans = resolver.getClasses();
@author Tim Fennell