// }
if (!(specDD instanceof Lifecycle)) {
return;
}
Lifecycle lifecycle = (Lifecycle) specDD;
AbstractFinder classFinder = module.getClassFinder();
//TODO Need to double check the LifecycleMethod Scanning, seems we also do it in the OpenEJB
String componentType = null;
if (specDD instanceof EnterpriseBean) {
componentType = ((EnterpriseBean) specDD).getEjbClass();
} else if (specDD instanceof Interceptor) {
componentType = ((Interceptor) specDD).getInterceptorClass();
} else if (specDD instanceof ApplicationClient) {
componentType = ((ApplicationClient) specDD).getMainClass();
}
Map<String, LifecycleCallback> postConstructMap = mapLifecycleCallbacks(lifecycle.getPostConstruct(), componentType);
Map<String, LifecycleCallback> preDestroyMap = mapLifecycleCallbacks(lifecycle.getPreDestroy(), componentType);
if (module.getClassFinder() != null) {
List<Method> postConstructs = classFinder.findAnnotatedMethods(PostConstruct.class);
for (Method m : postConstructs) {
String methodName = m.getName();
String className = m.getDeclaringClass().getName();
if (!postConstructMap.containsKey(className)) {
LifecycleCallback callback = new LifecycleCallback();
callback.setLifecycleCallbackClass(className);
callback.setLifecycleCallbackMethod(methodName);
lifecycle.getPostConstruct().add(callback);
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)) {
LifecycleCallback callback = new LifecycleCallback();