for (Field field : fields) {
Resource resourceAnnotation;
EJB ejbAnnotation;
WebServiceRef webServiceRefAnnotation;
PersistenceContext persistenceContextAnnotation;
PersistenceUnit persistenceUnitAnnotation;
if (injections != null && injections.containsKey(field.getName())) {
annotations.add(new AnnotationCacheEntry(
field.getName(), null,
injections.get(field.getName()),
AnnotationCacheEntryType.FIELD));
} else if ((resourceAnnotation =
field.getAnnotation(Resource.class)) != null) {
annotations.add(new AnnotationCacheEntry(field.getName(), null,
resourceAnnotation.name(), AnnotationCacheEntryType.FIELD));
} else if ((ejbAnnotation =
field.getAnnotation(EJB.class)) != null) {
annotations.add(new AnnotationCacheEntry(field.getName(), null,
ejbAnnotation.name(), AnnotationCacheEntryType.FIELD));
} else if ((webServiceRefAnnotation =
field.getAnnotation(WebServiceRef.class)) != null) {
annotations.add(new AnnotationCacheEntry(field.getName(), null,
webServiceRefAnnotation.name(),
AnnotationCacheEntryType.FIELD));
} else if ((persistenceContextAnnotation =
field.getAnnotation(PersistenceContext.class)) != null) {
annotations.add(new AnnotationCacheEntry(field.getName(), null,
persistenceContextAnnotation.name(),
AnnotationCacheEntryType.FIELD));
} else if ((persistenceUnitAnnotation =
field.getAnnotation(PersistenceUnit.class)) != null) {
annotations.add(new AnnotationCacheEntry(field.getName(), null,
persistenceUnitAnnotation.name(),
AnnotationCacheEntryType.FIELD));
}
}
}
// Initialize methods annotations
Method[] methods = Introspection.getDeclaredMethods(clazz);
Method postConstruct = null;
String postConstructFromXml = postConstructMethods.get(clazz.getName());
Method preDestroy = null;
String preDestroyFromXml = preDestroyMethods.get(clazz.getName());
for (Method method : methods) {
if (context != null) {
// Resource injection only if JNDI is enabled
if (injections != null &&
Introspection.isValidSetter(method)) {
String fieldName = Introspection.getPropertyName(method);
if (injections.containsKey(fieldName)) {
annotations.add(new AnnotationCacheEntry(
method.getName(),
method.getParameterTypes(),
injections.get(fieldName),
AnnotationCacheEntryType.SETTER));
continue;
}
}
Resource resourceAnnotation;
EJB ejbAnnotation;
WebServiceRef webServiceRefAnnotation;
PersistenceContext persistenceContextAnnotation;
PersistenceUnit persistenceUnitAnnotation;
if ((resourceAnnotation =
method.getAnnotation(Resource.class)) != null) {
annotations.add(new AnnotationCacheEntry(
method.getName(),
method.getParameterTypes(),
resourceAnnotation.name(),
AnnotationCacheEntryType.SETTER));
} else if ((ejbAnnotation =
method.getAnnotation(EJB.class)) != null) {
annotations.add(new AnnotationCacheEntry(
method.getName(),
method.getParameterTypes(),
ejbAnnotation.name(),
AnnotationCacheEntryType.SETTER));
} else if ((webServiceRefAnnotation =
method.getAnnotation(WebServiceRef.class)) != null) {
annotations.add(new AnnotationCacheEntry(
method.getName(),
method.getParameterTypes(),
webServiceRefAnnotation.name(),
AnnotationCacheEntryType.SETTER));
} else if ((persistenceContextAnnotation =
method.getAnnotation(PersistenceContext.class)) != null) {
annotations.add(new AnnotationCacheEntry(
method.getName(),
method.getParameterTypes(),
persistenceContextAnnotation.name(),
AnnotationCacheEntryType.SETTER));
} else if ((persistenceUnitAnnotation = method.getAnnotation(PersistenceUnit.class)) != null) {
annotations.add(new AnnotationCacheEntry(
method.getName(),
method.getParameterTypes(),
persistenceUnitAnnotation.name(),
AnnotationCacheEntryType.SETTER));
}
}
postConstruct = findPostConstruct(postConstruct, postConstructFromXml, method);