openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From strub...@apache.org
Subject svn commit: r1804947 - in /openwebbeans/trunk/webbeans-impl/src: main/java/org/apache/webbeans/annotation/ main/java/org/apache/webbeans/component/ main/java/org/apache/webbeans/config/ main/java/org/apache/webbeans/container/ main/java/org/apache/webb...
Date Sun, 13 Aug 2017 22:22:11 GMT
Author: struberg
Date: Sun Aug 13 22:22:10 2017
New Revision: 1804947

URL: http://svn.apache.org/viewvc?rev=1804947&view=rev
Log:
OWB-1210 rework Instance<T> handling 

Modified:
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/annotation/DefaultLiteral.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/BeanAttributesImpl.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/BeanManagerBean.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ConversationBean.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ExtensionBean.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/InstanceBean.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/InterceptionFactoryBean.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/container/InjectionResolver.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/OwbCDI.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/AbstractInjectable.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/InstanceProducer.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/AnnotationUtil.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/container/OwbCDIProviderTest.java
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/event/component/ObserversComponentTest.java

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/annotation/DefaultLiteral.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/annotation/DefaultLiteral.java?rev=1804947&r1=1804946&r2=1804947&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/annotation/DefaultLiteral.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/annotation/DefaultLiteral.java
Sun Aug 13 22:22:10 2017
@@ -33,7 +33,7 @@ public class DefaultLiteral extends Empt
 {
     public static final DefaultLiteral INSTANCE = new DefaultLiteral();
     public static final Annotation[] ARRAY = {INSTANCE};
-    public static final Set<Annotation> SET = Collections.<Annotation>singleton(INSTANCE);

+    public static final Set<Annotation> SET = Collections.singleton(INSTANCE);
 
     private static final String TOSTRING = "@javax.enterprise.inject.Default()";
     private static final long serialVersionUID = 6788272256977634238L;

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/BeanAttributesImpl.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/BeanAttributesImpl.java?rev=1804947&r1=1804946&r2=1804947&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/BeanAttributesImpl.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/BeanAttributesImpl.java
Sun Aug 13 22:22:10 2017
@@ -67,7 +67,7 @@ public class BeanAttributesImpl<T> imple
 
     public BeanAttributesImpl(Set<Type> types)
     {
-        this(types, AnnotationUtil.DEFAULT_AND_ANY_ANNOTATION, Dependent.class, null, false,
Collections.<Class<? extends Annotation>>emptySet(), false);
+        this(types, AnnotationUtil.DEFAULT_AND_ANY_ANNOTATION_SET, Dependent.class, null,
false, Collections.<Class<? extends Annotation>>emptySet(), false);
     }
 
     public BeanAttributesImpl(Set<Type> types, Set<Annotation> qualifiers)

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/BeanManagerBean.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/BeanManagerBean.java?rev=1804947&r1=1804946&r2=1804947&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/BeanManagerBean.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/BeanManagerBean.java
Sun Aug 13 22:22:10 2017
@@ -33,7 +33,7 @@ public class BeanManagerBean extends Bui
     {
         super(webBeansContext,
               WebBeansType.MANAGER,
-              new BeanAttributesImpl<>(CollectionUtil.<Type>unmodifiableSet(BeanManager.class,
Object.class), AnnotationUtil.DEFAULT_AND_ANY_ANNOTATION),
+              new BeanAttributesImpl<>(CollectionUtil.<Type>unmodifiableSet(BeanManager.class,
Object.class), AnnotationUtil.DEFAULT_AND_ANY_ANNOTATION_SET),
               BeanManager.class,
               false,
               new SimpleProducerFactory<>(new BeanManagerProducer(webBeansContext)));

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ConversationBean.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ConversationBean.java?rev=1804947&r1=1804946&r2=1804947&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ConversationBean.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ConversationBean.java
Sun Aug 13 22:22:10 2017
@@ -48,7 +48,7 @@ public class ConversationBean extends Bu
               WebBeansType.CONVERSATION,
                   new BeanAttributesImpl<>(
                     CollectionUtil.<Type>unmodifiableSet(Conversation.class, ConversationImpl.class,
Object.class),
-                    AnnotationUtil.DEFAULT_AND_ANY_ANNOTATION,
+                    AnnotationUtil.DEFAULT_AND_ANY_ANNOTATION_SET,
                     RequestScoped.class,
                     "javax.enterprise.context.conversation",
                     false,

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ExtensionBean.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ExtensionBean.java?rev=1804947&r1=1804946&r2=1804947&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ExtensionBean.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ExtensionBean.java
Sun Aug 13 22:22:10 2017
@@ -44,7 +44,7 @@ public class ExtensionBean<T> extends Bu
               WebBeansType.EXTENSION,
               new BeanAttributesImpl<>(
               webBeansContext.getAnnotatedElementFactory().getAnnotatedType(returnType).getTypeClosure(),
-              AnnotationUtil.DEFAULT_AND_ANY_ANNOTATION,
+              AnnotationUtil.DEFAULT_AND_ANY_ANNOTATION_SET,
               ApplicationScoped.class),
               returnType,
               false,

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/InstanceBean.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/InstanceBean.java?rev=1804947&r1=1804946&r2=1804947&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/InstanceBean.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/InstanceBean.java
Sun Aug 13 22:22:10 2017
@@ -18,8 +18,6 @@
  */
 package org.apache.webbeans.component;
 
-import java.lang.reflect.Type;
-
 import javax.enterprise.inject.Instance;
 import javax.enterprise.util.TypeLiteral;
 import javax.inject.Provider;
@@ -27,31 +25,19 @@ import javax.inject.Provider;
 import org.apache.webbeans.config.WebBeansContext;
 import org.apache.webbeans.inject.instance.InstanceImpl;
 import org.apache.webbeans.portable.InstanceProducer;
-import org.apache.webbeans.util.AnnotationUtil;
 import org.apache.webbeans.util.CollectionUtil;
 
 public class InstanceBean<T> extends BuiltInOwbBean<Instance<T>>
 {
-    
     @SuppressWarnings("serial")
     public InstanceBean(WebBeansContext webBeansContext)
     {
         super(webBeansContext,
             WebBeansType.INSTANCE,
-            new BeanAttributesImpl<>(CollectionUtil.<Type>unmodifiableSet(
-                new TypeLiteral<Instance<T>>()
-                {
-                }.getRawType(),
-                new TypeLiteral<Provider<T>>()
-                {
-                }.getRawType(),
-                Object.class)),
+            new BeanAttributesImpl(CollectionUtil.unmodifiableSet(Instance.class, Provider.class,
Object.class)),
             new TypeLiteral<Instance<T>>(){}.getRawType(),
             false,
-            new SimpleProducerFactory<>(
-                new InstanceProducer<>(new TypeLiteral<Instance<T>>()
-                {
-                }.getRawType(), AnnotationUtil.DEFAULT_AND_ANY_ANNOTATION, webBeansContext)));
+            new SimpleProducerFactory(new InstanceProducer(webBeansContext)));
     }
 
     /* (non-Javadoc)

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/InterceptionFactoryBean.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/InterceptionFactoryBean.java?rev=1804947&r1=1804946&r2=1804947&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/InterceptionFactoryBean.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/InterceptionFactoryBean.java
Sun Aug 13 22:22:10 2017
@@ -41,7 +41,7 @@ public class InterceptionFactoryBean ext
                 WebBeansType.INTERCEPTIONFACTORY,
                 new BeanAttributesImpl<>(
                         CollectionUtil.<Type>unmodifiableSet(InterceptionFactory.class,
Object.class),
-                        AnnotationUtil.DEFAULT_AND_ANY_ANNOTATION),
+                        AnnotationUtil.DEFAULT_AND_ANY_ANNOTATION_SET),
                 InterceptionFactory.class,
                 false,
                 new SimpleProducerFactory<>(new InterceptionFactoryProducer(webBeansContext)));

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=1804947&r1=1804946&r2=1804947&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 Aug 13 22:22:10 2017
@@ -653,10 +653,10 @@ public class BeansDeployer
         
         // Register InjectionPoint bean
         beanManager.addInternalBean(webBeansUtil.getInjectionPointBean());
-        
+
         //Register Instance Bean
         beanManager.addInternalBean(webBeansUtil.getInstanceBean());
-        
+
         //Register Event Bean
         beanManager.addInternalBean(webBeansUtil.getEventBean());
         beanManager.addInternalBean(webBeansUtil.getEventMetadataBean());

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=1804947&r1=1804946&r2=1804947&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 Aug 13 22:22:10 2017
@@ -1192,7 +1192,7 @@ public class BeanManagerImpl implements
     public <T> InterceptionFactory<T> createInterceptionFactory(CreationalContext<T>
creationalContext, Class<T> clazz)
     {
         return new InterceptionFactoryImpl(
-                webBeansContext, createAnnotatedType(clazz), AnnotationUtil.DEFAULT_AND_ANY_ANNOTATION,
+                webBeansContext, createAnnotatedType(clazz), AnnotationUtil.DEFAULT_AND_ANY_ANNOTATION_SET,
                 // ok, we can need to not cast that brutally
                 CreationalContextImpl.class.cast(creationalContext));
     }

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/InjectionResolver.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/InjectionResolver.java?rev=1804947&r1=1804946&r2=1804947&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/InjectionResolver.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/InjectionResolver.java
Sun Aug 13 22:22:10 2017
@@ -106,6 +106,9 @@ public class InjectionResolver
 
     private boolean fastMatching;
 
+    private Bean<Instance<Object>> instanceBean;
+    private Bean<Event<Object>> eventBean;
+
     /**
      * Creates a new injection resolve for given bean manager.
      *
@@ -114,8 +117,11 @@ public class InjectionResolver
     public InjectionResolver(WebBeansContext webBeansContext)
     {
         this.webBeansContext = webBeansContext;
-        this.alternativesManager = webBeansContext.getAlternativesManager();
-        this.startup = true;
+        alternativesManager = webBeansContext.getAlternativesManager();
+        startup = true;
+        fastMatching = false;
+        instanceBean = webBeansContext.getWebBeansUtil().getInstanceBean();
+        eventBean = webBeansContext.getWebBeansUtil().getEventBean();
     }
 
     public void setFastMatching(boolean fastMatching)
@@ -271,10 +277,6 @@ public class InjectionResolver
 
         Set<Annotation> qualSet = injectionPoint.getQualifiers();
         Annotation[] qualifiers = qualSet.toArray(new Annotation[qualSet.size()]);
-        if (isInstanceOrEventInjection(type))
-        {
-            qualifiers = AnyLiteral.ARRAY;
-        }
 
         Set<Bean<?>> beanSet = implResolveByType(injectionPoint.isDelegate(),
type, clazz, qualifiers);
 
@@ -330,22 +332,25 @@ public class InjectionResolver
     }
 
 
-    private boolean isInstanceOrEventInjection(Type type)
+    private Bean<?> getInstanceOrEventInjectionBean(Type type)
     {
         Class<?> clazz;
-        boolean injectInstanceOrEventProvider = false;
         if (type instanceof ParameterizedType)
         {
             ParameterizedType pt = (ParameterizedType) type;
             clazz = (Class<?>) pt.getRawType();
 
-            if (clazz.isAssignableFrom(Instance.class) || clazz.isAssignableFrom(Event.class))
+            if (clazz.isAssignableFrom(Instance.class))
             {
-                injectInstanceOrEventProvider = true;
+                return instanceBean;
+            }
+            if (clazz.isAssignableFrom(Event.class))
+            {
+                return eventBean;
             }
         }
 
-        return injectInstanceOrEventProvider;
+        return null;
     }
 
 
@@ -447,23 +452,18 @@ public class InjectionResolver
 
         boolean currentQualifier = false;
 
-        if (isInstanceOrEventInjection(injectionPointType))
-        {
-            qualifiers = AnyLiteral.ARRAY;
-        }
-        else
+        if (qualifiers.length == 0)
         {
-            if (qualifiers.length == 0)
-            {
-                qualifiers = DefaultLiteral.ARRAY;
-                currentQualifier = true;
-            }
+            qualifiers = DefaultLiteral.ARRAY;
+            currentQualifier = true;
         }
 
         Set<Bean<?>> resolvedComponents = null;
         BeanCacheKey cacheKey = null;
+
         if (!startup)
         {
+            // we only cache and validate once the set of Beans is final, otherwise we would
cache crap
             validateInjectionPointType(injectionPointType);
 
             cacheKey = new BeanCacheKey(isDelegate, injectionPointType, bdaBeansXMLFilePath,
qualifiers);
@@ -473,7 +473,6 @@ public class InjectionResolver
             {
                 return resolvedComponents;
             }
-
         }
 
         if (resolvedComponents  == null)
@@ -544,7 +543,23 @@ public class InjectionResolver
             }
         }
 
-        if (!startup && resolvedComponents != null && !resolvedComponents.isEmpty())
+        if (resolvedComponents.isEmpty())
+        {
+            // for Instance or Event creation we provided special Beans
+            // because they actually needs to fit every Qualifier
+            Bean<?> specialBean = getInstanceOrEventInjectionBean(injectionPointType);
+            if (specialBean != null)
+            {
+                resolvedComponents.add(specialBean);
+            }
+        }
+
+        if (resolvedComponents.isEmpty())
+        {
+            findNewBean(resolvedComponents, injectionPointType, qualifiers);
+        }
+
+        if (!startup && !resolvedComponents.isEmpty())
         {
             resolvedBeansByType.put(cacheKey, resolvedComponents);
         }
@@ -557,6 +572,27 @@ public class InjectionResolver
         return resolvedComponents;
     }
 
+    private void findNewBean(Set<Bean<?>> resolvedComponents, Type injectionPointType,
Annotation[] qualifiers)
+    {
+        if (qualifiers.length == 1 && New.class.equals(qualifiers[0].annotationType()))
+        {
+            // happen in TCKs, shouldn't be the case in real apps
+            New newQualifier = (New)qualifiers[0];
+            Class<?> beanClass;
+            if (newQualifier.value() != New.class)
+            {
+                beanClass = newQualifier.value();
+            }
+            else
+            {
+                beanClass = GenericsUtil.getRawType(injectionPointType);
+            }
+
+            resolvedComponents.add(webBeansContext.getWebBeansUtil().createNewComponent(beanClass));
+        }
+
+    }
+
     private Set<Bean<?>> findByBeanType(Set<Bean<?>> allComponents,
Type injectionPointType, boolean isDelegate)
     {
         Set<Bean<?>> resolved = new HashSet<>();
@@ -799,21 +835,6 @@ public class InjectionResolver
             }
         }
 
-        if (result.isEmpty() && annotations.length == 1 && New.class.equals(annotations[0].annotationType()))
-        { // happen in TCKs, shouldn't be the case in real apps
-            New newQualifier = (New)annotations[0];
-            Class<?> beanClass;
-            if (newQualifier.value() != New.class)
-            {
-                beanClass = newQualifier.value(); 
-            }
-            else
-            {
-                beanClass = GenericsUtil.getRawType(type);
-            }
-            result.add(webBeansContext.getWebBeansUtil().createNewComponent(beanClass));
-        }
-
         return result;
     }
 }

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/OwbCDI.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/OwbCDI.java?rev=1804947&r1=1804946&r2=1804947&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/OwbCDI.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/OwbCDI.java
Sun Aug 13 22:22:10 2017
@@ -18,8 +18,6 @@
  */
 package org.apache.webbeans.container;
 
-import org.apache.webbeans.annotation.DefaultLiteral;
-import org.apache.webbeans.component.InstanceBean;
 import org.apache.webbeans.config.WebBeansContext;
 import org.apache.webbeans.context.creational.CreationalContextImpl;
 import org.apache.webbeans.inject.instance.InstanceImpl;
@@ -43,7 +41,7 @@ public class OwbCDI extends CDI<Object>
         WebBeansContext webBeansContext = getWebBeansContext();
         BeanManagerImpl bm = webBeansContext.getBeanManagerImpl();
         CreationalContextImpl<Instance<Object>> creationalContext = bm.createCreationalContext(null);
-        return new InstanceBean<>(webBeansContext).create(creationalContext).select(DefaultLiteral.INSTANCE);
+        return webBeansContext.getWebBeansUtil().getInstanceBean().create(creationalContext);
     }
 
     @Override

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/AbstractInjectable.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/AbstractInjectable.java?rev=1804947&r1=1804946&r2=1804947&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/AbstractInjectable.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/AbstractInjectable.java
Sun Aug 13 22:22:10 2017
@@ -34,7 +34,6 @@ import javax.enterprise.inject.spi.Produ
 import org.apache.webbeans.component.AbstractProducerBean;
 import org.apache.webbeans.config.WebBeansContext;
 import org.apache.webbeans.container.BeanManagerImpl;
-import org.apache.webbeans.container.InjectionResolver;
 import org.apache.webbeans.context.creational.CreationalContextImpl;
 import org.apache.webbeans.util.ClassUtil;
 import org.apache.webbeans.util.WebBeansUtil;
@@ -76,10 +75,8 @@ public abstract class AbstractInjectable
         T injected;
         BeanManagerImpl beanManager = creationalContext.getWebBeansContext().getBeanManagerImpl();
 
-        //Injected contextual beam
-        InjectionResolver instance = beanManager.getInjectionResolver();
-
-        Bean<?> injectedBean = instance.getInjectionPointBean(injectionPoint);
+        //Injected contextual bean
+        Bean<?> injectedBean = beanManager.getInjectionResolver().getInjectionPointBean(injectionPoint);
         
         //Injection for dependent instance InjectionPoint fields
         boolean dependentProducer = false;

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/InstanceProducer.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/InstanceProducer.java?rev=1804947&r1=1804946&r2=1804947&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/InstanceProducer.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/InstanceProducer.java
Sun Aug 13 22:22:10 2017
@@ -28,6 +28,7 @@ import javax.enterprise.inject.Instance;
 import javax.enterprise.inject.spi.InjectionPoint;
 import javax.enterprise.inject.spi.Interceptor;
 
+import org.apache.webbeans.annotation.DefaultLiteral;
 import org.apache.webbeans.component.InstanceBean;
 import org.apache.webbeans.config.WebBeansContext;
 import org.apache.webbeans.context.creational.CreationalContextImpl;
@@ -35,15 +36,11 @@ import org.apache.webbeans.inject.instan
 
 public class InstanceProducer<T> extends AbstractProducer<Instance<T>>
 {
-    private Class<Instance<T>> returnType;
-    private Set<Annotation> qualifiers;
     private WebBeansContext webBeansContext;
 
 
-    public InstanceProducer(Class<Instance<T>> returnType, Set<Annotation>
qualifiers, WebBeansContext webBeansContext)
+    public InstanceProducer(WebBeansContext webBeansContext)
     {
-        this.returnType = returnType;
-        this.qualifiers = qualifiers;
         this.webBeansContext = webBeansContext;
     }
 
@@ -75,8 +72,9 @@ public class InstanceProducer<T> extends
             }
             else
             {
-                qualifiers = this.qualifiers;
-                type = returnType;
+                // an 'empty' directly resolved Instance always is for Default qualified
Objects
+                qualifiers = DefaultLiteral.SET;
+                type = Object.class;
             }
 
             return new InstanceImpl<>(type, injectionPoint, webBeansContext, creationalContextImpl,
qualifiers.toArray(new Annotation[qualifiers.size()]));

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/AnnotationUtil.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/AnnotationUtil.java?rev=1804947&r1=1804946&r2=1804947&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/AnnotationUtil.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/AnnotationUtil.java
Sun Aug 13 22:22:10 2017
@@ -50,7 +50,7 @@ public final class AnnotationUtil
     
     public static final Annotation[] DEFAULT_AND_ANY_ANNOTATION_ARRAY = {DefaultLiteral.INSTANCE,
AnyLiteral.INSTANCE};
 
-    public static final Set<Annotation> DEFAULT_AND_ANY_ANNOTATION = Collections.unmodifiableSet(ArrayUtil.asSet(DEFAULT_AND_ANY_ANNOTATION_ARRAY));
+    public static final Set<Annotation> DEFAULT_AND_ANY_ANNOTATION_SET = Collections.unmodifiableSet(ArrayUtil.asSet(DEFAULT_AND_ANY_ANNOTATION_ARRAY));
     
 
     // No instantiate

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=1804947&r1=1804946&r2=1804947&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 Aug 13 22:22:10 2017
@@ -170,9 +170,15 @@ public final class WebBeansUtil
     private final ConcurrentMap<EventCacheKey, Boolean> validEventType = new ConcurrentHashMap<>();
     private final ConcurrentMap<Type, Boolean> notContainerEvents = new ConcurrentHashMap<>();
 
+    private InstanceBean instanceBean;
+    private EventBean eventBean;
+
     public WebBeansUtil(WebBeansContext webBeansContext)
     {
         this.webBeansContext = webBeansContext;
+
+        instanceBean = new InstanceBean(webBeansContext);
+        eventBean = new EventBean<>(webBeansContext);
     }
 
     /**
@@ -490,7 +496,7 @@ public final class WebBeansUtil
      */
     public <T> InstanceBean<T> getInstanceBean()
     {
-        return new InstanceBean<>(webBeansContext);
+        return instanceBean;
     }
 
     /**
@@ -499,7 +505,7 @@ public final class WebBeansUtil
      */
     public <T> EventBean<T> getEventBean()
     {
-        return new EventBean<>(webBeansContext);
+        return eventBean;
     }
 
     /**

Modified: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/container/OwbCDIProviderTest.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/container/OwbCDIProviderTest.java?rev=1804947&r1=1804946&r2=1804947&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/container/OwbCDIProviderTest.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/container/OwbCDIProviderTest.java
Sun Aug 13 22:22:10 2017
@@ -34,18 +34,18 @@ import static java.lang.annotation.Eleme
 import static java.lang.annotation.RetentionPolicy.RUNTIME;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
 
 public class OwbCDIProviderTest extends AbstractUnitTest
 {
     @Test
     public void run()
     {
-        startContainer(OwbCDIProviderTest.class);
+        startContainer(OwbCDIProviderTest.class, QualifiedBean.class);
         assertNotNull(CDI.current());
         assertNotNull(CDI.current().getBeanManager());
         assertFalse(CDI.current().isUnsatisfied());
-        assertFalse(CDI.current().isAmbiguous());
-        assertNotNull(CDI.current().get());
+        assertTrue(CDI.current().isAmbiguous());
     }
 
     @Test

Modified: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/event/component/ObserversComponentTest.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/event/component/ObserversComponentTest.java?rev=1804947&r1=1804946&r2=1804947&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/event/component/ObserversComponentTest.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/event/component/ObserversComponentTest.java
Sun Aug 13 22:22:10 2017
@@ -16,7 +16,7 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.webbeans.svtest.unittests.event.component;
+package org.apache.webbeans.test.unittests.event.component;
 
 import javax.enterprise.util.AnnotationLiteral;
 



Mime
View raw message