openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From strub...@apache.org
Subject svn commit: r1432770 - in /openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans: component/ config/ container/ intercept/
Date Sun, 13 Jan 2013 23:53:53 GMT
Author: struberg
Date: Sun Jan 13 23:53:52 2013
New Revision: 1432770

URL: http://svn.apache.org/viewvc?rev=1432770&view=rev
Log:
OWB-344 reimplement BeanManager#resolveInterceptors

Modified:
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/InjectionTargetBean.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/BeansDeployer.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/BeanManagerImpl.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorsManager.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/WebBeansInterceptorConfig.java

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/InjectionTargetBean.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/InjectionTargetBean.java?rev=1432770&r1=1432769&r2=1432770&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/InjectionTargetBean.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/InjectionTargetBean.java
Sun Jan 13 23:53:52 2013
@@ -46,6 +46,7 @@ public interface InjectionTargetBean<T> 
     /**
      * Gets interceptor stack of bean instance.
      * @return interceptor stack
+     * @deprecated
      */
     public List<InterceptorData> getInterceptorStack();    
     

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/BeansDeployer.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/BeansDeployer.java?rev=1432770&r1=1432769&r2=1432770&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/BeansDeployer.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/BeansDeployer.java
Sun Jan 13 23:53:52 2013
@@ -63,7 +63,6 @@ import org.apache.webbeans.exception.Web
 import org.apache.webbeans.exception.WebBeansDeploymentException;
 import org.apache.webbeans.exception.WebBeansException;
 import org.apache.webbeans.exception.inject.InconsistentSpecializationException;
-import org.apache.webbeans.intercept.webbeans.WebBeansInterceptorBeanPleaseRemove;
 import org.apache.webbeans.logger.WebBeansLoggerFacade;
 import org.apache.webbeans.portable.AnnotatedElementFactory;
 import org.apache.webbeans.portable.events.ProcessAnnotatedTypeImpl;
@@ -348,8 +347,7 @@ public class BeansDeployer
         List<javax.enterprise.inject.spi.Interceptor<?>> interceptors = webBeansContext.getInterceptorsManager().getCdiInterceptors();
         for(javax.enterprise.inject.spi.Interceptor interceptor : interceptors)
         {
-            WebBeansInterceptorBeanPleaseRemove wbInt = (WebBeansInterceptorBeanPleaseRemove)interceptor;
-            beans.add(wbInt);
+            beans.add(interceptor);
         }
         
         logger.fine("Validation of the interceptor's injection points has started.");
@@ -870,6 +868,7 @@ public class BeansDeployer
                 {
                     logger.log(Level.FINE, "Found Managed Bean Interceptor with class name
: [{0}]", annotatedType.getJavaClass().getName());
                 }
+/*X TODO remove this old code*/
                 if(annotationTypeSet)
                 {
                     bean = webBeansContext.getWebBeansUtil().defineInterceptor(annotatedType);
@@ -878,6 +877,14 @@ public class BeansDeployer
                 {
                     bean = managedBeanCreator.defineInterceptor(processInjectionTargetEvent);
                 }
+/*X TODO enable again:
+                CdiInterceptorBeanBuilder<T> ibb
+                        = new CdiInterceptorBeanBuilder<T>(webBeansContext, annotatedType);
+                if (ibb.isInterceptorEnabled()) {
+                    Interceptor<T> interceptor = ibb.getBean();
+                    webBeansContext.getInterceptorsManager().addCdiInterceptor(interceptor);
+                }
+*/
             }
             else
             {

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/BeanManagerImpl.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/BeanManagerImpl.java?rev=1432770&r1=1432769&r2=1432770&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/BeanManagerImpl.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/BeanManagerImpl.java
Sun Jan 13 23:53:52 2013
@@ -76,8 +76,6 @@ import org.apache.webbeans.event.Notific
 import org.apache.webbeans.exception.WebBeansConfigurationException;
 import org.apache.webbeans.exception.definition.DuplicateDefinitionException;
 import org.apache.webbeans.exception.inject.DefinitionException;
-import org.apache.webbeans.intercept.InterceptorComparator;
-import org.apache.webbeans.intercept.webbeans.WebBeansInterceptorBeanPleaseRemove;
 import org.apache.webbeans.plugins.OpenWebBeansJmsPlugin;
 import org.apache.webbeans.portable.AnnotatedElementFactory;
 import org.apache.webbeans.portable.creation.InjectionTargetProducer;
@@ -440,23 +438,7 @@ public class BeanManagerImpl implements 
     {
         webBeansContext.getAnnotationManager().checkInterceptorResolverParams(interceptorBindings);
 
-        Set<Interceptor<?>> intsSet = webBeansContext.getWebBeansInterceptorConfig().findDeployedWebBeansInterceptor(interceptorBindings);
-        Iterator<Interceptor<?>> itSet = intsSet.iterator();
-
-        List<Interceptor<?>> interceptorList = new ArrayList<Interceptor<?>>();
-        while (itSet.hasNext())
-        {
-            WebBeansInterceptorBeanPleaseRemove interceptor = (WebBeansInterceptorBeanPleaseRemove)
itSet.next();
-
-            if (interceptor.intercepts(type))
-            {
-                interceptorList.add(interceptor);
-            }
-        }
-
-        Collections.sort(interceptorList, new InterceptorComparator(webBeansContext));
-
-        return interceptorList;
+        return webBeansContext.getInterceptorsManager().resolveInterceptors(type, interceptorBindings);
     }
 
     

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorsManager.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorsManager.java?rev=1432770&r1=1432769&r2=1432770&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorsManager.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorsManager.java
Sun Jan 13 23:53:52 2013
@@ -30,6 +30,7 @@ import java.util.concurrent.ConcurrentHa
 import java.util.concurrent.CopyOnWriteArrayList;
 
 import javax.enterprise.inject.spi.AnnotatedType;
+import javax.enterprise.inject.spi.InterceptionType;
 import javax.enterprise.inject.spi.Interceptor;
 import javax.enterprise.inject.spi.PassivationCapable;
 
@@ -38,6 +39,7 @@ import org.apache.webbeans.component.cre
 import org.apache.webbeans.config.WebBeansContext;
 import org.apache.webbeans.container.BeanManagerImpl;
 import org.apache.webbeans.exception.WebBeansConfigurationException;
+import org.apache.webbeans.util.AnnotationUtil;
 import org.apache.webbeans.util.Asserts;
 
 /**
@@ -176,6 +178,50 @@ public class InterceptorsManager
         return configuredInterceptorClasses.contains(interceptorClazz);
     }
 
+    public List<Interceptor<?>> resolveInterceptors(InterceptionType type, Annotation...
interceptorBindings)
+    {
+        List<Interceptor<?>> interceptorList = new ArrayList<Interceptor<?>>();
+        for (Interceptor<?> interceptor : cdiInterceptors)
+        {
+            if (interceptor.intercepts(type) && intercepts(interceptor, interceptorBindings))
+            {
+                interceptorList.add(interceptor);
+            }
+        }
+
+        Collections.sort(interceptorList, new InterceptorComparator(webBeansContext));
+
+        return interceptorList;
+    }
+
+    private boolean intercepts(Interceptor<?> interceptor, Annotation[] requestedInterceptorBindings)
+    {
+        for (Annotation interceptorBinding : interceptor.getInterceptorBindings())
+        {
+            // if an interceptor has multiple bindings then all of them must be in the
+            // requestedInterceptorBindings for a positive match
+
+            if (!inBindingArray(interceptorBinding, requestedInterceptorBindings))
+            {
+                return false;
+            }
+
+        }
+
+        return true;
+    }
+
+    private boolean inBindingArray(Annotation interceptorBinding, Annotation[] requestedInterceptorBindings)
+    {
+        for (Annotation requestedBinding : requestedInterceptorBindings)
+        {
+            if (AnnotationUtil.isQualifierEqual(requestedBinding, interceptorBinding))
+            {
+                return true;
+            }
+        }
+        return false;
+    }
 
     /**
      * Add a CDI-style interceptor.

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/WebBeansInterceptorConfig.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/WebBeansInterceptorConfig.java?rev=1432770&r1=1432769&r2=1432770&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/WebBeansInterceptorConfig.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/WebBeansInterceptorConfig.java
Sun Jan 13 23:53:52 2013
@@ -100,7 +100,7 @@ public final class WebBeansInterceptorCo
             bean.getWebBeansContext().getEJBInterceptorConfig().configure(bean.getAnnotatedType(),
stack);
 
             final OpenWebBeansEjbPlugin ejbPlugin = bean.getWebBeansContext().getPluginLoader().getEjbPlugin();
-            final boolean isStateful = ejbPlugin.isStatefulBean(bean.getBeanClass());
+            final boolean isStateful = ejbPlugin != null && ejbPlugin.isStatefulBean(bean.getBeanClass());
 
             if (isStateful)
             {



Mime
View raw message