openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From strub...@apache.org
Subject svn commit: r1431992 - in /openwebbeans/trunk/webbeans-impl/src: main/java/org/apache/webbeans/component/ main/java/org/apache/webbeans/component/creation/ main/java/org/apache/webbeans/config/ main/java/org/apache/webbeans/intercept/ main/java/org/apa...
Date Fri, 11 Jan 2013 11:09:54 GMT
Author: struberg
Date: Fri Jan 11 11:09:54 2013
New Revision: 1431992

URL: http://svn.apache.org/viewvc?rev=1431992&view=rev
Log:
OWB-344 interceptor builder refined

Modified:
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/InterceptorBean.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/AbstractInjectionTargetBeanBuilder.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/CdiInterceptorBeanBuilder.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/InterceptorBeanBuilder.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ManagedBeanBuilder.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/BeansDeployer.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorResolutionService.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/resolution/InterceptorBeanBuilderTest.java

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/InterceptorBean.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/InterceptorBean.java?rev=1431992&r1=1431991&r2=1431992&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/InterceptorBean.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/InterceptorBean.java
Fri Jan 11 11:09:54 2013
@@ -49,8 +49,6 @@ public abstract class InterceptorBean<T>
     public InterceptorBean(WebBeansContext webBeansContext, AnnotatedType<T> annotatedType)
     {
         super(webBeansContext, WebBeansType.INTERCEPTOR, annotatedType.getJavaClass(), annotatedType);
-
-        Asserts.assertNotNull(intercepts, "Interceptor does not handle any InterceptionTypes!");
     }
 
     private Set<InterceptionType> intercepts;

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/AbstractInjectionTargetBeanBuilder.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/AbstractInjectionTargetBeanBuilder.java?rev=1431992&r1=1431991&r2=1431992&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/AbstractInjectionTargetBeanBuilder.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/AbstractInjectionTargetBeanBuilder.java
Fri Jan 11 11:09:54 2013
@@ -73,7 +73,7 @@ import org.apache.webbeans.util.WebBeans
 public abstract class AbstractInjectionTargetBeanBuilder<T> extends AbstractBeanBuilder<T>
 {    
     
-    private WebBeansContext webBeansContext;
+    protected WebBeansContext webBeansContext;
     private Set<AnnotatedMember<? super T>> injectionPoints = new HashSet<AnnotatedMember<?
super T>>();
 
     /**

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/CdiInterceptorBeanBuilder.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/CdiInterceptorBeanBuilder.java?rev=1431992&r1=1431991&r2=1431992&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/CdiInterceptorBeanBuilder.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/CdiInterceptorBeanBuilder.java
Fri Jan 11 11:09:54 2013
@@ -34,7 +34,19 @@ public class CdiInterceptorBeanBuilder<T
         super(new CdiInterceptorBean<T>(webBeansContext, annotatedType));
     }
 
-    public void defineCdiInterceptorBean()
+    public void defineCdiInterceptorRules()
+    {
+        defineInterceptorBindings();
+        defineInterceptorRules();
+
+    }
+
+    public boolean isInterceptorEnabled()
+    {
+        return webBeansContext.getInterceptorsManager().isInterceptorClassEnabled(getBeanType());
+    }
+
+    protected void defineInterceptorBindings()
     {
 
     }

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/InterceptorBeanBuilder.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/InterceptorBeanBuilder.java?rev=1431992&r1=1431991&r2=1431992&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/InterceptorBeanBuilder.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/InterceptorBeanBuilder.java
Fri Jan 11 11:09:54 2013
@@ -21,24 +21,32 @@ package org.apache.webbeans.component.cr
 import javax.enterprise.context.Dependent;
 
 import org.apache.webbeans.component.InterceptorBean;
-import org.apache.webbeans.intercept.InterceptorResolutionService;
+
 
 /**
  * Bean builder for {@link org.apache.webbeans.component.InterceptorBean}s.
  */
 public abstract class InterceptorBeanBuilder<T> extends AbstractInjectionTargetBeanBuilder<T>
 {
-    protected final InterceptorResolutionService interceptorResolutionService;
 
     protected InterceptorBeanBuilder(InterceptorBean<T> bean)
     {
         super(bean, Dependent.class);
-        interceptorResolutionService = bean.getWebBeansContext().getInterceptorResolutionService();
     }
 
-    protected void defineInterceptorBean()
-    {
+    /**
+     * If this method returns <code>false</code> the {@link #getBean()} method
must not get called.
+     *
+     * @return <code>true</code> if the Interceptor is enabled and a Bean should
get created
+     */
+    public abstract boolean isInterceptorEnabled();
 
+    protected void defineInterceptorRules()
+    {
+        defineInjectedMethods();
+        defineInjectedFields();
     }
 
+
+
 }

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ManagedBeanBuilder.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ManagedBeanBuilder.java?rev=1431992&r1=1431991&r2=1431992&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ManagedBeanBuilder.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ManagedBeanBuilder.java
Fri Jan 11 11:09:54 2013
@@ -238,6 +238,9 @@ public class ManagedBeanBuilder<T> exten
         return managedBean;
     }
 
+    /**
+     * @deprecated replaced via the various {@link InterceptorBeanBuilder}s
+     */
     public void defineInterceptor(ProcessInjectionTarget<T> injectionTargetEvent)
     {
         Class<?> clazz = injectionTargetEvent.getAnnotatedType().getJavaClass();

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=1431992&r1=1431991&r2=1431992&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
Fri Jan 11 11:09:54 2013
@@ -406,7 +406,7 @@ public class BeansDeployer
                     //If intercepted marker
                     if(bean instanceof InterceptedMarker)
                     {
-                        webBeansContext.getWebBeansInterceptorConfig().defineBeanInterceptorStack((AbstractInjectionTargetBean<Object>)bean);
+                        webBeansContext.getWebBeansInterceptorConfig().defineBeanInterceptorStack((AbstractInjectionTargetBean<Object>)
bean);
                     }                                                            
                 }                
                 
@@ -862,7 +862,7 @@ public class BeansDeployer
                     managedBeanCreator.defineDecorator(processInjectionTargetEvent);
                 }
             }
-            else if(WebBeansUtil.isInterceptor(annotatedType))
+            else if(WebBeansUtil.isCdiInterceptor(annotatedType))
             {
                 if (logger.isLoggable(Level.FINE))
                 {

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorResolutionService.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorResolutionService.java?rev=1431992&r1=1431991&r2=1431992&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorResolutionService.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorResolutionService.java
Fri Jan 11 11:09:54 2013
@@ -335,6 +335,7 @@ public class InterceptorResolutionServic
         /**
          * All the Interceptor Beans which are active on this class somewhere.
          * This is only used to create the Interceptor instances.
+         * The Interceptors are not sorted yet.
          */
         private Set<Interceptor<?>> interceptors = null;
 

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java?rev=1431992&r1=1431991&r2=1431992&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java
Fri Jan 11 11:09:54 2013
@@ -2448,7 +2448,7 @@ public final class WebBeansUtil
     public boolean isAnnotatedTypeDecoratorOrInterceptor(AnnotatedType<?> annotatedType)
     {
         if(isDecorator(annotatedType) ||
-           isInterceptor(annotatedType))
+           isCdiInterceptor(annotatedType))
         {
             return true;
         }
@@ -2466,9 +2466,10 @@ public final class WebBeansUtil
     }
 
     /**
-     * @return <code>true</code> if this AnnotatedType represents an Interceptor
+     * @return <code>true</code> if this AnnotatedType represents a CDI Interceptor
+     *         defined via a {@link javax.interceptor.Interceptor} annotation
      */
-    public static boolean isInterceptor(AnnotatedType<?> annotatedType)
+    public static boolean isCdiInterceptor(AnnotatedType<?> annotatedType)
     {
         return annotatedType.isAnnotationPresent(javax.interceptor.Interceptor.class);
     }

Modified: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/resolution/InterceptorBeanBuilderTest.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/resolution/InterceptorBeanBuilderTest.java?rev=1431992&r1=1431991&r2=1431992&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/resolution/InterceptorBeanBuilderTest.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/resolution/InterceptorBeanBuilderTest.java
Fri Jan 11 11:09:54 2013
@@ -27,6 +27,7 @@ import java.util.Collection;
 import org.apache.webbeans.component.creation.CdiInterceptorBeanBuilder;
 import org.apache.webbeans.newtests.AbstractUnitTest;
 import org.apache.webbeans.newtests.interceptors.factory.beans.ClassInterceptedClass;
+import org.apache.webbeans.test.component.intercept.webbeans.SecureAndTransactionalInterceptor;
 import org.apache.webbeans.test.component.intercept.webbeans.TransactionalInterceptor;
 import org.apache.webbeans.test.component.intercept.webbeans.bindings.Transactional;
 import org.junit.Assert;
@@ -50,13 +51,24 @@ public class InterceptorBeanBuilderTest 
 
         startContainer(beanClasses, beanXmls);
 
-        AnnotatedType<TransactionalInterceptor> annotatedType = getBeanManager().createAnnotatedType(TransactionalInterceptor.class);
+        {
+            AnnotatedType<SecureAndTransactionalInterceptor> annotatedType = getBeanManager().createAnnotatedType(SecureAndTransactionalInterceptor.class);
 
-/*X TODO finish
-        CdiInterceptorBeanBuilder<TransactionalInterceptor> ibb
-                = new CdiInterceptorBeanBuilder<TransactionalInterceptor>(getWebBeansContext(),
annotatedType);
-        Bean<TransactionalInterceptor> bean = ibb.getBean();
-        Assert.assertNotNull(bean);
-*/
+            CdiInterceptorBeanBuilder<SecureAndTransactionalInterceptor> ibb
+                    = new CdiInterceptorBeanBuilder<SecureAndTransactionalInterceptor>(getWebBeansContext(),
annotatedType);
+            Assert.assertFalse(ibb.isInterceptorEnabled());
+        }
+
+        {
+            AnnotatedType<TransactionalInterceptor> annotatedType = getBeanManager().createAnnotatedType(TransactionalInterceptor.class);
+
+            CdiInterceptorBeanBuilder<TransactionalInterceptor> ibb
+                    = new CdiInterceptorBeanBuilder<TransactionalInterceptor>(getWebBeansContext(),
annotatedType);
+            ibb.defineCdiInterceptorRules();
+            Bean<TransactionalInterceptor> bean = ibb.getBean();
+            Assert.assertNotNull(bean);
+        }
+
+        shutDownContainer();
     }
 }



Mime
View raw message