* Parse the content of the class to detect annotated classes.
* @param inC the class to inspect.
*/
private void computeAnnotations(byte[] inC) {
ClassReader cr = new ClassReader(inC);
MetadataCollector collector = new MetadataCollector();
cr.accept(collector, 0);
if (collector.isIgnoredBecauseOfMissingComponent()) {
// No @Component, just skip.
//warn("Annotation processing ignored in " + collector.getClassName() + " - @Component missing");
} else if (collector.isComponentType()) {
boolean toskip = false;
for (int i = 0; !toskip && i < m_metadata.size(); i++) {
Element meta = (Element) m_metadata.get(i);
if (! meta.getName().equals("instance") // Only if its a component type definition,
// so skip instance declaration
&& meta.containsAttribute("name")
&& meta.getAttribute("name").equalsIgnoreCase(collector.getComponentTypeDeclaration().getAttribute("name"))) {
toskip = true;
warn("The component type " + collector.getComponentTypeDeclaration().getAttribute("name") + " is overriden by the metadata file");
}
}
if (!toskip) {
// if no metadata or empty one, create a new array.
Element elem = collector.getComponentTypeDeclaration();
m_metadata.add(elem);
String name = elem.getAttribute("classname");
name = name.replace('.', '/');
name += ".class";
// Creates the ComponentInfo and store bytecode
ComponentInfo info = new ComponentInfo(name, elem);
info.m_bytecode = inC;
m_components.add(info);
// Instantiate ?
if (collector.getInstanceDeclaration() != null) {
//warn("Declaring an empty instance of " + elem.getAttribute("classname"));
m_metadata.add(collector.getInstanceDeclaration());
}
}
}
}