openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject svn commit: r1132498 - in /openwebbeans/trunk/webbeans-impl/src: main/java/org/apache/webbeans/component/creation/ main/java/org/apache/webbeans/config/ main/java/org/apache/webbeans/decorator/ main/java/org/apache/webbeans/portable/ main/java/org/apac...
Date Sun, 05 Jun 2011 21:51:23 GMT
Author: djencks
Date: Sun Jun  5 21:51:23 2011
New Revision: 1132498

URL: http://svn.apache.org/viewvc?rev=1132498&view=rev
Log:
OWB-581 Use the excluded interface check in a lot more places.  Also fix a few typos

Modified:
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/AbstractBeanCreator.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/AbstractInjectedTargetBeanCreator.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/DefinitionUtil.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/ManagedBeanConfigurator.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/OpenWebBeansConfiguration.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/decorator/WebBeansDecorator.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/AbstractAnnotated.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/TestContext.java

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/AbstractBeanCreator.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/AbstractBeanCreator.java?rev=1132498&r1=1132497&r2=1132498&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/AbstractBeanCreator.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/AbstractBeanCreator.java
Sun Jun  5 21:51:23 2011
@@ -20,6 +20,7 @@ package org.apache.webbeans.component.cr
 
 import java.lang.annotation.Annotation;
 import java.lang.reflect.Type;
+import java.util.Iterator;
 import java.util.Set;
 
 import javax.enterprise.inject.spi.AnnotatedType;
@@ -92,6 +93,15 @@ public class AbstractBeanCreator<T> impl
             Set<Type> types = this.annotatedType.getTypeClosure();
             this.bean.getTypes().addAll(types);
         }
+        Set<String> ignored = bean.getWebBeansContext().getOpenWebBeansConfiguration().getIgnoredInterfaces();
+        for (Iterator<Type> i = bean.getTypes().iterator(); i.hasNext();)
+        {
+            Type t = i.next();
+            if (t instanceof Class && ignored.contains(((Class<?>)t).getName()))
+            {
+                i.remove();
+            }
+        }
     }
 
     /**

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/AbstractInjectedTargetBeanCreator.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/AbstractInjectedTargetBeanCreator.java?rev=1132498&r1=1132497&r2=1132498&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/AbstractInjectedTargetBeanCreator.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/AbstractInjectedTargetBeanCreator.java
Sun Jun  5 21:51:23 2011
@@ -128,7 +128,7 @@ public abstract class AbstractInjectedTa
         AbstractInjectionTargetBean bean = getBean();
         if(isDefaultMetaDataProvider())
         {
-            return bean.getWebBeansContext().getDefinitionUtil().defineProduerFields(bean);
+            return bean.getWebBeansContext().getDefinitionUtil().defineProducerFields(bean);
         }
         else
         {

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/DefinitionUtil.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/DefinitionUtil.java?rev=1132498&r1=1132497&r2=1132498&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/DefinitionUtil.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/DefinitionUtil.java
Sun Jun  5 21:51:23 2011
@@ -29,6 +29,7 @@ import java.lang.reflect.Type;
 import java.lang.reflect.TypeVariable;
 import java.util.ArrayList;
 import java.util.HashSet;
+import java.util.Iterator;
 import java.util.List;
 import java.util.Set;
 
@@ -112,10 +113,24 @@ public final class DefinitionUtil
         else
         {
             defineNormalApiTypes(bean, clazz);
-        }        
+        }
+        removeIgnoredInterfaces(bean);
     }
-     
-    
+
+    private static <T> void removeIgnoredInterfaces(AbstractOwbBean<T> bean)
+    {
+        Set<String> ignoredInterfaces = bean.getWebBeansContext().getOpenWebBeansConfiguration().getIgnoredInterfaces();
+        for (Iterator<Type> i = bean.getTypes().iterator(); i.hasNext(); )
+        {
+            Type t = i.next();
+            if (t instanceof Class && ignoredInterfaces.contains(((Class<?>)
t).getName()))
+            {
+                i.remove();
+            }
+        }
+    }
+
+
     private static <T> void defineNormalApiTypes(AbstractOwbBean<T> bean, Class<T>
clazz)
     {
         bean.getTypes().add(Object.class);
@@ -189,7 +204,8 @@ public final class DefinitionUtil
         else
         {
             defineNormalProducerMethodApi(producerBean, type);
-        }        
+        }
+        removeIgnoredInterfaces(producerBean);
     }
     
     private static <T> void defineNormalProducerMethodApi(AbstractProducerBean<T>
producerBean, Type type)
@@ -675,7 +691,7 @@ public final class DefinitionUtil
      * @param component producer field owner component
      * @return the set of producer field components
      */
-    public Set<ProducerFieldBean<?>> defineProduerFields(InjectionTargetBean<?>
component)
+    public Set<ProducerFieldBean<?>> defineProducerFields(InjectionTargetBean<?>
component)
     {
         Set<ProducerFieldBean<?>> producerFields = new HashSet<ProducerFieldBean<?>>();
         Field[] fields = webBeansContext.getSecurityService().doPrivilegedGetDeclaredFields(component.getReturnType());
@@ -1193,7 +1209,7 @@ public final class DefinitionUtil
      */
     public void defineDecoratorStack(AbstractInjectionTargetBean<?> bean)
     {
-        WebBeansDecoratorConfig.configureDecarotors(bean);
+        WebBeansDecoratorConfig.configureDecorators(bean);
     }
 
     public <T> Set<ObserverMethod<?>> defineObserverMethods(InjectionTargetBean<T>
component, Class<T> clazz)

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/ManagedBeanConfigurator.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/ManagedBeanConfigurator.java?rev=1132498&r1=1132497&r2=1132498&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/ManagedBeanConfigurator.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/ManagedBeanConfigurator.java
Sun Jun  5 21:51:23 2011
@@ -167,7 +167,7 @@ public final class ManagedBeanConfigurat
             manager.putInjectionTargetWrapper(producerMethod, new InjectionTargetWrapper(new
ProducerBeansProducer(producerMethod)));
         }
 
-        Set<ProducerFieldBean<?>> producerFields = definitionUtil.defineProduerFields(component);
+        Set<ProducerFieldBean<?>> producerFields = definitionUtil.defineProducerFields(component);
         for (ProducerFieldBean<?> producerField : producerFields)
         {
             // add them one after the other to enable serialization handling et al

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/OpenWebBeansConfiguration.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/OpenWebBeansConfiguration.java?rev=1132498&r1=1132497&r2=1132498&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/OpenWebBeansConfiguration.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/OpenWebBeansConfiguration.java
Sun Jun  5 21:51:23 2011
@@ -20,7 +20,11 @@ package org.apache.webbeans.config;
 
 import java.security.AccessController;
 import java.security.PrivilegedAction;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashSet;
 import java.util.Properties;
+import java.util.Set;
 
 import org.apache.webbeans.exception.WebBeansConfigurationException;
 import org.apache.webbeans.logger.WebBeansLogger;
@@ -122,7 +126,9 @@ public class OpenWebBeansConfiguration
      * when determining if a decorator matches its delegate.  These are typically added by
      * weaving or bytecode modification.
      */
-    public static final String IGNORED_DECORATOR_INTERFACES = "org.apache.webbeans.ignoredDecoratorInterfaces";
+    public static final String IGNORED_INTERFACES = "org.apache.webbeans.ignoredDecoratorInterfaces";
+
+    private Set<String> ignoredInterfaces;
 
     /**
      * you can configure this externally as well.
@@ -344,4 +350,22 @@ public class OpenWebBeansConfiguration
         
         return Boolean.valueOf(value);
     }
+
+    public synchronized Set<String> getIgnoredInterfaces()
+    {
+        if (ignoredInterfaces == null)
+        {
+            String ignoredInterfacesString = getProperty(IGNORED_INTERFACES);
+            if (ignoredInterfacesString != null)
+            {
+                ignoredInterfaces = new HashSet<String>(Arrays.asList(ignoredInterfacesString.split("[,\\p{javaWhitespace}]")));
+            }
+            else
+            {
+                ignoredInterfaces = Collections.emptySet();
+            }
+        }
+        return ignoredInterfaces;
+    }
+
 }

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/decorator/WebBeansDecorator.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/decorator/WebBeansDecorator.java?rev=1132498&r1=1132497&r2=1132498&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/decorator/WebBeansDecorator.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/decorator/WebBeansDecorator.java
Sun Jun  5 21:51:23 2011
@@ -23,7 +23,6 @@ import org.apache.webbeans.component.Abs
 import org.apache.webbeans.component.ManagedBean;
 import org.apache.webbeans.component.WebBeansType;
 import org.apache.webbeans.config.OWBLogConst;
-import org.apache.webbeans.config.OpenWebBeansConfiguration;
 import org.apache.webbeans.config.WebBeansContext;
 import org.apache.webbeans.exception.WebBeansConfigurationException;
 import org.apache.webbeans.exception.WebBeansException;
@@ -47,8 +46,6 @@ import java.lang.reflect.Field;
 import java.lang.reflect.Member;
 import java.lang.reflect.Method;
 import java.lang.reflect.Type;
-import java.util.Arrays;
-import java.util.Collections;
 import java.util.HashSet;
 import java.util.Iterator;
 import java.util.Set;
@@ -117,16 +114,9 @@ public class WebBeansDecorator<T> extend
 
     private static <T> Set<String> getIgnoredDecoratorInterfaces(AbstractInjectionTargetBean<T>
wrappedBean)
     {
-        OpenWebBeansConfiguration config = wrappedBean.getWebBeansContext().getOpenWebBeansConfiguration();
-        String ignoredDecoratorInterfacesString = config.getProperty(OpenWebBeansConfiguration.IGNORED_DECORATOR_INTERFACES);
-        if (ignoredDecoratorInterfacesString != null)
-        {
-            return new HashSet<String>(Arrays.asList(ignoredDecoratorInterfacesString.split("[,\\p{javaWhitespace}]")));
-        }
-        else
-        {
-            return Collections.singleton(Serializable.class.getName());
-        }
+        Set<String> result = new HashSet<String>(wrappedBean.getWebBeansContext().getOpenWebBeansConfiguration().getIgnoredInterfaces());
+        result.add(Serializable.class.getName());
+        return result;
     }
 
     protected void init()

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=1132498&r1=1132497&r2=1132498&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 Jun  5 21:51:23 2011
@@ -85,7 +85,7 @@ public final class WebBeansDecoratorConf
         delegate.getWebBeansContext().getBeanManagerImpl().addDecorator(decorator);
     }
 
-    public static void configureDecarotors(AbstractInjectionTargetBean<?> component)
+    public static void configureDecorators(AbstractInjectionTargetBean<?> component)
     {
         if (!component.getDecoratorStack().isEmpty())
         {

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AbstractAnnotated.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AbstractAnnotated.java?rev=1132498&r1=1132497&r2=1132498&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AbstractAnnotated.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AbstractAnnotated.java
Sun Jun  5 21:51:23 2011
@@ -21,6 +21,7 @@ package org.apache.webbeans.portable;
 import java.lang.annotation.Annotation;
 import java.lang.reflect.Type;
 import java.util.HashSet;
+import java.util.Iterator;
 import java.util.Set;
 
 import javax.enterprise.inject.Typed;
@@ -155,6 +156,15 @@ abstract class AbstractAnnotated impleme
             typeClosures = new HashSet<Type>();
             this.typeClosures.add(Object.class);
             ClassUtil.setTypeHierarchy(this.typeClosures, this.baseType);
+            Set<String> ignoredInterfaces = webBeansContext.getOpenWebBeansConfiguration().getIgnoredInterfaces();
+            for (Iterator<Type> i = this.typeClosures.iterator(); i.hasNext(); )
+            {
+                Type t = i.next();
+                if (t instanceof Class && ignoredInterfaces.contains(((Class<?>)t).getName()))
+                {
+                    i.remove();
+                }
+            }
 
             Annotation[] anns = annotations.toArray(new Annotation[annotations.size()]);
             if(AnnotationUtil.hasAnnotation(anns, Typed.class))

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=1132498&r1=1132497&r2=1132498&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
Sun Jun  5 21:51:23 2011
@@ -768,7 +768,7 @@ public final class WebBeansUtil
         conversationComp.addQualifier(new AnyLiteral());
         conversationComp.setName("javax.enterprise.context.conversation");
 
-        WebBeansDecoratorConfig.configureDecarotors(conversationComp);
+        WebBeansDecoratorConfig.configureDecorators(conversationComp);
 
         return conversationComp;
     }

Modified: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/TestContext.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/TestContext.java?rev=1132498&r1=1132497&r2=1132498&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/TestContext.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/TestContext.java
Sun Jun  5 21:51:23 2011
@@ -305,7 +305,7 @@ public abstract class TestContext implem
         {
             manager.addBean(WebBeansUtil.createNewBean(bean));
             DecoratorUtil.checkManagedBeanDecoratorConditions(bean,null);
-            WebBeansDecoratorConfig.configureDecarotors(bean);
+            WebBeansDecoratorConfig.configureDecorators(bean);
             webBeansContext.getDefinitionUtil().defineBeanInterceptorStack(bean);
 
             getComponents().add((AbstractOwbBean<?>) bean);



Mime
View raw message