Author: rmannibucau
Date: Wed Oct  9 08:37:43 2013
New Revision: 1530527

URL: http://svn.apache.org/r1530527
Log:
TOMEE-1053 @HandlesTypes support - no more linking but 
enableFindImplementations/enableFindSubclasses

Modified:
    
tomee/tomee/trunk/tomee/tomee-catalina/src/main/java/org/apache/tomee/catalina/OpenEJBContextConfig.java

Modified: 
tomee/tomee/trunk/tomee/tomee-catalina/src/main/java/org/apache/tomee/catalina/OpenEJBContextConfig.java
URL: 
http://svn.apache.org/viewvc/tomee/tomee/trunk/tomee/tomee-catalina/src/main/java/org/apache/tomee/catalina/OpenEJBContextConfig.java?rev=1530527&r1=1530526&r2=1530527&view=diff
==============================================================================
--- 
tomee/tomee/trunk/tomee/tomee-catalina/src/main/java/org/apache/tomee/catalina/OpenEJBContextConfig.java
 (original)
+++ 
tomee/tomee/trunk/tomee/tomee-catalina/src/main/java/org/apache/tomee/catalina/OpenEJBContextConfig.java
 Wed Oct  9 08:37:43 2013
@@ -416,11 +416,8 @@ public class OpenEJBContextConfig extend
 
             if (typeInitializerMap.size() > 0 && finder != null) {
                 final ClassLoader loader = 
context.getLoader().getClassLoader();
-                if (handlesTypesNonAnnotations) {
-                    if (AnnotationFinder.class.isInstance(finder)) {
-                        AnnotationFinder.class.cast(finder).link();
-                    }
-                }
+                boolean foundSubClasses = false;
+                boolean foundImplementations = false;
 
                 for (final Map.Entry<Class<?>, 
Set<ServletContainerInitializer>> entry : typeInitializerMap.entrySet()) {
                     final Class<?> annotation = entry.getKey();
@@ -435,6 +432,19 @@ public class OpenEJBContextConfig extend
                         } else {
                             try { // we need to load the class 
(entry.getKey()) with the finder classloader = tempClassLoader otherwise 
isAssignable is false in almost all cases
                                 logger.info("Using @HandlesTypes on a parent 
class (and not an annotation) is a performance killer. See " + 
annotation.getName() + " on " + sci.getClass().getName());
+                                if (AnnotationFinder.class.isInstance(finder)) 
{
+                                    if (annotation.isInterface()) {
+                                        if (!foundImplementations) {
+                                            
AnnotationFinder.class.cast(finder).enableFindImplementations();
+                                            foundImplementations = true;
+                                        }
+                                    } else {
+                                        if (!foundSubClasses) {
+                                            
AnnotationFinder.class.cast(finder).enableFindSubclasses();
+                                            foundSubClasses = true;
+                                        }
+                                    }
+                                }
 
                                 final Class<?> reloadedClass = 
tempLoader.loadClass(annotation.getName());
                                 final List<Class<?>> implementations = 
List.class.cast(finder.findImplementations(reloadedClass));


Reply via email to