openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From strub...@apache.org
Subject svn commit: r1429163 - in /openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans: annotation/ config/ container/ intercept/ intercept/webbeans/ portable/events/discovery/
Date Fri, 04 Jan 2013 22:39:18 GMT
Author: struberg
Date: Fri Jan  4 22:39:17 2013
New Revision: 1429163

URL: http://svn.apache.org/viewvc?rev=1429163&view=rev
Log:
OWB-749 move extension added info to InterceptorsManager

Modified:
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/annotation/AnnotationManager.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/webbeans/WebBeansInterceptorBean.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/events/discovery/AfterBeanDiscoveryImpl.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/events/discovery/BeforeBeanDiscoveryImpl.java

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/annotation/AnnotationManager.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/annotation/AnnotationManager.java?rev=1429163&r1=1429162&r2=1429163&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/annotation/AnnotationManager.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/annotation/AnnotationManager.java
Fri Jan  4 22:39:17 2013
@@ -94,7 +94,7 @@ public final class AnnotationManager
         Asserts.nullCheckForClass(clazz);
 
         return clazz.isAnnotationPresent(InterceptorBinding.class)
-               || beanManagerImpl.hasInterceptorBindingType(clazz);
+               || webBeansContext.getInterceptorsManager().hasInterceptorBindingType(clazz);
     }
 
 

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=1429163&r1=1429162&r2=1429163&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  4 22:39:17 2013
@@ -881,8 +881,8 @@ public class BeansDeployer
             }
             else
             {
-                if(webBeansContext.getBeanManagerImpl().containsCustomDecoratorClass(annotatedType.getJavaClass())
||
-                        webBeansContext.getBeanManagerImpl().containsCustomInterceptorClass(annotatedType.getJavaClass()))
+                if (webBeansContext.getBeanManagerImpl().containsCustomDecoratorClass(annotatedType.getJavaClass())
||
+                    webBeansContext.getInterceptorsManager().containsCustomInterceptorClass(annotatedType.getJavaClass()))
                 {
                     return false;
                 }

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=1429163&r1=1429162&r2=1429163&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
Fri Jan  4 22:39:17 2013
@@ -148,13 +148,6 @@ public class BeanManagerImpl implements 
     
     /**Additional decorator class*/
     private List<Class<?>> additionalDecoratorClasses = new ArrayList<Class<?>>();
-    
-    /**Additional interceptor class*/
-    private List<Class<?>> additionalInterceptorClasses = new ArrayList<Class<?>>();
-
-    /**Additional interceptor binding types we got via Extensions */
-    private Map<Class<? extends Annotation>, Set<Annotation>> additionalInterceptorBindingTypes
-            = new HashMap<Class<? extends Annotation>, Set<Annotation>>();
 
     /**
      * This list contains additional qualifiers which got set via the
@@ -409,24 +402,11 @@ public class BeanManagerImpl implements 
 
     }
 
-    //X TODO move to InterceptorsManager
-    public void addCustomInterceptorClass(Class<?> clazz)
-    {
-        Asserts.nullCheckForClass(clazz);
-        additionalInterceptorClasses.add(clazz);
-    }
-
     public void addCustomDecoratorClass(Class<?> clazz)
     {
         Asserts.nullCheckForClass(clazz);
         additionalDecoratorClasses.add(clazz);
     }
-    
-    public boolean containsCustomInterceptorClass(Class<?> clazz)
-    {
-        Asserts.nullCheckForClass(clazz);
-        return additionalInterceptorClasses.contains(clazz);
-    }
 
     public boolean containsCustomDecoratorClass(Class<?> clazz)
     {
@@ -434,32 +414,6 @@ public class BeanManagerImpl implements 
         return additionalDecoratorClasses.contains(clazz);
     }
 
-    public void addInterceptorBindingType(Class<? extends Annotation> bindingType,
Annotation... inheritsArray)
-    {
-        Set<Annotation> inherits = additionalInterceptorBindingTypes.get(bindingType);
-        if (inherits == null)
-        {
-            inherits = new HashSet<Annotation>();
-            additionalInterceptorBindingTypes.put(bindingType, inherits);
-        }
-        for(Annotation ann : inheritsArray)
-        {
-            inherits.add(ann);
-        }
-
-    }
-
-    public boolean hasInterceptorBindingType(Class<? extends Annotation> bindingType)
-    {
-        return additionalInterceptorBindingTypes.keySet().contains(bindingType);
-    }
-
-
-    public Set<Annotation> getInterceptorBindingTypeMetaAnnotations(Class<? extends
Annotation> interceptorBindingType)
-    {
-        return Collections.unmodifiableSet(additionalInterceptorBindingTypes.get(interceptorBindingType));
-    }
-
     /**
      * {@inheritDoc}
      */
@@ -1077,8 +1031,6 @@ public class BeanManagerImpl implements 
     {
         additionalAnnotatedTypes.clear();
         additionalDecoratorClasses.clear();
-        additionalInterceptorClasses.clear();
-        additionalInterceptorBindingTypes.clear();
         additionalQualifiers.clear();
         additionalScopes.clear();
         clearCacheProxies();
@@ -1090,7 +1042,7 @@ public class BeanManagerImpl implements 
         producers.clear();
         passivationBeans.clear();
         webBeansDecorators.clear();
-        webBeansContext.getInterceptorsManager().getInterceptors().clear();
+        webBeansContext.getInterceptorsManager().clear();
     }
 
     public void clearCacheProxies()

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=1429163&r1=1429162&r2=1429163&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
Fri Jan  4 22:39:17 2013
@@ -18,8 +18,14 @@
  */
 package org.apache.webbeans.intercept;
 
+import java.lang.annotation.Annotation;
 import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
 import java.util.List;
+import java.util.Map;
+import java.util.Set;
 import java.util.concurrent.CopyOnWriteArrayList;
 
 import javax.enterprise.inject.spi.AnnotatedType;
@@ -39,11 +45,26 @@ public class InterceptorsManager
     private final WebBeansContext webBeansContext;
     private final BeanManagerImpl beanManager;
 
-    private List<Class<?>> enabledInterceptorClasses = new CopyOnWriteArrayList<Class<?>>();
+    /**
+     * Interceptor classes which got added via beans.xml
+     */
+    private List<Class<?>> configuredInterceptorClasses = new CopyOnWriteArrayList<Class<?>>();
 
-    /**Active interceptors*/
+    /**
+     * Active interceptors
+     */
     private List<Interceptor<?>> webBeansInterceptors = new ArrayList<Interceptor<?>>();
 
+    /**Additional interceptor class*/
+    private List<Class<?>> additionalInterceptorClasses = new ArrayList<Class<?>>();
+
+    /**
+     * Additional interceptor binding types we got via Extensions
+     */
+    private Map<Class<? extends Annotation>, Set<Annotation>> additionalInterceptorBindingTypes
+            = new HashMap<Class<? extends Annotation>, Set<Annotation>>();
+
+
     public InterceptorsManager(WebBeansContext webBeansContext)
     {
         this.webBeansContext = webBeansContext;
@@ -51,15 +72,27 @@ public class InterceptorsManager
     }
 
     /**
+     * Clears all info.
+     * This must only be called by the BeanManager.
+     */
+    public void clear()
+    {
+        additionalInterceptorBindingTypes.clear();
+        additionalInterceptorClasses.clear();
+        configuredInterceptorClasses.clear();
+    }
+
+
+    /**
      * Add a certain class to the enabled interceptors list.
      */
     public void addNewInterceptorClass(Class<?> interceptorClazz)
     {
         Asserts.nullCheckForClass(interceptorClazz, "interceptorClazz can not be null");
 
-        if (!enabledInterceptorClasses.contains(interceptorClazz))
+        if (!configuredInterceptorClasses.contains(interceptorClazz))
         {
-            enabledInterceptorClasses.add(interceptorClazz);
+            configuredInterceptorClasses.add(interceptorClazz);
         }
     }
 
@@ -71,13 +104,13 @@ public class InterceptorsManager
         Asserts.assertNotNull(src, "src parameter can not be  null");
         Asserts.assertNotNull(target, "target parameter can not be null");
 
-        int srcIndex = enabledInterceptorClasses.indexOf(src);
+        int srcIndex = configuredInterceptorClasses.indexOf(src);
         if (srcIndex == -1)
         {
             throw new IllegalArgumentException(src.getName() + " is not an enabled interceptor!");
         }
 
-        int targetIndex = enabledInterceptorClasses.indexOf(target);
+        int targetIndex = configuredInterceptorClasses.indexOf(target);
         if (targetIndex == -1)
         {
             throw new IllegalArgumentException(target.getName() + " is not an enabled interceptor!");
@@ -105,7 +138,7 @@ public class InterceptorsManager
     {
         Asserts.nullCheckForClass(interceptorClazz, "interceptorClazz can not be null");
 
-        return enabledInterceptorClasses.contains(interceptorClazz);
+        return configuredInterceptorClasses.contains(interceptorClazz);
     }
 
 
@@ -117,7 +150,7 @@ public class InterceptorsManager
             OwbBean<?> owbBean = (OwbBean<?>)interceptor;
             if(owbBean.isPassivationCapable())
             {
-                beanManager.addPassivationInfo((OwbBean)interceptor);
+                beanManager.addPassivationInfo((OwbBean) interceptor);
             }
 
         }
@@ -129,15 +162,54 @@ public class InterceptorsManager
         return webBeansInterceptors;
     }
 
+    public void addCustomInterceptorClass(Class<?> clazz)
+    {
+        Asserts.nullCheckForClass(clazz);
+        additionalInterceptorClasses.add(clazz);
+    }
+
+    public boolean containsCustomInterceptorClass(Class<?> clazz)
+    {
+        Asserts.nullCheckForClass(clazz);
+        return additionalInterceptorClasses.contains(clazz);
+    }
+
+    public void addInterceptorBindingType(Class<? extends Annotation> bindingType,
Annotation... inheritsArray)
+    {
+        Set<Annotation> inherits = additionalInterceptorBindingTypes.get(bindingType);
+        if (inherits == null)
+        {
+            inherits = new HashSet<Annotation>();
+            additionalInterceptorBindingTypes.put(bindingType, inherits);
+        }
+        for(Annotation ann : inheritsArray)
+        {
+            inherits.add(ann);
+        }
+
+    }
+
+    public boolean hasInterceptorBindingType(Class<? extends Annotation> bindingType)
+    {
+        return additionalInterceptorBindingTypes.keySet().contains(bindingType);
+    }
+
+
+    public Set<Annotation> getInterceptorBindingTypeMetaAnnotations(Class<? extends
Annotation> interceptorBindingType)
+    {
+        return Collections.unmodifiableSet(additionalInterceptorBindingTypes.get(interceptorBindingType));
+    }
+
+
     public void validateInterceptorClasses()
     {
-        for(Class<?> interceptorClass : enabledInterceptorClasses)
+        for(Class<?> interceptorClass : configuredInterceptorClasses)
         {
             AnnotatedType<?> annotatedType = webBeansContext.getAnnotatedElementFactory().newAnnotatedType(interceptorClass);
 
             // Validate decorator classes
             if(!annotatedType.isAnnotationPresent(javax.interceptor.Interceptor.class) &&
-               !beanManager.containsCustomInterceptorClass(interceptorClass))
+               !containsCustomInterceptorClass(interceptorClass))
             {
                 throw new WebBeansConfigurationException("Given class : " + interceptorClass
+ " is not a interceptor class");
             }   

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/webbeans/WebBeansInterceptorBean.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/webbeans/WebBeansInterceptorBean.java?rev=1429163&r1=1429162&r2=1429163&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/webbeans/WebBeansInterceptorBean.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/webbeans/WebBeansInterceptorBean.java
Fri Jan  4 22:39:17 2013
@@ -199,9 +199,9 @@ public class WebBeansInterceptorBean<T> 
             Set<Annotation> declared = null;
             Annotation[] anns = null;
 
-            if (webBeansContext.getBeanManagerImpl().hasInterceptorBindingType(clazzAnnot))
+            if (webBeansContext.getInterceptorsManager().hasInterceptorBindingType(clazzAnnot))
             {
-                declared = webBeansContext.getBeanManagerImpl().getInterceptorBindingTypeMetaAnnotations(clazzAnnot);
+                declared = webBeansContext.getInterceptorsManager().getInterceptorBindingTypeMetaAnnotations(clazzAnnot);
                 anns = new Annotation[declared.size()];
                 anns = declared.toArray(anns);
             }

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/events/discovery/AfterBeanDiscoveryImpl.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/events/discovery/AfterBeanDiscoveryImpl.java?rev=1429163&r1=1429162&r2=1429163&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/events/discovery/AfterBeanDiscoveryImpl.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/events/discovery/AfterBeanDiscoveryImpl.java
Fri Jan  4 22:39:17 2013
@@ -109,7 +109,7 @@ public class AfterBeanDiscoveryImpl impl
 
             InterceptorsManager interceptorsManager = webBeansContext.getInterceptorsManager();
             interceptorsManager.addInterceptor(interceptor);
-            webBeansContext.getBeanManagerImpl().addCustomInterceptorClass(bean.getBeanClass());
+            webBeansContext.getInterceptorsManager().addCustomInterceptorClass(bean.getBeanClass());
         }
         
         else if(bean instanceof Decorator)

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/events/discovery/BeforeBeanDiscoveryImpl.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/events/discovery/BeforeBeanDiscoveryImpl.java?rev=1429163&r1=1429162&r2=1429163&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/events/discovery/BeforeBeanDiscoveryImpl.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/events/discovery/BeforeBeanDiscoveryImpl.java
Fri Jan  4 22:39:17 2013
@@ -68,7 +68,7 @@ public class BeforeBeanDiscoveryImpl imp
      */
     public void addInterceptorBinding(Class<? extends Annotation> binding, Annotation...
bindingDef)
     {
-        webBeansContext.getBeanManagerImpl().addInterceptorBindingType(binding, bindingDef);
+        webBeansContext.getInterceptorsManager().addInterceptorBindingType(binding, bindingDef);
     }
 
     /**
@@ -90,4 +90,4 @@ public class BeforeBeanDiscoveryImpl imp
         webBeansContext.getStereoTypeManager().addStereoTypeModel(model);
     }
 
-}
\ No newline at end of file
+}



Mime
View raw message