openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gerdo...@apache.org
Subject svn commit: r789094 - in /incubator/openwebbeans/trunk/webbeans-impl/src: main/java/org/apache/webbeans/component/ main/java/org/apache/webbeans/config/ main/java/org/apache/webbeans/container/ main/java/org/apache/webbeans/inject/instance/ main/java/o...
Date Sun, 28 Jun 2009 12:47:42 GMT
Author: gerdogdu
Date: Sun Jun 28 12:47:42 2009
New Revision: 789094

URL: http://svn.apache.org/viewvc?rev=789094&view=rev
Log:
Updating for reflecting Instance changes.

Modified:
    incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/InstanceComponentImpl.java
    incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/DefinitionUtil.java
    incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/InjectionResolver.java
    incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/ManagerImpl.java
    incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/ResolutionUtil.java
    incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/instance/InstanceFactory.java
    incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/instance/InstanceImpl.java
    incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java
    incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/inject/InstanceInjectedComponent.java
    incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/inject/broken/InstanceInjectedBrokenComponent1.java
    incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/inject/broken/InstanceInjectedBrokenComponent2.java
    incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/inject/broken/InstanceInjectedBrokenComponent3.java
    incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/inject/broken/InstanceInjectedBrokenComponent4.java
    incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/servlet/TestContext.java
    incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/inject/InjectedInstanceComponentTest.java
    incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/inject/broken/InjectedInstanceBrokenComponentTest.java

Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/InstanceComponentImpl.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/InstanceComponentImpl.java?rev=789094&r1=789093&r2=789094&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/InstanceComponentImpl.java
(original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/InstanceComponentImpl.java
Sun Jun 28 12:47:42 2009
@@ -28,15 +28,10 @@
 {
     private Type injectedType;
     
-    private Type[] actualTypeArguments = new Type[0];
-    
-    private Type[] injectedTypeArguments = new Type[0];
-    
-    public InstanceComponentImpl(Class<Instance<T>> returnType, Type injectedType,
Type[] injectedTypeArguments)
+    public InstanceComponentImpl(Class<Instance<T>> returnType, Type injectedType)
     {
         super(WebBeansType.INSTANCE, returnType);
         this.injectedType = injectedType;
-        this.injectedTypeArguments = injectedTypeArguments;
     }
     
     @Override
@@ -45,7 +40,7 @@
         Annotation[] anns = new Annotation[getBindings().size()];
         anns = getBindings().toArray(anns);
         
-        return InstanceFactory.getInstance(this.injectedType, this.actualTypeArguments, anns);
+        return InstanceFactory.getInstance(this.injectedType, anns);
     }
 
     @Override
@@ -54,13 +49,4 @@
         
     }
 
-    /**
-     * @return the actualTypeArguments
-     */
-    public Type[] getActualTypeArguments()
-    {
-        return this.injectedTypeArguments;
-    }
-
-    
-}
+}
\ No newline at end of file

Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/DefinitionUtil.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/DefinitionUtil.java?rev=789094&r1=789093&r2=789094&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/DefinitionUtil.java
(original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/DefinitionUtil.java
Sun Jun 28 12:47:42 2009
@@ -32,6 +32,7 @@
 import javax.enterprise.inject.Current;
 import javax.enterprise.inject.Disposes;
 import javax.enterprise.inject.Initializer;
+import javax.enterprise.inject.Instance;
 import javax.enterprise.inject.Named;
 import javax.enterprise.inject.NonBinding;
 import javax.enterprise.inject.Produces;
@@ -43,7 +44,6 @@
 import javax.enterprise.inject.spi.Bean;
 import javax.enterprise.inject.spi.InjectionPoint;
 import javax.event.Fires;
-import javax.inject.Obtains;
 
 import org.apache.webbeans.annotation.AnyScopeLiteral;
 import org.apache.webbeans.annotation.CurrentLiteral;
@@ -1180,12 +1180,11 @@
     {
         Annotated annotated = injectionPoint.getAnnotated();
         
-        //If contains the @Obtains, defines implicit component
-        if(annotated.isAnnotationPresent(Obtains.class))
+        if(WebBeansUtil.checkObtainsInjectionPointConditions(injectionPoint))
         {
-            WebBeansUtil.checkObtainsInjectionPointConditions(injectionPoint);
             WebBeansUtil.addInjectedImplicitInstanceComponent(injectionPoint);
-        }                                  
+        }
+        
         //If contains the @Fires, defines implicit component
         else if(annotated.isAnnotationPresent(Fires.class))
         {
@@ -1207,8 +1206,7 @@
                         break;
                     }
                 }
-            }
-            
+            }            
         }
     }
 }
\ No newline at end of file

Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/InjectionResolver.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/InjectionResolver.java?rev=789094&r1=789093&r2=789094&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/InjectionResolver.java
(original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/InjectionResolver.java
Sun Jun 28 12:47:42 2009
@@ -174,7 +174,7 @@
         
         Set<Bean<Object>> beanSet = implResolveByType(type ,bindingTypes);
         
-        ResolutionUtil.checkResolvedBeans(beanSet, clazz);
+        ResolutionUtil.checkResolvedBeans(beanSet, clazz, bindingTypes);
         
         return beanSet.iterator().next();
         

Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/ManagerImpl.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/ManagerImpl.java?rev=789094&r1=789093&r2=789094&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/ManagerImpl.java
(original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/ManagerImpl.java
Sun Jun 28 12:47:42 2009
@@ -333,7 +333,7 @@
         ResolutionUtil.getInstanceByTypeConditions(bindingTypes);
         Set<Bean<T>> set = resolveByType(type, bindingTypes);
 
-        ResolutionUtil.checkResolvedBeans(set, type);
+        ResolutionUtil.checkResolvedBeans(set, type, bindingTypes);
 
         return getInstance(set.iterator().next());
     }
@@ -343,7 +343,7 @@
         ResolutionUtil.getInstanceByTypeConditions(bindingTypes);
         Set<Bean<T>> set = resolveByType(type, bindingTypes);
 
-        ResolutionUtil.checkResolvedBeans(set, type.getRawType());
+        ResolutionUtil.checkResolvedBeans(set, type.getRawType(),bindingTypes);
 
         return getInstance(set.iterator().next());
     }

Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/ResolutionUtil.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/ResolutionUtil.java?rev=789094&r1=789093&r2=789094&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/ResolutionUtil.java
(original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/ResolutionUtil.java
Sun Jun 28 12:47:42 2009
@@ -50,7 +50,7 @@
         AnnotationUtil.checkBindingTypeConditions(bindingTypes);
     }
 
-    public static <T> void checkResolvedBeans(Set<Bean<T>> resolvedSet,
Class<?> type, Annotation...bindingTypes)
+    public static <T> void checkResolvedBeans(Set<Bean<T>> resolvedSet,
Class<?> type, Annotation[] bindingTypes)
     {
         if (resolvedSet.isEmpty())
         {

Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/instance/InstanceFactory.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/instance/InstanceFactory.java?rev=789094&r1=789093&r2=789094&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/instance/InstanceFactory.java
(original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/instance/InstanceFactory.java
Sun Jun 28 12:47:42 2009
@@ -28,9 +28,9 @@
         
     }
     
-    public static <T> Instance<T> getInstance(Type injectedType, Type[] actualTypeArguments,
Annotation...annotations)
+    public static <T> Instance<T> getInstance(Type injectedType, Annotation...annotations)
     {
-        InstanceImpl<T> instance = new InstanceImpl<T>(injectedType,actualTypeArguments,annotations);
  
+        InstanceImpl<T> instance = new InstanceImpl<T>(injectedType, annotations);
  
         
         return instance;
     }

Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/instance/InstanceImpl.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/instance/InstanceImpl.java?rev=789094&r1=789093&r2=789094&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/instance/InstanceImpl.java
(original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/instance/InstanceImpl.java
Sun Jun 28 12:47:42 2009
@@ -1,30 +1,27 @@
 /*
- *  Licensed to the Apache Software Foundation (ASF) under one or more
- *  contributor license agreements.  See the NOTICE file distributed with
- *  this work for additional information regarding copyright ownership.
- *  The ASF licenses this file to You under the Apache License, Version 2.0
- *  (the "License"); you may not use this file except in compliance with
- *  the License.  You may obtain a copy of the License at
- * 
- *       http://www.apache.org/licenses/LICENSE-2.0
- * 
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law
+ * or agreed to in writing, software distributed under the License is
+ * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the specific language
+ * governing permissions and limitations under the License.
  */
 package org.apache.webbeans.inject.instance;
 
 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.Instance;
+import javax.enterprise.inject.TypeLiteral;
 import javax.enterprise.inject.spi.Bean;
-import javax.inject.Obtains;
-
 
 import org.apache.webbeans.container.InjectionResolver;
 import org.apache.webbeans.container.ManagerImpl;
@@ -34,72 +31,182 @@
 
 /**
  * Implements the {@link Instance} interface.
- * @param <T> injection type
+ * 
+ * @param <T> specific instance type
  */
 class InstanceImpl<T> implements Instance<T>
 {
-    /**Injected class type*/
+    /** Injected class type */
     private Type injectionClazz;
-    
-    /**Injected point actual type arguments*/
-    private Type[] actualTypeArguments = new Type[0];
-    
-    /**Binding annotations appeared on the injection point*/
+
+    /** Binding annotations appeared on the injection point */
     private Set<Annotation> bindingAnnotations = new HashSet<Annotation>();
-    
+
     /**
      * Creates new instance.
+     * 
      * @param injectionClazz injection class type
      * @param actualTypeArguments actual type arguments
      * @param annotations binding annotations
      */
-    InstanceImpl(Type injectionClazz, Type[] actualTypeArguments, Annotation...annotations)
+    InstanceImpl(Type injectionClazz, Annotation... annotations)
     {
         this.injectionClazz = injectionClazz;
-        this.actualTypeArguments = actualTypeArguments;
-        
-        for(Annotation ann : annotations)
+
+        for (Annotation ann : annotations)
         {
-            if(!ann.annotationType().equals(Obtains.class))
-            {
-                bindingAnnotations.add(ann);   
-            }
+            bindingAnnotations.add(ann);
         }
     }
 
     /**
      * Returns the bean instance with given binding annotations.
+     * 
      * @param annotations binding annotations
      * @return bean instance
      */
-    public T get(Annotation... annotations)
+    public T get()
     {
-        AnnotationUtil.checkBindingTypeConditions(annotations);
+        T instance = null;
+
+        Annotation[] anns = new Annotation[this.bindingAnnotations.size()];
+        anns = this.bindingAnnotations.toArray(anns);
         
-        if(annotations != null && annotations.length > 0)
+        Set<Bean<T>> beans = resolveBeans();
+
+        ResolutionUtil.checkResolvedBeans(beans, ClassUtil.getClazz(this.injectionClazz),anns);
+
+        Bean<T> bean = beans.iterator().next();
+        instance = ManagerImpl.getManager().getInstance(bean);
+
+        return instance;
+    }
+
+    /**
+     * Returns set of resolved beans.
+     * 
+     * @return set of resolved beans
+     */
+    private Set<Bean<T>> resolveBeans()
+    {
+        Annotation[] anns = new Annotation[this.bindingAnnotations.size()];
+        anns = this.bindingAnnotations.toArray(anns);
+
+        InjectionResolver resolver = InjectionResolver.getInstance();
+        Set<Bean<T>> beans = resolver.implResolveByType(this.injectionClazz,
anns);
+        
+        return beans;
+    }
+    
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public boolean isAmbiguous()
+    {
+        Set<Bean<T>> beans = resolveBeans();
+        
+        return beans.size() > 1 ? true : false;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public boolean isUnsatisfied()
+    {
+        Set<Bean<T>> beans = resolveBeans();
+        
+        return beans.size() == 0 ? true : false;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public Instance<T> select(Annotation... bindings)
+    {
+        Annotation[] newBindingsArray = getAdditionalBindings(bindings);
+        InstanceImpl<T> newInstance = new InstanceImpl<T>(this.injectionClazz,
newBindingsArray);
+
+        return newInstance;
+    }
+
+    /**
+     * Returns total binding types array
+     * 
+     * @param bindings additional bindings
+     * @return total binding types array
+     */
+    private Annotation[] getAdditionalBindings(Annotation[] bindings)
+    {
+        AnnotationUtil.checkBindingTypeConditions(bindings);
+        Set<Annotation> newBindings = new HashSet<Annotation>(this.bindingAnnotations);
+
+        if (bindings != null && bindings.length > 0)
         {
-            for(Annotation annot : annotations)
+            for (Annotation annot : bindings)
             {
-                if(this.bindingAnnotations.contains(annot))
+                if (newBindings.contains(annot))
                 {
                     throw new IllegalArgumentException("Duplicate Binding Exception, " +
this.toString());
                 }
-                
-                this.bindingAnnotations.add(annot);
+
+                newBindings.add(annot);
             }
         }
+
+        Annotation[] newBindingsArray = new Annotation[newBindings.size()];
+        newBindingsArray = newBindings.toArray(newBindingsArray);
         
-        Annotation[] anns = new Annotation[this.bindingAnnotations.size()];
-        anns = this.bindingAnnotations.toArray(anns);
+        return newBindingsArray;
+    }
+    
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    @SuppressWarnings("unchecked")
+    public <U extends T> Instance<U> select(Class<U> subtype, Annotation...
bindings)
+    {
+        AnnotationUtil.checkBindingTypeConditions(bindings);
         
-        InjectionResolver resolver = InjectionResolver.getInstance();
-        Set<Bean<T>> beans = resolver.implResolveByType(this.injectionClazz,
anns);
+        if(subtype == null)
+        {
+            subtype = (Class<U>)this.injectionClazz;
+        }
         
-        ResolutionUtil.checkResolvedBeans(beans, ClassUtil.getClazz(this.injectionClazz));
+        Annotation[] newBindings = getAdditionalBindings(bindings);
         
-        Bean<T> bean = beans.iterator().next();
+        InstanceImpl<U> newInstance = new InstanceImpl<U>(subtype, newBindings);
+                    
+        return newInstance;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public <U extends T> Instance<U> select(TypeLiteral<U> subtype, Annotation...
bindings)
+    {        
+        return select(subtype.getRawType(), bindings);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public Iterator<T> iterator()
+    {
+        Set<Bean<T>> beans = resolveBeans();
+        Set<T> instances = new HashSet<T>();
+        for(Bean<T> bean : beans)
+        {
+            T instance = ManagerImpl.getManager().getInstance(bean);
+            instances.add(instance);
+        }
         
-        return ManagerImpl.getManager().getInstance(bean);
+        return instances.iterator();
     }
 
     public String toString()
@@ -108,35 +215,21 @@
         builder.append("Instance<");
         builder.append(ClassUtil.getClazz(this.injectionClazz).getName());
         builder.append(">");
-        builder.append(" with actual type arguments {");
-        
+
+        builder.append(",with binding annotations {");
         int i = 0;
-        for(Type type : this.actualTypeArguments)
+        for (Annotation binding : this.bindingAnnotations)
         {
-            Class<?> clazz = (Class<?>)type;
-            
-            if(i != 0)
+            if (i != 0)
             {
                 builder.append(",");
             }
-            
-            builder.append(clazz.getName());            
-        }
-        
-        builder.append("} with binding annotations {");
-        i = 0;
-        for(Annotation binding : this.bindingAnnotations)
-        {
-            if(i != 0)
-            {
-                builder.append(",");
-            }
-            
-            builder.append(binding.toString());            
+
+            builder.append(binding.toString());
         }
-        
+
         builder.append("}");
-        
+
         return builder.toString();
-    }   
+    }
 }
\ No newline at end of file

Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java?rev=789094&r1=789093&r2=789094&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java
(original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java
Sun Jun 28 12:47:42 2009
@@ -726,7 +726,7 @@
     
     public static <T> InstanceComponentImpl<T> createInstanceComponent(ParameterizedType
instance,Class<Instance<T>> clazz, Type injectedType, Annotation...obtainsBindings)
     {
-        InstanceComponentImpl<T> instanceComponent = new InstanceComponentImpl<T>(clazz,injectedType,
instance.getActualTypeArguments());
+        InstanceComponentImpl<T> instanceComponent = new InstanceComponentImpl<T>(clazz,injectedType);
         
         instanceComponent.addApiType(clazz);
         instanceComponent.addApiType(Object.class);
@@ -1692,52 +1692,73 @@
     }
     
     /**
-     * Check bean <code>Obtains</code> field injection conditions.
-     * @param <T> bean class type
-     * @param clazz bean class
+     * Returns true if instance injection point false otherwise.
+     * 
+     * @param injectionPoint injection point definition
+     * @return true if instance injection point
      */
-    public static <T> void checkObtainsInjectionPointConditions(InjectionPoint injectionPoint)
+    public static boolean checkObtainsInjectionPointConditions(InjectionPoint injectionPoint)
     {        
-            Class<?> rawType = null;
+        Type type = injectionPoint.getType();
+        
+        Class<?> candidateClazz = null;
+        if(type instanceof Class)
+        {
+            candidateClazz = (Class<?>)type;
+        }
+        else if(type instanceof ParameterizedType)
+        {
+            ParameterizedType pt = (ParameterizedType)type;
+            candidateClazz = (Class<?>)pt.getRawType();
+        }
+        
+        if(!candidateClazz.equals(Instance.class))
+        {
+            return false;
+        }        
+        
+        Class<?> rawType = null;
+        
+        if(ClassUtil.isParametrizedType(injectionPoint.getType()))
+        {
+            ParameterizedType pt = (ParameterizedType)injectionPoint.getType();
+            
+            rawType = (Class<?>) pt.getRawType();
+            
+            Type[] typeArgs = pt.getActualTypeArguments();
             
-            if(ClassUtil.isParametrizedType(injectionPoint.getType()))
+            if(!(rawType.equals(Instance.class)))
             {
-                ParameterizedType pt = (ParameterizedType)injectionPoint.getType();
-                
-                rawType = (Class<?>) pt.getRawType();
-                
-                Type[] typeArgs = pt.getActualTypeArguments();
-                
-                if(!(rawType.equals(Instance.class)))
+                throw new WebBeansConfigurationException("<Instance> field injection
" + injectionPoint.toString() + " must have type javax.inject.Instance");
+            }                
+            else
+            {                                        
+                if(typeArgs.length == 1)
                 {
-                    throw new WebBeansConfigurationException("@Obtains field injection "
+ injectionPoint.toString() + " must have type javax.inject.Instance");
-                }                
-                else
-                {                                        
-                    if(typeArgs.length == 1)
-                    {
-                        Type actualArgument = typeArgs[0];
-                        
-                        if(ClassUtil.isParametrizedType(actualArgument) || ClassUtil.isWildCardType(actualArgument)
|| ClassUtil.isTypeVariable(actualArgument))
-                        {                            
-                            throw new WebBeansConfigurationException("@Obtains field injection
" + injectionPoint.toString() + " actual type argument can not be Parametrized, Wildcard type
or Type variable");                            
-                        }
-                                                
-                        if(ClassUtil.isDefinitionConstainsTypeVariables((Class<?>)actualArgument))
-                        {
-                            throw new WebBeansConfigurationException("@Obtains field injection
" + injectionPoint.toString() + " must not have TypeVariable or WildCard generic type argument");
                           
-                        }
+                    Type actualArgument = typeArgs[0];
+                    
+                    if(ClassUtil.isParametrizedType(actualArgument) || ClassUtil.isWildCardType(actualArgument)
|| ClassUtil.isTypeVariable(actualArgument))
+                    {                            
+                        throw new WebBeansConfigurationException("<Instance> field
injection " + injectionPoint.toString() + " actual type argument can not be Parametrized,
Wildcard type or Type variable");                            
                     }
-                    else
+                                            
+                    if(ClassUtil.isDefinitionConstainsTypeVariables((Class<?>)actualArgument))
                     {
-                        throw new WebBeansConfigurationException("@Obtains field injection
" + injectionPoint.toString() + " must not have more than one actual type argument");
+                        throw new WebBeansConfigurationException("<Instance> field
injection " + injectionPoint.toString() + " must not have TypeVariable or WildCard generic
type argument");                            
                     }
-                }                                
-            }
-            else
-            {
-                throw new WebBeansConfigurationException("@Obtains field injection " + injectionPoint.toString()
+ " must be defined as ParameterizedType with one actual type argument");
-            }        
+                }
+                else
+                {
+                    throw new WebBeansConfigurationException("<Instance> field injection
" + injectionPoint.toString() + " must not have more than one actual type argument");
+                }
+            }                                
+        }
+        else
+        {
+            throw new WebBeansConfigurationException("<Instance> field injection "
+ injectionPoint.toString() + " must be defined as ParameterizedType with one actual type
argument");
+        }  
+        
+        return true;
     }
 
     public static <T> void checkPassivationScope(AbstractComponent<T> component,
ScopeType scope)

Modified: incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/inject/InstanceInjectedComponent.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/inject/InstanceInjectedComponent.java?rev=789094&r1=789093&r2=789094&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/inject/InstanceInjectedComponent.java
(original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/inject/InstanceInjectedComponent.java
Sun Jun 28 12:47:42 2009
@@ -16,19 +16,17 @@
  */
 package org.apache.webbeans.test.component.inject;
 
-import java.lang.annotation.Annotation;
 
 import javax.enterprise.context.RequestScoped;
 import javax.enterprise.inject.Current;
 import javax.enterprise.inject.Instance;
-import javax.inject.Obtains;
 
 import org.apache.webbeans.test.component.PaymentProcessorComponent;
 
 @RequestScoped
 public class InstanceInjectedComponent
 {
-    @Obtains @Current Instance<PaymentProcessorComponent> instance;
+    @Current Instance<PaymentProcessorComponent> instance;
     
     public InstanceInjectedComponent()
     {
@@ -42,7 +40,7 @@
     
     public PaymentProcessorComponent getPaymentComponent()
     {
-        return instance.get(new Annotation[]{});
+        return instance.get();
     }
 
 }

Modified: incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/inject/broken/InstanceInjectedBrokenComponent1.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/inject/broken/InstanceInjectedBrokenComponent1.java?rev=789094&r1=789093&r2=789094&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/inject/broken/InstanceInjectedBrokenComponent1.java
(original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/inject/broken/InstanceInjectedBrokenComponent1.java
Sun Jun 28 12:47:42 2009
@@ -16,11 +16,11 @@
  */
 package org.apache.webbeans.test.component.inject.broken;
 
-import javax.inject.Obtains;
+import javax.enterprise.inject.Any;
+import javax.enterprise.inject.Instance;
 
-import org.apache.webbeans.test.component.IPayment;
 
 public class InstanceInjectedBrokenComponent1
 {
-    @Obtains IPayment payment;
+    @Any Instance payment;
 }

Modified: incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/inject/broken/InstanceInjectedBrokenComponent2.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/inject/broken/InstanceInjectedBrokenComponent2.java?rev=789094&r1=789093&r2=789094&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/inject/broken/InstanceInjectedBrokenComponent2.java
(original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/inject/broken/InstanceInjectedBrokenComponent2.java
Sun Jun 28 12:47:42 2009
@@ -16,12 +16,12 @@
  */
 package org.apache.webbeans.test.component.inject.broken;
 
+import javax.enterprise.inject.Any;
 import javax.enterprise.inject.Instance;
-import javax.inject.Obtains;
 
 import org.apache.webbeans.test.component.ITypeLiteralComponent;
 
 public class InstanceInjectedBrokenComponent2
 {
-    @Obtains Instance<ITypeLiteralComponent<?>> instance;
+    @Any Instance<ITypeLiteralComponent<?>> instance;
 }

Modified: incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/inject/broken/InstanceInjectedBrokenComponent3.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/inject/broken/InstanceInjectedBrokenComponent3.java?rev=789094&r1=789093&r2=789094&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/inject/broken/InstanceInjectedBrokenComponent3.java
(original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/inject/broken/InstanceInjectedBrokenComponent3.java
Sun Jun 28 12:47:42 2009
@@ -16,11 +16,11 @@
  */
 package org.apache.webbeans.test.component.inject.broken;
 
+import javax.enterprise.inject.Any;
 import javax.enterprise.inject.Instance;
-import javax.inject.Obtains;
 
 
 public class InstanceInjectedBrokenComponent3
 {
-    @Obtains Instance<?> instance;
+    @Any Instance<?> instance;
 }

Modified: incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/inject/broken/InstanceInjectedBrokenComponent4.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/inject/broken/InstanceInjectedBrokenComponent4.java?rev=789094&r1=789093&r2=789094&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/inject/broken/InstanceInjectedBrokenComponent4.java
(original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/inject/broken/InstanceInjectedBrokenComponent4.java
Sun Jun 28 12:47:42 2009
@@ -16,11 +16,11 @@
  */
 package org.apache.webbeans.test.component.inject.broken;
 
+import javax.enterprise.inject.Any;
 import javax.enterprise.inject.Instance;
-import javax.inject.Obtains;
 
 @SuppressWarnings("unchecked")
 public class InstanceInjectedBrokenComponent4
 {
-    @Obtains Instance instance;
+    @Any Instance instance;
 }

Modified: incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/servlet/TestContext.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/servlet/TestContext.java?rev=789094&r1=789093&r2=789094&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/servlet/TestContext.java
(original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/servlet/TestContext.java
Sun Jun 28 12:47:42 2009
@@ -23,11 +23,11 @@
 import javax.decorator.Decorator;
 import javax.enterprise.context.Dependent;
 import javax.enterprise.context.spi.Context;
+import javax.enterprise.inject.Instance;
 import javax.enterprise.inject.deployment.Production;
 import javax.enterprise.inject.spi.Bean;
 import javax.enterprise.inject.spi.InjectionPoint;
 import javax.enterprise.inject.spi.BeanManager;
-import javax.inject.Obtains;
 import javax.interceptor.Interceptor;
 import javax.servlet.ServletContext;
 import javax.servlet.ServletContextListener;
@@ -197,7 +197,7 @@
         for(InjectionPoint injectionPoint : injectionPoints)
         {
             //If contains the @Obtains, defines implicit component
-            if(injectionPoint.getAnnotated().isAnnotationPresent(Obtains.class))
+            if(injectionPoint.getAnnotated().getBaseType().equals(Instance.class))
             {
                 WebBeansUtil.addInjectedImplicitInstanceComponent(injectionPoint);
             }                                    

Modified: incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/inject/InjectedInstanceComponentTest.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/inject/InjectedInstanceComponentTest.java?rev=789094&r1=789093&r2=789094&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/inject/InjectedInstanceComponentTest.java
(original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/inject/InjectedInstanceComponentTest.java
Sun Jun 28 12:47:42 2009
@@ -38,7 +38,7 @@
     @Before
     public void init()
     {
-        initDefaultDeploymentTypes();
+        super.init();
     }
     
     @Test
@@ -61,5 +61,13 @@
         
         System.out.println(ins.toString());
         
+        boolean ambigious = ins.isAmbiguous();
+        
+        Assert.assertFalse(ambigious);
+        
+        boolean unsatisfied = ins.isUnsatisfied();
+        
+        Assert.assertFalse(unsatisfied);
+        
     }
 }

Modified: incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/inject/broken/InjectedInstanceBrokenComponentTest.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/inject/broken/InjectedInstanceBrokenComponentTest.java?rev=789094&r1=789093&r2=789094&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/inject/broken/InjectedInstanceBrokenComponentTest.java
(original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/inject/broken/InjectedInstanceBrokenComponentTest.java
Sun Jun 28 12:47:42 2009
@@ -35,7 +35,8 @@
     @Before
     public void init()
     {
-        initDefaultDeploymentTypes();        
+        super.init();     
+        
     }
     
     @Test



Mime
View raw message