openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From strub...@apache.org
Subject svn commit: r1429571 - in /openwebbeans/trunk/webbeans-impl/src: main/java/org/apache/webbeans/config/ main/java/org/apache/webbeans/container/ main/java/org/apache/webbeans/decorator/ main/java/org/apache/webbeans/portable/events/discovery/ test/java/...
Date Sun, 06 Jan 2013 19:07:58 GMT
Author: struberg
Date: Sun Jan  6 19:07:58 2013
New Revision: 1429571

URL: http://svn.apache.org/viewvc?rev=1429571&view=rev
Log:
OWB-344 move the Decorator list to the DecoratorManager

Modified:
    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/decorator/DecoratorsManager.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/decorator/WebBeansDecoratorConfig.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/events/discovery/AfterBeanDiscoveryImpl.java
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/mock/MockManager.java

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=1429571&r1=1429570&r2=1429571&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  6 19:07:58 2013
@@ -324,11 +324,10 @@ public class BeansDeployer
         webBeansContext.getDecoratorsManager().validateDecoratorClasses();
         webBeansContext.getInterceptorsManager().validateInterceptorClasses();
 
-        BeanManagerImpl manager = webBeansContext.getBeanManagerImpl();
         Set<Bean<?>> beans = new HashSet<Bean<?>>();
         
         //Adding decorators to validate
-        Set<Decorator<?>> decorators = manager.getDecorators();
+        Set<Decorator<?>> decorators = webBeansContext.getDecoratorsManager().getDecorators();
         for(Decorator decorator : decorators)
         {
             WebBeansDecorator wbDec = (WebBeansDecorator)decorator;
@@ -358,7 +357,7 @@ public class BeansDeployer
         
         beans.clear();
         
-        beans = manager.getBeans();
+        beans = webBeansContext.getBeanManagerImpl().getBeans();
         
         //Validate Others
         validate(beans);                

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=1429571&r1=1429570&r2=1429571&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  6 19:07:58 2013
@@ -71,7 +71,6 @@ import org.apache.webbeans.config.WebBea
 import org.apache.webbeans.context.creational.CreationalContextImpl;
 import org.apache.webbeans.decorator.DecoratorComparator;
 import org.apache.webbeans.decorator.WebBeansDecorator;
-import org.apache.webbeans.decorator.WebBeansDecoratorConfig;
 import org.apache.webbeans.event.NotificationManager;
 import org.apache.webbeans.exception.WebBeansConfigurationException;
 import org.apache.webbeans.exception.definition.DuplicateDefinitionException;
@@ -133,9 +132,6 @@ public class BeanManagerImpl implements 
     /**Normal scoped cache proxies*/
     private Map<Contextual<?>, Object> cacheProxies = new ConcurrentHashMap<Contextual<?>,
Object>();
 
-    /**Activity decorators*/
-    private Set<Decorator<?>> webBeansDecorators = new CopyOnWriteArraySet<Decorator<?>>();
-
     /**Event notification manager instance*/
     private NotificationManager notificationManager = null;
 
@@ -403,21 +399,6 @@ public class BeanManagerImpl implements 
         return deploymentBeans;
     }
     
-    
-    public BeanManager addDecorator(Decorator decorator)
-    {
-        webBeansDecorators.add(decorator);
-        if (decorator instanceof OwbBean)
-        {
-            OwbBean<?> owbBean = (OwbBean<?>)decorator;
-            
-            if(owbBean.isPassivationCapable())
-            {
-                addPassivationInfo((OwbBean)decorator);
-            }
-        }
-        return this;
-    }
 
     /**
      * {@inheritDoc}
@@ -425,7 +406,7 @@ public class BeanManagerImpl implements 
     public List<Decorator<?>> resolveDecorators(Set<Type> types, Annotation...
bindingTypes)
     {
         webBeansContext.getAnnotationManager().checkDecoratorResolverParams(types, bindingTypes);
-        Set<Decorator<?>> intsSet = WebBeansDecoratorConfig.findDeployedWebBeansDecorator(this,
types, bindingTypes);
+        Set<Decorator<?>> intsSet = webBeansContext.getDecoratorsManager().findDeployedWebBeansDecorator(types,
bindingTypes);
         Iterator<Decorator<?>> itSet = intsSet.iterator();
 
         List<Decorator<?>> decoratorList = new ArrayList<Decorator<?>>();
@@ -474,12 +455,6 @@ public class BeanManagerImpl implements 
         return deploymentBeans;
     }
 
-    public Set<Decorator<?>> getDecorators()
-    {
-        return webBeansDecorators;
-    }
-
-
     private void addContext(Class<? extends Annotation> scopeType, javax.enterprise.context.spi.Context
context)
     {
         Asserts.assertNotNull(scopeType, "scopeType parameter can not be null");
@@ -1010,7 +985,6 @@ public class BeanManagerImpl implements 
         errorStack.clear();
         producersForJavaEeComponents.clear();
         passivationBeans.clear();
-        webBeansDecorators.clear();
         webBeansContext.getInterceptorsManager().clear();
         webBeansContext.getDecoratorsManager().clear();
     }

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/decorator/DecoratorsManager.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/decorator/DecoratorsManager.java?rev=1429571&r1=1429570&r2=1429571&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/decorator/DecoratorsManager.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/decorator/DecoratorsManager.java
Sun Jan  6 19:07:58 2013
@@ -18,29 +18,45 @@
  */
 package org.apache.webbeans.decorator;
 
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Type;
 import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Iterator;
 import java.util.List;
+import java.util.Set;
 import java.util.concurrent.CopyOnWriteArrayList;
+import java.util.concurrent.CopyOnWriteArraySet;
 
 import javax.decorator.Decorator;
 
+import org.apache.webbeans.annotation.DefaultLiteral;
+import org.apache.webbeans.component.OwbBean;
 import org.apache.webbeans.config.WebBeansContext;
-import org.apache.webbeans.container.BeanManagerImpl;
 import org.apache.webbeans.exception.WebBeansConfigurationException;
 import org.apache.webbeans.util.Asserts;
 
 public class DecoratorsManager
 {
     private List<Class<?>> enabledDecorators = new CopyOnWriteArrayList<Class<?>>();
-    private final BeanManagerImpl manager;
+    private final WebBeansContext webBeansContext;
 
-    /**Additional decorator class*/
+    /**
+     * Additional decorator classes added by Extensions
+     */
     private List<Class<?>> additionalDecoratorClasses = new ArrayList<Class<?>>();
 
+    /**
+     * Active and enabled decorators
+     */
+    private Set<javax.enterprise.inject.spi.Decorator<?>> webBeansDecorators
= new CopyOnWriteArraySet<javax.enterprise.inject.spi.Decorator<?>>();
+
+
 
     public DecoratorsManager(WebBeansContext webBeansContext)
     {
-        manager = webBeansContext.getBeanManagerImpl();
+        this.webBeansContext = webBeansContext;
     }
 
     public void addNewDecorator(Class<?> decoratorClazz)
@@ -99,7 +115,6 @@ public class DecoratorsManager
         }                
     }
 
-
     public void addCustomDecoratorClass(Class<?> clazz)
     {
         Asserts.nullCheckForClass(clazz);
@@ -112,8 +127,63 @@ public class DecoratorsManager
         return additionalDecoratorClasses.contains(clazz);
     }
 
+    public Set<javax.enterprise.inject.spi.Decorator<?>> getDecorators()
+    {
+        return webBeansDecorators;
+    }
+
+    public void addDecorator(javax.enterprise.inject.spi.Decorator decorator)
+    {
+        webBeansDecorators.add(decorator);
+        if (decorator instanceof OwbBean)
+        {
+            OwbBean<?> owbBean = (OwbBean<?>)decorator;
+
+            if(owbBean.isPassivationCapable())
+            {
+                webBeansContext.getBeanManagerImpl().addPassivationInfo((OwbBean)decorator);
+            }
+        }
+    }
+
+    public  Set<javax.enterprise.inject.spi.Decorator<?>> findDeployedWebBeansDecorator(Set<Type>
apiTypes, Annotation... anns)
+    {
+        Set<javax.enterprise.inject.spi.Decorator<?>> set = new HashSet<javax.enterprise.inject.spi.Decorator<?>>();
+
+        Iterator<javax.enterprise.inject.spi.Decorator<?>> it = Collections.unmodifiableSet(getDecorators()).iterator();
+        WebBeansDecorator<?> decorator = null;
+
+        List<Class<? extends Annotation>> bindingTypes = new ArrayList<Class<?
extends Annotation>>();
+        Set<Annotation> listAnnot = new HashSet<Annotation>();
+        for (Annotation ann : anns)
+        {
+            bindingTypes.add(ann.annotationType());
+            listAnnot.add(ann);
+        }
+
+        if (listAnnot.isEmpty())
+        {
+            listAnnot.add(new DefaultLiteral());
+        }
+
+        while (it.hasNext())
+        {
+            decorator = (WebBeansDecorator<?>) it.next();
+
+            if (decorator.isDecoratorMatch(apiTypes, listAnnot))
+            {
+                set.add(decorator);
+            }
+        }
+
+        return set;
+
+    }
+
+
     public void clear()
     {
         additionalDecoratorClasses.clear();
+        webBeansDecorators.clear();
     }
 }

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/decorator/WebBeansDecoratorConfig.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/decorator/WebBeansDecoratorConfig.java?rev=1429571&r1=1429570&r2=1429571&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/decorator/WebBeansDecoratorConfig.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/decorator/WebBeansDecoratorConfig.java
Sun Jan  6 19:07:58 2013
@@ -19,10 +19,7 @@
 package org.apache.webbeans.decorator;
 
 import java.lang.annotation.Annotation;
-import java.lang.reflect.Type;
 import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashSet;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Set;
@@ -32,11 +29,9 @@ import java.util.logging.Logger;
 import javax.enterprise.context.Dependent;
 import javax.enterprise.inject.spi.BeanManager;
 import javax.enterprise.inject.spi.Decorator;
-import org.apache.webbeans.annotation.DefaultLiteral;
 import org.apache.webbeans.component.AbstractInjectionTargetBean;
 import org.apache.webbeans.component.InjectionTargetBean;
 import org.apache.webbeans.config.OWBLogConst;
-import org.apache.webbeans.container.BeanManagerImpl;
 import org.apache.webbeans.context.creational.CreationalContextImpl;
 import org.apache.webbeans.logger.WebBeansLoggerFacade;
 import org.apache.webbeans.spi.BDABeansXmlScanner;
@@ -83,7 +78,7 @@ public final class WebBeansDecoratorConf
             logger.log(Level.FINE, "Configuring decorator class : [{0}]", delegate.getReturnType());
         }
         WebBeansDecorator<T> decorator = new WebBeansDecorator<T>(delegate);
-        delegate.getWebBeansContext().getBeanManagerImpl().addDecorator(decorator);
+        delegate.getWebBeansContext().getDecoratorsManager().addDecorator(decorator);
     }
 
     public static void configureDecorators(AbstractInjectionTargetBean<?> component)
@@ -175,38 +170,5 @@ public final class WebBeansDecoratorConf
         }
     }
 
-    public static Set<Decorator<?>> findDeployedWebBeansDecorator(BeanManagerImpl
beanManagerImpl, Set<Type> apiTypes, Annotation... anns)
-    {
-        Set<Decorator<?>> set = new HashSet<Decorator<?>>();
-
-        Iterator<Decorator<?>> it = Collections.unmodifiableSet(beanManagerImpl.getDecorators()).iterator();
-        WebBeansDecorator<?> decorator = null;
-
-        List<Class<? extends Annotation>> bindingTypes = new ArrayList<Class<?
extends Annotation>>();
-        Set<Annotation> listAnnot = new HashSet<Annotation>();
-        for (Annotation ann : anns)
-        {
-            bindingTypes.add(ann.annotationType());
-            listAnnot.add(ann);
-        }
-
-        if (listAnnot.isEmpty())
-        {
-            listAnnot.add(new DefaultLiteral());
-        }
-
-        while (it.hasNext())
-        {
-            decorator = (WebBeansDecorator<?>) it.next();
-
-            if (decorator.isDecoratorMatch(apiTypes, listAnnot))
-            {
-                set.add(decorator);
-            }
-        }
-
-        return set;
-
-    }
 
 }

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=1429571&r1=1429570&r2=1429571&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
Sun Jan  6 19:07:58 2013
@@ -143,7 +143,7 @@ public class AfterBeanDiscoveryImpl impl
             }
 
 
-            beanManager.addDecorator(new WebBeansDecorator(managedBean, (Decorator) bean));
+            webBeansContext.getDecoratorsManager().addDecorator(new WebBeansDecorator(managedBean,
(Decorator) bean));
             webBeansContext.getDecoratorsManager().addCustomDecoratorClass(bean.getBeanClass());
         }
         else

Modified: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/mock/MockManager.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/mock/MockManager.java?rev=1429571&r1=1429570&r2=1429571&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/mock/MockManager.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/mock/MockManager.java
Sun Jan  6 19:07:58 2013
@@ -103,11 +103,6 @@ public class MockManager implements Bean
         return manager.addContext(context);
     }
 
-    public BeanManager addDecorator(Decorator<?> decorator)
-    {
-        return manager.addDecorator(decorator);
-    }
-
     public void fireEvent(Object event, Annotation... bindings)
     {
         manager.fireEvent(event, bindings);



Mime
View raw message