List<Method> methodswithPersistenceContext = classFinder.findAnnotatedMethods(PersistenceContext.class);
List<Field> fieldswithPersistenceContext = classFinder.findAnnotatedFields(PersistenceContext.class);
// Class-level annotation
for (Class cls : classeswithPersistenceContext) {
PersistenceContext persistenceContext = (PersistenceContext) cls.getAnnotation(PersistenceContext.class);
if (persistenceContext != null) {
addPersistenceContext(annotatedApp, persistenceContext, cls, null, null);
}
}
// Method-level annotation
for (Method method : methodswithPersistenceContext) {
PersistenceContext persistenceContext = method.getAnnotation(PersistenceContext.class);
if (persistenceContext != null) {
addPersistenceContext(annotatedApp, persistenceContext, null, method, null);
}
}
// Field-level annotation
for (Field field : fieldswithPersistenceContext) {
PersistenceContext persistenceContext = field.getAnnotation(PersistenceContext.class);
if (persistenceContext != null) {
addPersistenceContext(annotatedApp, persistenceContext, null, null, field);
}
}