int fileCount = 0;
ClassFileModelBuilder cfmb = new ClassFileModelBuilder();
String[] paths = getContext().getClassPath().split(File.pathSeparator);
for (int i = 0; i < paths.length; i++) {
FileSystemResourceLoader loader = new FileSystemResourceLoader();
ResourcePatternResolver resourcePatternResolver = new PathMatchingResourcePatternResolver(loader);
String ending = "/"+ ((basePackage.length() > 0) ? basePackage.replace(".", "/") + "/" : "") + pattern;
if (paths[i].startsWith("/")) {
paths[i] = "file:" + paths[i];
}
if (paths[i].endsWith(".jar")) {
paths[i] = "jar:"+ paths[i] + "!";
}
String packageSearchPath =paths[i]+ending;
getContext().getLogger().send("Searching: "+packageSearchPath);
Resource[] resources = resourcePatternResolver.getResources(packageSearchPath);
for (Resource resource : resources) {
fileCount++;
cfmb.visit(resource);
}