Package org.apache.openejb.jee

Examples of org.apache.openejb.jee.Lifecycle


//            return;
//        }
        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();
                    callback.setLifecycleCallbackClass(className);
                    callback.setLifecycleCallbackMethod(methodName);
                    preDestroyMap.put(className, callback);
                    lifecycle.getPreDestroy().add(callback);
                }
            }
        }
        Map<String, LifecycleMethod> postConstructs = map(postConstructMap);
        Map<String, LifecycleMethod> preDestroys = map(preDestroyMap);
View Full Code Here

TOP

Related Classes of org.apache.openejb.jee.Lifecycle

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.