Return-Path: Delivered-To: apmail-incubator-openwebbeans-commits-archive@minotaur.apache.org Received: (qmail 38918 invoked from network); 28 Jun 2009 12:47:55 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 28 Jun 2009 12:47:55 -0000 Received: (qmail 89971 invoked by uid 500); 28 Jun 2009 12:48:06 -0000 Delivered-To: apmail-incubator-openwebbeans-commits-archive@incubator.apache.org Received: (qmail 89951 invoked by uid 500); 28 Jun 2009 12:48:06 -0000 Mailing-List: contact openwebbeans-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: openwebbeans-dev@incubator.apache.org Delivered-To: mailing list openwebbeans-commits@incubator.apache.org Received: (qmail 89941 invoked by uid 99); 28 Jun 2009 12:48:06 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 28 Jun 2009 12:48:06 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 28 Jun 2009 12:48:03 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 85D6A23888BD; Sun, 28 Jun 2009 12:47:43 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: openwebbeans-commits@incubator.apache.org From: gerdogdu@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20090628124743.85D6A23888BD@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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> returnType, Type injectedType, Type[] injectedTypeArguments) + public InstanceComponentImpl(Class> 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> 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> 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> 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 void checkResolvedBeans(Set> resolvedSet, Class type, Annotation...bindingTypes) + public static void checkResolvedBeans(Set> 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 Instance getInstance(Type injectedType, Type[] actualTypeArguments, Annotation...annotations) + public static Instance getInstance(Type injectedType, Annotation...annotations) { - InstanceImpl instance = new InstanceImpl(injectedType,actualTypeArguments,annotations); + InstanceImpl instance = new InstanceImpl(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 injection type + * + * @param specific instance type */ class InstanceImpl implements Instance { - /**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 bindingAnnotations = new HashSet(); - + /** * 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> beans = resolveBeans(); + + ResolutionUtil.checkResolvedBeans(beans, ClassUtil.getClazz(this.injectionClazz),anns); + + Bean bean = beans.iterator().next(); + instance = ManagerImpl.getManager().getInstance(bean); + + return instance; + } + + /** + * Returns set of resolved beans. + * + * @return set of resolved beans + */ + private Set> resolveBeans() + { + Annotation[] anns = new Annotation[this.bindingAnnotations.size()]; + anns = this.bindingAnnotations.toArray(anns); + + InjectionResolver resolver = InjectionResolver.getInstance(); + Set> beans = resolver.implResolveByType(this.injectionClazz, anns); + + return beans; + } + + /** + * {@inheritDoc} + */ + @Override + public boolean isAmbiguous() + { + Set> beans = resolveBeans(); + + return beans.size() > 1 ? true : false; + } + + /** + * {@inheritDoc} + */ + @Override + public boolean isUnsatisfied() + { + Set> beans = resolveBeans(); + + return beans.size() == 0 ? true : false; + } + + /** + * {@inheritDoc} + */ + @Override + public Instance select(Annotation... bindings) + { + Annotation[] newBindingsArray = getAdditionalBindings(bindings); + InstanceImpl newInstance = new InstanceImpl(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 newBindings = new HashSet(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 Instance select(Class subtype, Annotation... bindings) + { + AnnotationUtil.checkBindingTypeConditions(bindings); - InjectionResolver resolver = InjectionResolver.getInstance(); - Set> beans = resolver.implResolveByType(this.injectionClazz, anns); + if(subtype == null) + { + subtype = (Class)this.injectionClazz; + } - ResolutionUtil.checkResolvedBeans(beans, ClassUtil.getClazz(this.injectionClazz)); + Annotation[] newBindings = getAdditionalBindings(bindings); - Bean bean = beans.iterator().next(); + InstanceImpl newInstance = new InstanceImpl(subtype, newBindings); + + return newInstance; + } + + /** + * {@inheritDoc} + */ + @Override + public Instance select(TypeLiteral subtype, Annotation... bindings) + { + return select(subtype.getRawType(), bindings); + } + + /** + * {@inheritDoc} + */ + @Override + public Iterator iterator() + { + Set> beans = resolveBeans(); + Set instances = new HashSet(); + for(Bean 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 InstanceComponentImpl createInstanceComponent(ParameterizedType instance,Class> clazz, Type injectedType, Annotation...obtainsBindings) { - InstanceComponentImpl instanceComponent = new InstanceComponentImpl(clazz,injectedType, instance.getActualTypeArguments()); + InstanceComponentImpl instanceComponent = new InstanceComponentImpl(clazz,injectedType); instanceComponent.addApiType(clazz); instanceComponent.addApiType(Object.class); @@ -1692,52 +1692,73 @@ } /** - * Check bean Obtains field injection conditions. - * @param 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 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(" 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(" 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(" 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(" field injection " + injectionPoint.toString() + " must not have more than one actual type argument"); + } + } + } + else + { + throw new WebBeansConfigurationException(" field injection " + injectionPoint.toString() + " must be defined as ParameterizedType with one actual type argument"); + } + + return true; } public static void checkPassivationScope(AbstractComponent 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 instance; + @Current Instance 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> instance; + @Any Instance> 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