use of org.apache.felix.scrplugin.annotations.ScannedClass in project felix by apache.
the class ClassScanner method processClass.
/**
* Scan a single class.
*/
private ClassDescription processClass(final Class<?> annotatedClass, final String location) throws SCRDescriptorFailureException, SCRDescriptorException {
log.debug("Processing " + annotatedClass.getName());
try {
// get the class file for ASM
final String pathToClassFile = annotatedClass.getName().replace('.', '/') + ".class";
final InputStream input = project.getClassLoader().getResourceAsStream(pathToClassFile);
final ClassReader classReader;
try {
classReader = new ClassReader(input);
} finally {
if (input != null) {
input.close();
}
}
final ClassNode classNode = new ClassNode();
classReader.accept(classNode, SKIP_CODE | SKIP_DEBUG | SKIP_FRAMES);
// create descriptions
final List<ScannedAnnotation> annotations = extractAnnotation(classNode, annotatedClass);
if (annotations.size() > 0) {
// process annotations and create descriptions
final ClassDescription desc = new ClassDescription(annotatedClass, location);
aProcessor.process(new ScannedClass(annotations, annotatedClass), desc);
log.debug("Found descriptions " + desc + " in " + annotatedClass.getName());
return desc;
}
} catch (final IllegalArgumentException ioe) {
throw new SCRDescriptorException("Unable to scan class files: " + annotatedClass.getName() + " (Class file format probably not supported by ASM ?)", location, ioe);
} catch (final IOException ioe) {
throw new SCRDescriptorException("Unable to scan class files: " + annotatedClass.getName(), location, ioe);
}
return null;
}
Aggregations