openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From strub...@apache.org
Subject svn commit: r1759903 - /openwebbeans/trunk/webbeans-tomcat7/src/main/java/org/apache/webbeans/web/tomcat7/TomcatWebPlugin.java
Date Thu, 08 Sep 2016 20:41:35 GMT
Author: struberg
Date: Thu Sep  8 20:41:34 2016
New Revision: 1759903

URL: http://svn.apache.org/viewvc?rev=1759903&view=rev
Log:
OWB-1153 improve servlet component instance check

Modified:
    openwebbeans/trunk/webbeans-tomcat7/src/main/java/org/apache/webbeans/web/tomcat7/TomcatWebPlugin.java

Modified: openwebbeans/trunk/webbeans-tomcat7/src/main/java/org/apache/webbeans/web/tomcat7/TomcatWebPlugin.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-tomcat7/src/main/java/org/apache/webbeans/web/tomcat7/TomcatWebPlugin.java?rev=1759903&r1=1759902&r2=1759903&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-tomcat7/src/main/java/org/apache/webbeans/web/tomcat7/TomcatWebPlugin.java
(original)
+++ openwebbeans/trunk/webbeans-tomcat7/src/main/java/org/apache/webbeans/web/tomcat7/TomcatWebPlugin.java
Thu Sep  8 20:41:34 2016
@@ -18,7 +18,6 @@
  */
 package org.apache.webbeans.web.tomcat7;
 
-import javax.jws.WebService;
 import javax.servlet.Filter;
 import javax.servlet.Servlet;
 import javax.servlet.ServletContextAttributeListener;
@@ -30,6 +29,8 @@ import javax.servlet.http.HttpSessionAtt
 import javax.servlet.http.HttpSessionBindingListener;
 import javax.servlet.http.HttpSessionListener;
 
+import java.util.EventListener;
+
 import org.apache.webbeans.exception.WebBeansConfigurationException;
 import org.apache.webbeans.spi.SecurityService;
 import org.apache.webbeans.spi.plugins.AbstractOwbPlugin;
@@ -75,45 +76,48 @@ public class TomcatWebPlugin extends Abs
     @Override
     public void isManagedBean(Class<?> clazz)
     {
-        if (Servlet.class.isAssignableFrom(clazz) ||
-            Filter.class.isAssignableFrom(clazz) ||
-            ServletContextListener.class.isAssignableFrom(clazz) ||
-            ServletContextAttributeListener.class.isAssignableFrom(clazz) ||
-            HttpSessionActivationListener.class.isAssignableFrom(clazz) ||
-            HttpSessionAttributeListener.class.isAssignableFrom(clazz) ||
-            HttpSessionBindingListener.class.isAssignableFrom(clazz) ||
-            HttpSessionListener.class.isAssignableFrom(clazz) ||
-            ServletRequestListener.class.isAssignableFrom(clazz) ||
-            ServletRequestAttributeListener.class.isAssignableFrom(clazz) )
+        if (isServletSpecClass(clazz))
         {
             throw new WebBeansConfigurationException("Given class  : " + clazz.getName()
+ " is not managed bean");
         }
     }
-    
+
     /**
      * {@inheritDoc}
      */
     @Override
     public boolean supportsJavaEeComponentInjections(Class<?> clazz)
     {
-        if(Servlet.class.isAssignableFrom(clazz) ||
-           Filter.class.isAssignableFrom(clazz) ||
-           ServletContextListener.class.isAssignableFrom(clazz) ||
-           ServletContextAttributeListener.class.isAssignableFrom(clazz) ||
-           HttpSessionActivationListener.class.isAssignableFrom(clazz) ||
-           HttpSessionAttributeListener.class.isAssignableFrom(clazz) ||
-           HttpSessionBindingListener.class.isAssignableFrom(clazz) ||
-           HttpSessionListener.class.isAssignableFrom(clazz) ||
-           ServletRequestListener.class.isAssignableFrom(clazz) ||
-           ServletRequestAttributeListener.class.isAssignableFrom(clazz) ||
-           clazz.isAnnotationPresent(WebService.class))
+        if(isServletSpecClass(clazz))
         {
             return true;
         }
-        
+
         return false;
     }
-    
+
+    private boolean isServletSpecClass(Class<?> clazz)
+    {
+        if (Servlet.class.isAssignableFrom(clazz) ||
+            Filter.class.isAssignableFrom(clazz))
+        {
+            return true;
+        }
+
+        if (EventListener.class.isAssignableFrom(clazz))
+        {
+            return ServletContextListener.class.isAssignableFrom(clazz) ||
+                   ServletContextAttributeListener.class.isAssignableFrom(clazz) ||
+                   HttpSessionActivationListener.class.isAssignableFrom(clazz) ||
+                   HttpSessionAttributeListener.class.isAssignableFrom(clazz) ||
+                   HttpSessionBindingListener.class.isAssignableFrom(clazz) ||
+                   HttpSessionListener.class.isAssignableFrom(clazz) ||
+                   ServletRequestListener.class.isAssignableFrom(clazz) ||
+                   ServletRequestAttributeListener.class.isAssignableFrom(clazz);
+        }
+        return false;
+    }
+
     
     /**
      * {@inheritDoc}



Mime
View raw message