annotations.add(new AnnotationCacheEntry(
field.getName(), null,
injections.get(field.getName()),
AnnotationCacheEntryType.FIELD));
} else if (field.isAnnotationPresent(Resource.class)) {
Resource annotation = field.getAnnotation(Resource.class);
annotations.add(new AnnotationCacheEntry(
field.getName(), null, annotation.name(),
AnnotationCacheEntryType.FIELD));
} else if (field.isAnnotationPresent(EJB.class)) {
EJB annotation = field.getAnnotation(EJB.class);
annotations.add(new AnnotationCacheEntry(
field.getName(), null, annotation.name(),
AnnotationCacheEntryType.FIELD));
} else if (field.isAnnotationPresent(WebServiceRef.class)) {
WebServiceRef annotation =
field.getAnnotation(WebServiceRef.class);
annotations.add(new AnnotationCacheEntry(
field.getName(), null, annotation.name(),
AnnotationCacheEntryType.FIELD));
} else if (field.isAnnotationPresent(PersistenceContext.class)) {
PersistenceContext annotation =
field.getAnnotation(PersistenceContext.class);
annotations.add(new AnnotationCacheEntry(
field.getName(), null, annotation.name(),
AnnotationCacheEntryType.FIELD));
} else if (field.isAnnotationPresent(PersistenceUnit.class)) {
PersistenceUnit annotation =
field.getAnnotation(PersistenceUnit.class);
annotations.add(new AnnotationCacheEntry(
field.getName(), null, annotation.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(method.getName()),
AnnotationCacheEntryType.SETTER));
break;
}
}
if (method.isAnnotationPresent(Resource.class)) {
Resource annotation = method.getAnnotation(Resource.class);
annotations.add(new AnnotationCacheEntry(
method.getName(),
method.getParameterTypes(),
annotation.name(),
AnnotationCacheEntryType.SETTER));
} else if (method.isAnnotationPresent(EJB.class)) {
EJB annotation = method.getAnnotation(EJB.class);
annotations.add(new AnnotationCacheEntry(
method.getName(),
method.getParameterTypes(),
annotation.name(),
AnnotationCacheEntryType.SETTER));
} else if (method.isAnnotationPresent(WebServiceRef.class)) {
WebServiceRef annotation =
method.getAnnotation(WebServiceRef.class);
annotations.add(new AnnotationCacheEntry(
method.getName(),
method.getParameterTypes(),
annotation.name(),
AnnotationCacheEntryType.SETTER));
} else if (method.isAnnotationPresent(PersistenceContext.class)) {
PersistenceContext annotation =
method.getAnnotation(PersistenceContext.class);
annotations.add(new AnnotationCacheEntry(
method.getName(),
method.getParameterTypes(),
annotation.name(),
AnnotationCacheEntryType.SETTER));
} else if (method.isAnnotationPresent(PersistenceUnit.class)) {
PersistenceUnit annotation =
method.getAnnotation(PersistenceUnit.class);
annotations.add(new AnnotationCacheEntry(
method.getName(),
method.getParameterTypes(),
annotation.name(),
AnnotationCacheEntryType.SETTER));
}
}
postConstruct = findPostConstruct(postConstruct, postConstructFromXml, method);