for (TypeDeclaration typeDeclaration : apEnv.getTypeDeclarations()) {
try {
Class currentClass = Class.forName(typeDeclaration.getQualifiedName());
COMPONENT componentAnnotation = typeDeclaration.getAnnotation(COMPONENT.class);
if (componentAnnotation != null) {
String sourceCode = "";
try {
String name = currentClass.getName();
name = "src/main/java/" + name.replace(".", "/") + ".java";
log.debug(name);
BufferedReader bufferedReader = new BufferedReader(new FileReader(name));
String line = null;
while ((line = bufferedReader.readLine()) != null) {
sourceCode = sourceCode + line + "\n";
}
bufferedReader.close();
} catch (Exception e) {
log.error(e);
throw new RuntimeException(e);
}
if (log.isDebugEnabled()) {
log.debug(sourceCode);
}
if (sourceCode != null) {
boolean containsGenerationTags = false;
LineNumberReader sourceFileReader = new LineNumberReader(new StringReader(sourceCode));
StringBuffer sourceCodeBuffer = new StringBuffer();
log.debug("Line number " + sourceFileReader.getLineNumber());
String line = null;
boolean startGeneration = false;
while ((line = sourceFileReader.readLine()) != null) {
if (line.contains("@StartGeneration")) {
sourceCodeBuffer.append(line);
sourceCodeBuffer.append("\n");
startGeneration = true;
containsGenerationTags = true;
log.debug("Processing COMPONENT " + componentAnnotation.classname());
Component component = new Component(componentAnnotation, currentClass);
sourceCodeBuffer.append(processComponentAnnotation(component, currentClass));
}
else {
if(startGeneration){