if (fields[i].isAnnotationPresent(Resource.class)) {
Resource annotation = (Resource) fields[i].getAnnotation(Resource.class);
lookupFieldResource(context, instance, fields[i], annotation.name());
}
if (fields[i].isAnnotationPresent(EJB.class)) {
EJB annotation = (EJB) fields[i].getAnnotation(EJB.class);
lookupFieldResource(context, instance, fields[i], annotation.name());
}
if (fields[i].isAnnotationPresent(WebServiceRef.class)) {
WebServiceRef annotation =
(WebServiceRef) fields[i].getAnnotation(WebServiceRef.class);
lookupFieldResource(context, instance, fields[i], annotation.name());
}
if (fields[i].isAnnotationPresent(PersistenceContext.class)) {
PersistenceContext annotation =
(PersistenceContext) fields[i].getAnnotation(PersistenceContext.class);
lookupFieldResource(context, instance, fields[i], annotation.name());
}
if (fields[i].isAnnotationPresent(PersistenceUnit.class)) {
PersistenceUnit annotation =
(PersistenceUnit) fields[i].getAnnotation(PersistenceUnit.class);
lookupFieldResource(context, instance, fields[i], annotation.name());
}
}
// Initialize methods annotations
Method[] methods = instance.getClass().getDeclaredMethods();
for (int i = 0; i < methods.length; i++) {
if (methods[i].isAnnotationPresent(Resource.class)) {
Resource annotation = (Resource) methods[i].getAnnotation(Resource.class);
lookupMethodResource(context, instance, methods[i], annotation.name());
}
if (methods[i].isAnnotationPresent(EJB.class)) {
EJB annotation = (EJB) methods[i].getAnnotation(EJB.class);
lookupMethodResource(context, instance, methods[i], annotation.name());
}
if (methods[i].isAnnotationPresent(WebServiceRef.class)) {
WebServiceRef annotation =
(WebServiceRef) methods[i].getAnnotation(WebServiceRef.class);
lookupMethodResource(context, instance, methods[i], annotation.name());
}
if (methods[i].isAnnotationPresent(PersistenceContext.class)) {
PersistenceContext annotation =
(PersistenceContext) methods[i].getAnnotation(PersistenceContext.class);
lookupMethodResource(context, instance, methods[i], annotation.name());
}
if (methods[i].isAnnotationPresent(PersistenceUnit.class)) {
PersistenceUnit annotation =
(PersistenceUnit) methods[i].getAnnotation(PersistenceUnit.class);
lookupMethodResource(context, instance, methods[i], annotation.name());
}
}
clazz = clazz.getSuperclass();
}