tomee-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rmannibu...@apache.org
Subject svn commit: r1530524 - in /tomee/tomee/trunk: arquillian/arquillian-tomee-remote/src/test/java/org/apache/openejb/arquillian/handletypes/ container/openejb-core/src/main/java/org/apache/openejb/config/ tomee/tomee-catalina/src/main/java/org/apache/tome...
Date Wed, 09 Oct 2013 08:26:54 GMT
Author: rmannibucau
Date: Wed Oct  9 08:26:53 2013
New Revision: 1530524

URL: http://svn.apache.org/r1530524
Log:
TOMEE-1053 @HandlesTypes support - linking lazily = only when inheritance is used in @HandlesTypes
+ printing a message saying it will be 'slow'

Added:
    tomee/tomee/trunk/arquillian/arquillian-tomee-remote/src/test/java/org/apache/openejb/arquillian/handletypes/AnotherChild.java
    tomee/tomee/trunk/arquillian/arquillian-tomee-remote/src/test/java/org/apache/openejb/arquillian/handletypes/Decorated.java
    tomee/tomee/trunk/arquillian/arquillian-tomee-remote/src/test/java/org/apache/openejb/arquillian/handletypes/Decoration.java
      - copied, changed from r1530497, tomee/tomee/trunk/arquillian/arquillian-tomee-remote/src/test/java/org/apache/openejb/arquillian/handletypes/API.java
    tomee/tomee/trunk/arquillian/arquillian-tomee-remote/src/test/java/org/apache/openejb/arquillian/handletypes/HandleTypesAnnotationOnlyTest.java
    tomee/tomee/trunk/arquillian/arquillian-tomee-remote/src/test/java/org/apache/openejb/arquillian/handletypes/HandleTypesInterfaceOnlyTest.java
      - copied, changed from r1530497, tomee/tomee/trunk/arquillian/arquillian-tomee-remote/src/test/java/org/apache/openejb/arquillian/handletypes/HandleTypesTest.java
    tomee/tomee/trunk/arquillian/arquillian-tomee-remote/src/test/java/org/apache/openejb/arquillian/handletypes/InitAnnotationOnly.java
      - copied, changed from r1530497, tomee/tomee/trunk/arquillian/arquillian-tomee-remote/src/test/java/org/apache/openejb/arquillian/handletypes/Init.java
    tomee/tomee/trunk/arquillian/arquillian-tomee-remote/src/test/java/org/apache/openejb/arquillian/handletypes/InitInterfaceOnly.java
Modified:
    tomee/tomee/trunk/arquillian/arquillian-tomee-remote/src/test/java/org/apache/openejb/arquillian/handletypes/HandleTypesTest.java
    tomee/tomee/trunk/arquillian/arquillian-tomee-remote/src/test/java/org/apache/openejb/arquillian/handletypes/Init.java
    tomee/tomee/trunk/container/openejb-core/src/main/java/org/apache/openejb/config/FinderFactory.java
    tomee/tomee/trunk/tomee/tomee-catalina/src/main/java/org/apache/tomee/catalina/OpenEJBContextConfig.java

Added: tomee/tomee/trunk/arquillian/arquillian-tomee-remote/src/test/java/org/apache/openejb/arquillian/handletypes/AnotherChild.java
URL: http://svn.apache.org/viewvc/tomee/tomee/trunk/arquillian/arquillian-tomee-remote/src/test/java/org/apache/openejb/arquillian/handletypes/AnotherChild.java?rev=1530524&view=auto
==============================================================================
--- tomee/tomee/trunk/arquillian/arquillian-tomee-remote/src/test/java/org/apache/openejb/arquillian/handletypes/AnotherChild.java
(added)
+++ tomee/tomee/trunk/arquillian/arquillian-tomee-remote/src/test/java/org/apache/openejb/arquillian/handletypes/AnotherChild.java
Wed Oct  9 08:26:53 2013
@@ -0,0 +1,20 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.openejb.arquillian.handletypes;
+
+public class AnotherChild implements API {
+}

Added: tomee/tomee/trunk/arquillian/arquillian-tomee-remote/src/test/java/org/apache/openejb/arquillian/handletypes/Decorated.java
URL: http://svn.apache.org/viewvc/tomee/tomee/trunk/arquillian/arquillian-tomee-remote/src/test/java/org/apache/openejb/arquillian/handletypes/Decorated.java?rev=1530524&view=auto
==============================================================================
--- tomee/tomee/trunk/arquillian/arquillian-tomee-remote/src/test/java/org/apache/openejb/arquillian/handletypes/Decorated.java
(added)
+++ tomee/tomee/trunk/arquillian/arquillian-tomee-remote/src/test/java/org/apache/openejb/arquillian/handletypes/Decorated.java
Wed Oct  9 08:26:53 2013
@@ -0,0 +1,21 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.openejb.arquillian.handletypes;
+
+@Decoration
+public class Decorated {
+}

Copied: tomee/tomee/trunk/arquillian/arquillian-tomee-remote/src/test/java/org/apache/openejb/arquillian/handletypes/Decoration.java
(from r1530497, tomee/tomee/trunk/arquillian/arquillian-tomee-remote/src/test/java/org/apache/openejb/arquillian/handletypes/API.java)
URL: http://svn.apache.org/viewvc/tomee/tomee/trunk/arquillian/arquillian-tomee-remote/src/test/java/org/apache/openejb/arquillian/handletypes/Decoration.java?p2=tomee/tomee/trunk/arquillian/arquillian-tomee-remote/src/test/java/org/apache/openejb/arquillian/handletypes/Decoration.java&p1=tomee/tomee/trunk/arquillian/arquillian-tomee-remote/src/test/java/org/apache/openejb/arquillian/handletypes/API.java&r1=1530497&r2=1530524&rev=1530524&view=diff
==============================================================================
--- tomee/tomee/trunk/arquillian/arquillian-tomee-remote/src/test/java/org/apache/openejb/arquillian/handletypes/API.java
(original)
+++ tomee/tomee/trunk/arquillian/arquillian-tomee-remote/src/test/java/org/apache/openejb/arquillian/handletypes/Decoration.java
Wed Oct  9 08:26:53 2013
@@ -16,5 +16,12 @@
  */
 package org.apache.openejb.arquillian.handletypes;
 
-public interface API {
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.TYPE)
+public @interface Decoration {
 }

Added: tomee/tomee/trunk/arquillian/arquillian-tomee-remote/src/test/java/org/apache/openejb/arquillian/handletypes/HandleTypesAnnotationOnlyTest.java
URL: http://svn.apache.org/viewvc/tomee/tomee/trunk/arquillian/arquillian-tomee-remote/src/test/java/org/apache/openejb/arquillian/handletypes/HandleTypesAnnotationOnlyTest.java?rev=1530524&view=auto
==============================================================================
--- tomee/tomee/trunk/arquillian/arquillian-tomee-remote/src/test/java/org/apache/openejb/arquillian/handletypes/HandleTypesAnnotationOnlyTest.java
(added)
+++ tomee/tomee/trunk/arquillian/arquillian-tomee-remote/src/test/java/org/apache/openejb/arquillian/handletypes/HandleTypesAnnotationOnlyTest.java
Wed Oct  9 08:26:53 2013
@@ -0,0 +1,58 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.openejb.arquillian.handletypes;
+
+import org.apache.openejb.arquillian.common.IO;
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.arquillian.test.api.ArquillianResource;
+import org.jboss.shrinkwrap.api.Archive;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.spec.WebArchive;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import javax.servlet.ServletContainerInitializer;
+import java.io.IOException;
+import java.net.URL;
+
+import static org.hamcrest.CoreMatchers.containsString;
+import static org.hamcrest.CoreMatchers.not;
+import static org.hamcrest.MatcherAssert.assertThat;
+
+@RunWith(Arquillian.class)
+public class HandleTypesAnnotationOnlyTest {
+    @Deployment(testable = false)
+    public static Archive<?> war() {
+        return ShrinkWrap.create(WebArchive.class, "annotationonly.war")
+            .addClasses(API.class, Impl.class, InitAnnotationOnly.class, AnotherChild.class,
Decorated.class, Decoration.class)
+            .addAsServiceProvider(ServletContainerInitializer.class, InitAnnotationOnly.class);
+    }
+
+    @ArquillianResource
+    private URL url;
+
+    @Test
+    public void check() throws IOException {
+        final String content = IO.slurp(new URL(url.toExternalForm() + "list"));
+        assertThat(content, containsString(Decorated.class.getName()));
+        assertThat(content, not(containsString(Decoration.class.getName())));
+        assertThat(content, not(containsString(API.class.getName())));
+        assertThat(content, not(containsString(Impl.class.getName())));
+        assertThat(content, not(containsString(AnotherChild.class.getName())));
+    }
+}

Copied: tomee/tomee/trunk/arquillian/arquillian-tomee-remote/src/test/java/org/apache/openejb/arquillian/handletypes/HandleTypesInterfaceOnlyTest.java
(from r1530497, tomee/tomee/trunk/arquillian/arquillian-tomee-remote/src/test/java/org/apache/openejb/arquillian/handletypes/HandleTypesTest.java)
URL: http://svn.apache.org/viewvc/tomee/tomee/trunk/arquillian/arquillian-tomee-remote/src/test/java/org/apache/openejb/arquillian/handletypes/HandleTypesInterfaceOnlyTest.java?p2=tomee/tomee/trunk/arquillian/arquillian-tomee-remote/src/test/java/org/apache/openejb/arquillian/handletypes/HandleTypesInterfaceOnlyTest.java&p1=tomee/tomee/trunk/arquillian/arquillian-tomee-remote/src/test/java/org/apache/openejb/arquillian/handletypes/HandleTypesTest.java&r1=1530497&r2=1530524&rev=1530524&view=diff
==============================================================================
--- tomee/tomee/trunk/arquillian/arquillian-tomee-remote/src/test/java/org/apache/openejb/arquillian/handletypes/HandleTypesTest.java
(original)
+++ tomee/tomee/trunk/arquillian/arquillian-tomee-remote/src/test/java/org/apache/openejb/arquillian/handletypes/HandleTypesInterfaceOnlyTest.java
Wed Oct  9 08:26:53 2013
@@ -31,15 +31,16 @@ import java.io.IOException;
 import java.net.URL;
 
 import static org.hamcrest.CoreMatchers.containsString;
+import static org.hamcrest.CoreMatchers.not;
 import static org.hamcrest.MatcherAssert.assertThat;
 
 @RunWith(Arquillian.class)
-public class HandleTypesTest {
+public class HandleTypesInterfaceOnlyTest {
     @Deployment(testable = false)
     public static Archive<?> war() {
-        return ShrinkWrap.create(WebArchive.class, "ht.war")
-            .addClasses(API.class, Impl.class, Init.class)
-            .addAsServiceProvider(ServletContainerInitializer.class, Init.class);
+        return ShrinkWrap.create(WebArchive.class, "interfaceonly.war")
+            .addClasses(API.class, Impl.class, InitInterfaceOnly.class, AnotherChild.class,
Decorated.class, Decoration.class)
+            .addAsServiceProvider(ServletContainerInitializer.class, InitInterfaceOnly.class);
     }
 
     @ArquillianResource
@@ -49,5 +50,9 @@ public class HandleTypesTest {
     public void check() throws IOException {
         final String content = IO.slurp(new URL(url.toExternalForm() + "list"));
         assertThat(content, containsString(Impl.class.getName()));
+        assertThat(content, containsString(AnotherChild.class.getName()));
+        assertThat(content, not(containsString(API.class.getName())));
+        assertThat(content, not(containsString(Decorated.class.getName())));
+        assertThat(content, not(containsString(Decoration.class.getName())));
     }
 }

Modified: tomee/tomee/trunk/arquillian/arquillian-tomee-remote/src/test/java/org/apache/openejb/arquillian/handletypes/HandleTypesTest.java
URL: http://svn.apache.org/viewvc/tomee/tomee/trunk/arquillian/arquillian-tomee-remote/src/test/java/org/apache/openejb/arquillian/handletypes/HandleTypesTest.java?rev=1530524&r1=1530523&r2=1530524&view=diff
==============================================================================
--- tomee/tomee/trunk/arquillian/arquillian-tomee-remote/src/test/java/org/apache/openejb/arquillian/handletypes/HandleTypesTest.java
(original)
+++ tomee/tomee/trunk/arquillian/arquillian-tomee-remote/src/test/java/org/apache/openejb/arquillian/handletypes/HandleTypesTest.java
Wed Oct  9 08:26:53 2013
@@ -31,14 +31,15 @@ import java.io.IOException;
 import java.net.URL;
 
 import static org.hamcrest.CoreMatchers.containsString;
+import static org.hamcrest.CoreMatchers.not;
 import static org.hamcrest.MatcherAssert.assertThat;
 
 @RunWith(Arquillian.class)
 public class HandleTypesTest {
     @Deployment(testable = false)
     public static Archive<?> war() {
-        return ShrinkWrap.create(WebArchive.class, "ht.war")
-            .addClasses(API.class, Impl.class, Init.class)
+        return ShrinkWrap.create(WebArchive.class, "interfaceandannotation.war")
+            .addClasses(API.class, Impl.class, Init.class, AnotherChild.class, Decorated.class,
Decoration.class)
             .addAsServiceProvider(ServletContainerInitializer.class, Init.class);
     }
 
@@ -49,5 +50,9 @@ public class HandleTypesTest {
     public void check() throws IOException {
         final String content = IO.slurp(new URL(url.toExternalForm() + "list"));
         assertThat(content, containsString(Impl.class.getName()));
+        assertThat(content, containsString(AnotherChild.class.getName()));
+        assertThat(content, containsString(Decorated.class.getName()));
+        assertThat(content, not(containsString(API.class.getName())));
+        assertThat(content, not(containsString(Decoration.class.getName())));
     }
 }

Modified: tomee/tomee/trunk/arquillian/arquillian-tomee-remote/src/test/java/org/apache/openejb/arquillian/handletypes/Init.java
URL: http://svn.apache.org/viewvc/tomee/tomee/trunk/arquillian/arquillian-tomee-remote/src/test/java/org/apache/openejb/arquillian/handletypes/Init.java?rev=1530524&r1=1530523&r2=1530524&view=diff
==============================================================================
--- tomee/tomee/trunk/arquillian/arquillian-tomee-remote/src/test/java/org/apache/openejb/arquillian/handletypes/Init.java
(original)
+++ tomee/tomee/trunk/arquillian/arquillian-tomee-remote/src/test/java/org/apache/openejb/arquillian/handletypes/Init.java
Wed Oct  9 08:26:53 2013
@@ -27,7 +27,7 @@ import javax.servlet.annotation.HandlesT
 import java.io.IOException;
 import java.util.Set;
 
-@HandlesTypes(API.class)
+@HandlesTypes({ API.class, Decoration.class })
 public class Init implements ServletContainerInitializer {
     @Override
     public void onStartup(final Set<Class<?>> classes, final ServletContext servletContext)
throws ServletException {
@@ -43,7 +43,7 @@ public class Init implements ServletCont
 
         @Override
         public void init(final ServletConfig servletConfig) throws ServletException {
-
+            // no-op
         }
 
         @Override

Copied: tomee/tomee/trunk/arquillian/arquillian-tomee-remote/src/test/java/org/apache/openejb/arquillian/handletypes/InitAnnotationOnly.java
(from r1530497, tomee/tomee/trunk/arquillian/arquillian-tomee-remote/src/test/java/org/apache/openejb/arquillian/handletypes/Init.java)
URL: http://svn.apache.org/viewvc/tomee/tomee/trunk/arquillian/arquillian-tomee-remote/src/test/java/org/apache/openejb/arquillian/handletypes/InitAnnotationOnly.java?p2=tomee/tomee/trunk/arquillian/arquillian-tomee-remote/src/test/java/org/apache/openejb/arquillian/handletypes/InitAnnotationOnly.java&p1=tomee/tomee/trunk/arquillian/arquillian-tomee-remote/src/test/java/org/apache/openejb/arquillian/handletypes/Init.java&r1=1530497&r2=1530524&rev=1530524&view=diff
==============================================================================
--- tomee/tomee/trunk/arquillian/arquillian-tomee-remote/src/test/java/org/apache/openejb/arquillian/handletypes/Init.java
(original)
+++ tomee/tomee/trunk/arquillian/arquillian-tomee-remote/src/test/java/org/apache/openejb/arquillian/handletypes/InitAnnotationOnly.java
Wed Oct  9 08:26:53 2013
@@ -27,8 +27,8 @@ import javax.servlet.annotation.HandlesT
 import java.io.IOException;
 import java.util.Set;
 
-@HandlesTypes(API.class)
-public class Init implements ServletContainerInitializer {
+@HandlesTypes(Decoration.class)
+public class InitAnnotationOnly implements ServletContainerInitializer {
     @Override
     public void onStartup(final Set<Class<?>> classes, final ServletContext servletContext)
throws ServletException {
         servletContext.addServlet("list", new ListServlet(classes)).addMapping("/list");
@@ -43,7 +43,7 @@ public class Init implements ServletCont
 
         @Override
         public void init(final ServletConfig servletConfig) throws ServletException {
-
+            // no-op
         }
 
         @Override

Added: tomee/tomee/trunk/arquillian/arquillian-tomee-remote/src/test/java/org/apache/openejb/arquillian/handletypes/InitInterfaceOnly.java
URL: http://svn.apache.org/viewvc/tomee/tomee/trunk/arquillian/arquillian-tomee-remote/src/test/java/org/apache/openejb/arquillian/handletypes/InitInterfaceOnly.java?rev=1530524&view=auto
==============================================================================
--- tomee/tomee/trunk/arquillian/arquillian-tomee-remote/src/test/java/org/apache/openejb/arquillian/handletypes/InitInterfaceOnly.java
(added)
+++ tomee/tomee/trunk/arquillian/arquillian-tomee-remote/src/test/java/org/apache/openejb/arquillian/handletypes/InitInterfaceOnly.java
Wed Oct  9 08:26:53 2013
@@ -0,0 +1,73 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.openejb.arquillian.handletypes;
+
+import javax.servlet.Servlet;
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletContainerInitializer;
+import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.annotation.HandlesTypes;
+import java.io.IOException;
+import java.util.Set;
+
+@HandlesTypes(API.class)
+public class InitInterfaceOnly implements ServletContainerInitializer {
+    @Override
+    public void onStartup(final Set<Class<?>> classes, final ServletContext servletContext)
throws ServletException {
+        servletContext.addServlet("list", new ListServlet(classes)).addMapping("/list");
+    }
+
+    private static class ListServlet implements Servlet {
+        private final Set<Class<?>> list;
+
+        public ListServlet(final Set<Class<?>> classes) {
+            this.list = classes;
+        }
+
+        @Override
+        public void init(final ServletConfig servletConfig) throws ServletException {
+            // no-op
+        }
+
+        @Override
+        public ServletConfig getServletConfig() {
+            return null;
+        }
+
+        @Override
+        public void service(final ServletRequest servletRequest, final ServletResponse servletResponse)
throws ServletException, IOException {
+            if (list == null) {
+                servletResponse.getWriter().write("oops");
+            } else {
+                servletResponse.getWriter().write(list.toString());
+            }
+        }
+
+        @Override
+        public String getServletInfo() {
+            return null;
+        }
+
+        @Override
+        public void destroy() {
+
+        }
+    }
+}

Modified: tomee/tomee/trunk/container/openejb-core/src/main/java/org/apache/openejb/config/FinderFactory.java
URL: http://svn.apache.org/viewvc/tomee/tomee/trunk/container/openejb-core/src/main/java/org/apache/openejb/config/FinderFactory.java?rev=1530524&r1=1530523&r2=1530524&view=diff
==============================================================================
--- tomee/tomee/trunk/container/openejb-core/src/main/java/org/apache/openejb/config/FinderFactory.java
(original)
+++ tomee/tomee/trunk/container/openejb-core/src/main/java/org/apache/openejb/config/FinderFactory.java
Wed Oct  9 08:26:53 2013
@@ -143,7 +143,7 @@ public class FinderFactory {
     }
 
     private static boolean enableFindSubclasses() {
-        return !SystemInstance.get().getOptions().get(SKIP_LINK, false) && (isTomEE()
|| (isJaxRsInstalled() && SystemInstance.get().getOptions().get(TOMEE_JAXRS_DEPLOY_UNDECLARED_PROP,
false)));
+        return !SystemInstance.get().getOptions().get(SKIP_LINK, false) && (isJaxRsInstalled()
&& SystemInstance.get().getOptions().get(TOMEE_JAXRS_DEPLOY_UNDECLARED_PROP, false));
     }
 
     private static boolean isTomEE() {

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=1530524&r1=1530523&r2=1530524&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:26:53 2013
@@ -57,6 +57,7 @@ import org.apache.tomee.catalina.realm.T
 import org.apache.tomee.common.NamingUtil;
 import org.apache.tomee.common.ResourceFactory;
 import org.apache.tomee.loader.TomcatHelper;
+import org.apache.xbean.finder.AnnotationFinder;
 import org.apache.xbean.finder.IAnnotationFinder;
 
 import javax.servlet.ServletContainerInitializer;
@@ -382,10 +383,6 @@ public class OpenEJBContextConfig extend
         } catch (final NoClassDefFoundError error) {
             // no-op
         }
-
-        // let it be GC-ed
-        finder = null;
-        tempLoader = null;
     }
 
     private Set<Class<?>> getJsfClasses(final Context context) {
@@ -416,6 +413,43 @@ public class OpenEJBContextConfig extend
         webInfClassesAnnotationsProcessed = false;
         try {
             super.processServletContainerInitializers(fragments);
+
+            if (typeInitializerMap.size() > 0 && finder != null) {
+                final ClassLoader loader = context.getLoader().getClassLoader();
+                if (handlesTypesNonAnnotations) {
+                    if (AnnotationFinder.class.isInstance(finder)) {
+                        AnnotationFinder.class.cast(finder).link();
+                    }
+                }
+
+                for (final Map.Entry<Class<?>, Set<ServletContainerInitializer>>
entry : typeInitializerMap.entrySet()) {
+                    final Class<?> annotation = entry.getKey();
+                    for (final ServletContainerInitializer sci : entry.getValue()) {
+                        if (annotation.isAnnotation()) {
+                            try {
+                                final Class<? extends Annotation> reloadedAnnotation
= Class.class.cast(tempLoader.loadClass(annotation.getName()));
+                                addClassesWithRightLoader(loader, sci, finder.findAnnotatedClasses(reloadedAnnotation));
+                            } catch (final Throwable th) {
+                                // no-op
+                            }
+                        } 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());
+
+                                final Class<?> reloadedClass = tempLoader.loadClass(annotation.getName());
+                                final List<Class<?>> implementations = List.class.cast(finder.findImplementations(reloadedClass));
+                                addClassesWithRightLoader(loader, sci, implementations);
+                            } catch (final Throwable th) {
+                                // no-op
+                            }
+                        }
+                    }
+                }
+
+                // done
+                finder = null;
+                tempLoader = null;
+            }
         } catch (RuntimeException e) { // if exception occurs we have to clear the threadlocal
             webInfClassesAnnotationsProcessed = false;
             throw e;
@@ -496,39 +530,6 @@ public class OpenEJBContextConfig extend
     }
 
     private void internalProcessAnnotations(final File currentUrlAsFile, final WebAppInfo
webAppInfo, final WebXml fragment) {
-        if (typeInitializerMap.size() > 0 && finder != null) {
-            final ClassLoader loader = context.getLoader().getClassLoader();
-            if (handlesTypesNonAnnotations) {
-                for (final Map.Entry<Class<?>, Set<ServletContainerInitializer>>
entry : typeInitializerMap.entrySet()) {
-                    for (final ServletContainerInitializer sci : entry.getValue()) {
-                        try { // we need to load the class (entry.getKey()) with the finder
classloader = tempClassLoader otherwise isAssignable is false in almost all cases
-                            final Class<?> reloadedClass = tempLoader.loadClass(entry.getKey().getName());
-                            final List<Class<?>> implementations = List.class.cast(finder.findImplementations(reloadedClass));
-                            addClassesWithRightLoader(loader, sci, implementations);
-                        } catch (final Throwable th) {
-                            // no-op
-                        }
-                    }
-                }
-            }
-
-            if (handlesTypesAnnotations) {
-                for (final Map.Entry<Class<?>, Set<ServletContainerInitializer>>
entry : typeInitializerMap.entrySet()) {
-                    final Class<?> annotation = entry.getKey();
-                    if (annotation.isAnnotation()) {
-                        for (final ServletContainerInitializer sci : entry.getValue()) {
-                            try {
-                                final Class<? extends Annotation> reloadedAnnotation
= Class.class.cast(tempLoader.loadClass(annotation.getName()));
-                                addClassesWithRightLoader(loader, sci, finder.findAnnotatedClasses(reloadedAnnotation));
-                            } catch (final Throwable th) {
-                                // no-op
-                            }
-                        }
-                    }
-                }
-            }
-        }
-
         for (final ClassListInfo webAnnotated : webAppInfo.webAnnotatedClasses) {
             try {
                 if (!isIncludedIn(webAnnotated.name, currentUrlAsFile)) {



Mime
View raw message