Methods Summary |
---|
private void | addEntry(java.util.jar.JarEntry je)
String className = je.getName().replace('/", '.");
className = className.substring(0, className.length()-6);
entries.add(className);
|
private void | addEntry(java.io.File top, java.io.File f)
String fileName = f.getPath();
fileName = fileName.substring(top.getPath().length()+1);
String className = fileName.replace(File.separatorChar, '.");
className = className.substring(0, className.length()-6);
entries.add(className);
|
protected void | addScanClassName(java.lang.String className)This add extra className to be scanned.
if (className!=null && className.length()!=0)
entries.add(className);
|
protected void | addScanDirectory(java.io.File directory)This will include all class in directory to be scanned.
param directory
initScanDirectory(directory, directory);
|
protected void | addScanJar(java.io.File jarFile)This add all classes in given jarFile to be scanned.
JarFile jf = new JarFile(jarFile);
Enumeration<JarEntry> entriesEnum = jf.entries();
while(entriesEnum.hasMoreElements()) {
JarEntry je = entriesEnum.nextElement();
if (je.getName().endsWith(".class")) {
if (processAllClasses) {
addEntry(je);
} else {
// check if it contains top level annotations...
ReadableByteChannel channel = Channels.newChannel(jf.getInputStream(je));
if (channel!=null) {
if (classFile.containsAnnotation(channel, je.getSize())) {
addEntry(je);
}
}
}
}
}
|
public java.lang.ClassLoader | getClassLoader()
return classLoader;
|
public java.util.Set | getElements()
Set<Class> elements = new HashSet<Class>();
if (getClassLoader() == null) {
AnnotationUtils.getLogger().severe("Class loader null");
return elements;
}
for (String className : entries) {
if (AnnotationUtils.getLogger().isLoggable(Level.FINE)) {
AnnotationUtils.getLogger().fine("Getting " + className);
}
try {
elements.add(classLoader.loadClass(className));
} catch(ClassNotFoundException cnfe) {
AnnotationUtils.getLogger().log(Level.WARNING, "Cannot load " + className + " reason : " + cnfe.getMessage(), cnfe);
}
}
return elements;
|
private void | initScanDirectory(java.io.File top, java.io.File directory)
File[] files = directory.listFiles();
for (File file : files) {
if (file.isFile()) {
String fileName = file.getPath();
if (fileName.endsWith(".class")) {
if (processAllClasses) {
addEntry(top, file);
} else {
FileInputStream fis = null;
try {
fis = new FileInputStream(file);
if (classFile.containsAnnotation(fis.getChannel(), file.length())) {
addEntry(top, file);
}
} finally {
if (fis != null) {
fis.close();
}
}
}
}
} else {
initScanDirectory(top, file);
}
}
|