/**
* @version $Rev: 516141 $ $Date: 2007-03-08 13:45:05 -0500 (Thu, 08 Mar 2007) $
*/
public class LifecycleMethodBuilder extends AbstractNamingBuilder {
public void buildNaming(XmlObject specDD, XmlObject plan, Configuration localConfiguration, Configuration remoteConfiguration, Module module, Map componentContext) throws DeploymentException {
ClassFinder classFinder = module.getClassFinder();
AnnotatedApp annotatedApp = module.getAnnotatedApp();
if (annotatedApp == null) {
throw new NullPointerException("No AnnotatedApp supplied");
}
Map<String, LifecycleCallbackType> postConstructMap = mapLifecycleCallbacks(annotatedApp.getPostConstructArray());
Map<String, LifecycleCallbackType> preDestroyMap = mapLifecycleCallbacks(annotatedApp.getPreDestroyArray());
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)) {
LifecycleCallbackType callback = annotatedApp.addPostConstruct();
FullyQualifiedClassType classType = callback.addNewLifecycleCallbackClass();
classType.setStringValue(className);
JavaIdentifierType method = callback.addNewLifecycleCallbackMethod();
method.setStringValue(methodName);
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)) {
LifecycleCallbackType callback = annotatedApp.addPreDestroy();