List<Method> postConstructs = classFinder.findAnnotatedMethods(PostConstruct.class);
for (Method m : postConstructs) {
String methodName = m.getName();
String className = m.getDeclaringClass().getName();
if (!postConstructMap.containsKey(className)) {
LifecycleCallbackType callback = annotatedApp.addPostConstruct();
FullyQualifiedClassType classType = callback.addNewLifecycleCallbackClass();
classType.setStringValue(className);
JavaIdentifierType method = callback.addNewLifecycleCallbackMethod();
method.setStringValue(methodName);
postConstructMap.put(className, callback);
}
}
List<Method> preDestroys = classFinder.findAnnotatedMethods(PreDestroy.class);
for (Method m : preDestroys) {
String methodName = m.getName();
String className = m.getDeclaringClass().getName();
if (!preDestroyMap.containsKey(className)) {
LifecycleCallbackType callback = annotatedApp.addPreDestroy();
FullyQualifiedClassType classType = callback.addNewLifecycleCallbackClass();
classType.setStringValue(className);
JavaIdentifierType method = callback.addNewLifecycleCallbackMethod();
method.setStringValue(methodName);
preDestroyMap.put(className, callback);
}
}
}