You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openwebbeans.apache.org by ar...@apache.org on 2012/11/13 18:04:58 UTC
svn commit: r1408834 - in /openwebbeans/trunk:
webbeans-ejb/src/main/java/org/apache/webbeans/ejb/common/util/
webbeans-impl/src/main/java/org/apache/webbeans/config/
webbeans-impl/src/main/java/org/apache/webbeans/util/
webbeans-impl/src/test/java/org...
Author: arne
Date: Tue Nov 13 17:04:55 2012
New Revision: 1408834
URL: http://svn.apache.org/viewvc?rev=1408834&view=rev
Log:
OWB-719: Changing the @Named qualifier of a bean based on the bean name
Added:
openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/injection/named/
openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/injection/named/AbstractNamedBean.java
openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/injection/named/DefaultNamedBean.java
openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/injection/named/NamedBean.java
openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/injection/named/NamedInjectionPoints.java
openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/injection/named/NamedInterface.java
openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/injection/named/NamedTests.java
openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/producer/ConsumerBean.java
openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/producer/NamedProducerTest.java (with props)
openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/producer/ProducerBean.java
Modified:
openwebbeans/trunk/webbeans-ejb/src/main/java/org/apache/webbeans/ejb/common/util/EjbUtility.java
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/DefinitionUtil.java
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/ManagedBeanConfigurator.java
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansAnnotatedTypeUtil.java
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java
Modified: openwebbeans/trunk/webbeans-ejb/src/main/java/org/apache/webbeans/ejb/common/util/EjbUtility.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-ejb/src/main/java/org/apache/webbeans/ejb/common/util/EjbUtility.java?rev=1408834&r1=1408833&r2=1408834&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-ejb/src/main/java/org/apache/webbeans/ejb/common/util/EjbUtility.java (original)
+++ openwebbeans/trunk/webbeans-ejb/src/main/java/org/apache/webbeans/ejb/common/util/EjbUtility.java Tue Nov 13 17:04:55 2012
@@ -90,8 +90,8 @@ public final class EjbUtility
ejbBeanCreator.defineStereoTypes();
ejbBeanCreator.defineApiType();
ejbBeanCreator.defineScopeType("Session Bean implementation class : " + clazz.getName() + " stereotypes must declare same @ScopeType annotations", false);
- ejbBeanCreator.defineQualifier();
ejbBeanCreator.defineName(WebBeansUtil.getManagedBeanDefaultName(clazz.getSimpleName()));
+ ejbBeanCreator.defineQualifier();
Set<ProducerMethodBean<?>> producerMethodBeans = ejbBeanCreator.defineProducerMethods();
checkProducerMethods(producerMethodBeans, ejbBean);
Set<ProducerFieldBean<?>> producerFieldBeans = ejbBeanCreator.defineProducerFields();
Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/DefinitionUtil.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/DefinitionUtil.java?rev=1408834&r1=1408833&r2=1408834&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/DefinitionUtil.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/DefinitionUtil.java Tue Nov 13 17:04:55 2012
@@ -18,6 +18,8 @@
*/
package org.apache.webbeans.config;
+import static org.apache.webbeans.util.InjectionExceptionUtils.throwUnsatisfiedResolutionException;
+
import java.io.Serializable;
import java.lang.annotation.Annotation;
import java.lang.reflect.Constructor;
@@ -36,10 +38,10 @@ import java.util.Set;
import javax.enterprise.context.Dependent;
import javax.enterprise.context.NormalScope;
import javax.enterprise.event.Observes;
-import javax.enterprise.inject.Typed;
import javax.enterprise.inject.Disposes;
import javax.enterprise.inject.Produces;
import javax.enterprise.inject.Specializes;
+import javax.enterprise.inject.Typed;
import javax.enterprise.inject.spi.AnnotatedMethod;
import javax.enterprise.inject.spi.AnnotatedParameter;
import javax.enterprise.inject.spi.AnnotatedType;
@@ -55,13 +57,14 @@ import org.apache.webbeans.annotation.An
import org.apache.webbeans.annotation.AnyLiteral;
import org.apache.webbeans.annotation.DefaultLiteral;
import org.apache.webbeans.annotation.DependentScopeLiteral;
-import org.apache.webbeans.component.AbstractOwbBean;
+import org.apache.webbeans.annotation.NamedLiteral;
import org.apache.webbeans.component.AbstractInjectionTargetBean;
+import org.apache.webbeans.component.AbstractOwbBean;
import org.apache.webbeans.component.AbstractProducerBean;
import org.apache.webbeans.component.EnterpriseBeanMarker;
+import org.apache.webbeans.component.InjectionTargetBean;
import org.apache.webbeans.component.ManagedBean;
import org.apache.webbeans.component.OwbBean;
-import org.apache.webbeans.component.InjectionTargetBean;
import org.apache.webbeans.component.ProducerFieldBean;
import org.apache.webbeans.component.ProducerMethodBean;
import org.apache.webbeans.component.ResourceBean;
@@ -79,7 +82,6 @@ import org.apache.webbeans.util.Annotati
import org.apache.webbeans.util.Asserts;
import org.apache.webbeans.util.ClassUtil;
import org.apache.webbeans.util.WebBeansUtil;
-import static org.apache.webbeans.util.InjectionExceptionUtils.throwUnsatisfiedResolutionException;
/**
* Defines the web beans components common properties.
@@ -255,7 +257,14 @@ public final class DefinitionUtil
}
}
- component.addQualifier(annotation);
+ if (annotation.annotationType().equals(Named.class) && component.getName() != null)
+ {
+ component.addQualifier(new NamedLiteral(component.getName()));
+ }
+ else
+ {
+ component.addQualifier(annotation);
+ }
}
}
@@ -762,8 +771,8 @@ public final class DefinitionUtil
+ " must declare default @Scope annotation", false);
webBeansContext.getWebBeansUtil().checkUnproxiableApiType(component, component.getScope());
WebBeansUtil.checkProducerGenericType(component,method);
- defineQualifiers(component, methodAnns);
defineName(component, methodAnns, WebBeansUtil.getProducerDefaultName(method.getName()));
+ defineQualifiers(component, methodAnns);
return component;
}
@@ -1360,8 +1369,8 @@ public final class DefinitionUtil
defineScopeType(bean, anns, "Bean producer method : " + method.getJavaMember().getName() + " in class "
+ parent.getReturnType().getName() + " must declare default @Scope annotation", false);
WebBeansUtil.checkProducerGenericType(bean,method.getJavaMember());
- defineQualifiers(bean, anns);
defineName(bean, anns, WebBeansUtil.getProducerDefaultName(method.getJavaMember().getName()));
+ defineQualifiers(bean, anns);
return bean;
}
Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/ManagedBeanConfigurator.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/ManagedBeanConfigurator.java?rev=1408834&r1=1408833&r2=1408834&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/ManagedBeanConfigurator.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/ManagedBeanConfigurator.java Tue Nov 13 17:04:55 2012
@@ -149,8 +149,8 @@ public final class ManagedBeanConfigurat
component.setFullInit(true);
WebBeansUtil.checkGenericType(component);
- definitionUtil.defineQualifiers(component, clazzAnns);
definitionUtil.defineName(component, clazzAnns, WebBeansUtil.getManagedBeanDefaultName(clazz.getSimpleName()));
+ definitionUtil.defineQualifiers(component, clazzAnns);
Constructor<T> constructor = webBeansContext.getWebBeansUtil().defineConstructor(clazz);
component.setConstructor(constructor);
Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansAnnotatedTypeUtil.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansAnnotatedTypeUtil.java?rev=1408834&r1=1408833&r2=1408834&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansAnnotatedTypeUtil.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansAnnotatedTypeUtil.java Tue Nov 13 17:04:55 2012
@@ -524,10 +524,10 @@ public final class WebBeansAnnotatedType
webBeansContext.getWebBeansUtil().checkUnproxiableApiType(producerMethodBean,
producerMethodBean.getScope());
WebBeansUtil.checkProducerGenericType(producerMethodBean,annotatedMethod.getJavaMember());
- definitionUtil.defineQualifiers(producerMethodBean, AnnotationUtil.getAnnotationsFromSet(annotatedMethod.getAnnotations()));
definitionUtil.defineName(producerMethodBean,
AnnotationUtil.getAnnotationsFromSet(annotatedMethod.getAnnotations()),
WebBeansUtil.getProducerDefaultName(annotatedMethod.getJavaMember().getName()));
+ definitionUtil.defineQualifiers(producerMethodBean, AnnotationUtil.getAnnotationsFromSet(annotatedMethod.getAnnotations()));
addMethodInjectionPointMetaData(producerMethodBean, annotatedMethod);
producerBeans.add(producerMethodBean);
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=1408834&r1=1408833&r2=1408834&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 Tue Nov 13 17:04:55 2012
@@ -2622,8 +2622,8 @@ public final class WebBeansUtil
setInjectionTargetBeanEnableFlag(managedBean);
managedBeanCreator.checkCreateConditions();
- managedBeanCreator.defineQualifier();
managedBeanCreator.defineName(WebBeansUtil.getManagedBeanDefaultName(clazz.getSimpleName()));
+ managedBeanCreator.defineQualifier();
if (managedBean.isFullInit())
{
@@ -2773,8 +2773,8 @@ public final class WebBeansUtil
//Check for Enabled via Alternative
setInjectionTargetBeanEnableFlag(managedBean);
managedBeanCreator.checkCreateConditions();
- managedBeanCreator.defineQualifier();
managedBeanCreator.defineName(WebBeansUtil.getManagedBeanDefaultName(clazz.getSimpleName()));
+ managedBeanCreator.defineQualifier();
managedBeanCreator.defineConstructor();
managedBeanCreator.defineProducerMethods();
managedBeanCreator.defineProducerFields();
@@ -2935,8 +2935,8 @@ public final class WebBeansUtil
//Check for Enabled via Alternative
setInjectionTargetBeanEnableFlag(managedBean);
managedBeanCreator.checkCreateConditions();
- managedBeanCreator.defineQualifier();
managedBeanCreator.defineName(getManagedBeanDefaultName(clazz.getSimpleName()));
+ managedBeanCreator.defineQualifier();
managedBeanCreator.defineConstructor();
managedBeanCreator.defineProducerMethods();
managedBeanCreator.defineProducerFields();
Added: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/injection/named/AbstractNamedBean.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/injection/named/AbstractNamedBean.java?rev=1408834&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/injection/named/AbstractNamedBean.java (added)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/injection/named/AbstractNamedBean.java Tue Nov 13 17:04:55 2012
@@ -0,0 +1,26 @@
+/*
+ * 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.newtests.injection.named;
+
+public class AbstractNamedBean implements NamedInterface {
+
+ public String getName() {
+ return getClass().getSimpleName();
+ }
+}
Added: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/injection/named/DefaultNamedBean.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/injection/named/DefaultNamedBean.java?rev=1408834&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/injection/named/DefaultNamedBean.java (added)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/injection/named/DefaultNamedBean.java Tue Nov 13 17:04:55 2012
@@ -0,0 +1,26 @@
+/*
+ * 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.newtests.injection.named;
+
+import javax.inject.Named;
+
+@Named
+public class DefaultNamedBean extends AbstractNamedBean {
+
+}
Added: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/injection/named/NamedBean.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/injection/named/NamedBean.java?rev=1408834&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/injection/named/NamedBean.java (added)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/injection/named/NamedBean.java Tue Nov 13 17:04:55 2012
@@ -0,0 +1,26 @@
+/*
+ * 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.newtests.injection.named;
+
+import javax.inject.Named;
+
+@Named("named")
+public class NamedBean extends AbstractNamedBean {
+
+}
Added: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/injection/named/NamedInjectionPoints.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/injection/named/NamedInjectionPoints.java?rev=1408834&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/injection/named/NamedInjectionPoints.java (added)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/injection/named/NamedInjectionPoints.java Tue Nov 13 17:04:55 2012
@@ -0,0 +1,55 @@
+/*
+ * 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.newtests.injection.named;
+
+import javax.inject.Inject;
+import javax.inject.Named;
+
+public class NamedInjectionPoints {
+
+ @Inject
+ @Named("named")
+ private NamedInterface namedBeanWithNamedInjectionPoint;
+ @Inject
+ @Named
+ private NamedInterface named;
+
+ @Inject
+ @Named("defaultNamedBean")
+ private NamedInterface defaultNamedBeanWithNamedInjectionPoint;
+ @Inject
+ @Named
+ private NamedInterface defaultNamedBean;
+
+ public NamedInterface getNamedBeanWithNamedInjectionPoint() {
+ return namedBeanWithNamedInjectionPoint;
+ }
+
+ public NamedInterface getNamed() {
+ return named;
+ }
+
+ public NamedInterface getDefaultNamedBeanWithNamedInjectionPoint() {
+ return defaultNamedBeanWithNamedInjectionPoint;
+ }
+
+ public NamedInterface getDefaultNamedBean() {
+ return defaultNamedBean;
+ }
+}
Added: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/injection/named/NamedInterface.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/injection/named/NamedInterface.java?rev=1408834&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/injection/named/NamedInterface.java (added)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/injection/named/NamedInterface.java Tue Nov 13 17:04:55 2012
@@ -0,0 +1,25 @@
+/*
+ * 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.newtests.injection.named;
+
+
+public interface NamedInterface {
+
+ String getName();
+}
Added: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/injection/named/NamedTests.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/injection/named/NamedTests.java?rev=1408834&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/injection/named/NamedTests.java (added)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/injection/named/NamedTests.java Tue Nov 13 17:04:55 2012
@@ -0,0 +1,59 @@
+/*
+ * 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.newtests.injection.named;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+import javax.enterprise.context.spi.CreationalContext;
+import javax.enterprise.inject.spi.Bean;
+
+import org.apache.webbeans.newtests.AbstractUnitTest;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class NamedTests extends AbstractUnitTest {
+
+ @Test
+ public void testNamedInjection()
+ {
+ Collection<String> beanXmls = new ArrayList<String>();
+ Collection<Class<?>> beanClasses = new ArrayList<Class<?>>();
+
+ beanClasses.add(NamedInterface.class);
+ beanClasses.add(NamedBean.class);
+ beanClasses.add(DefaultNamedBean.class);
+ beanClasses.add(NamedInjectionPoints.class);
+
+ startContainer(beanClasses, beanXmls);
+
+ Bean<?> injectionPointsBean = getBeanManager().getBeans(NamedInjectionPoints.class).iterator().next();
+ CreationalContext<?> context = getBeanManager().createCreationalContext(injectionPointsBean);
+ NamedInjectionPoints consumer = (NamedInjectionPoints) getBeanManager().getReference(injectionPointsBean, NamedInjectionPoints.class, context);
+
+ Assert.assertEquals("NamedBean", consumer.getNamedBeanWithNamedInjectionPoint().getName());
+ Assert.assertEquals("NamedBean", consumer.getNamed().getName());
+ Assert.assertEquals("DefaultNamedBean", consumer.getDefaultNamedBeanWithNamedInjectionPoint().getName());
+ Assert.assertEquals("DefaultNamedBean", consumer.getDefaultNamedBean().getName());
+
+ shutDownContainer();
+
+ }
+
+}
Added: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/producer/ConsumerBean.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/producer/ConsumerBean.java?rev=1408834&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/producer/ConsumerBean.java (added)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/producer/ConsumerBean.java Tue Nov 13 17:04:55 2012
@@ -0,0 +1,73 @@
+/*
+ * 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.newtests.producer;
+
+import javax.inject.Inject;
+import javax.inject.Named;
+
+public class ConsumerBean {
+
+ @Inject
+ @Named("name1")
+ private String name1;
+
+ @Inject
+ @Named("name2")
+ private String name2;
+
+ @Inject
+ @Named("name3")
+ private boolean name3;
+
+ @Inject
+ @Named("name4")
+ private String name4;
+
+ @Inject
+ @Named("name5")
+ private String name5;
+
+ @Inject
+ @Named("name6")
+ private boolean name6;
+
+ public String getName1() {
+ return name1;
+ }
+
+ public String getName2() {
+ return name2;
+ }
+
+ public boolean isName3() {
+ return name3;
+ }
+
+ public String getName4() {
+ return name4;
+ }
+
+ public String getName5() {
+ return name5;
+ }
+
+ public boolean isName6() {
+ return name6;
+ }
+}
Added: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/producer/NamedProducerTest.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/producer/NamedProducerTest.java?rev=1408834&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/producer/NamedProducerTest.java (added)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/producer/NamedProducerTest.java Tue Nov 13 17:04:55 2012
@@ -0,0 +1,59 @@
+/*
+ * 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.newtests.producer;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+import javax.enterprise.context.spi.CreationalContext;
+import javax.enterprise.inject.spi.Bean;
+
+import org.apache.webbeans.newtests.AbstractUnitTest;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class NamedProducerTest extends AbstractUnitTest
+{
+
+ @Test
+ public void testNamedProducer()
+ {
+ Collection<String> beanXmls = new ArrayList<String>();
+ Collection<Class<?>> beanClasses = new ArrayList<Class<?>>();
+
+ beanClasses.add(ProducerBean.class);
+ beanClasses.add(ConsumerBean.class);
+
+ startContainer(beanClasses, beanXmls);
+
+ Bean<?> consumerBean = getBeanManager().getBeans(ConsumerBean.class).iterator().next();
+ CreationalContext<?> context = getBeanManager().createCreationalContext(consumerBean);
+ ConsumerBean consumer = (ConsumerBean) getBeanManager().getReference(consumerBean, ConsumerBean.class, context);
+
+ Assert.assertEquals("name1", consumer.getName1());
+ Assert.assertEquals("name2", consumer.getName2());
+ Assert.assertEquals(true, consumer.isName3());
+ Assert.assertEquals("name4", consumer.getName4());
+ Assert.assertEquals("name5", consumer.getName5());
+ Assert.assertEquals(true, consumer.isName6());
+
+ shutDownContainer();
+
+ }
+}
Propchange: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/producer/NamedProducerTest.java
------------------------------------------------------------------------------
svn:executable = *
Added: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/producer/ProducerBean.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/producer/ProducerBean.java?rev=1408834&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/producer/ProducerBean.java (added)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/producer/ProducerBean.java Tue Nov 13 17:04:55 2012
@@ -0,0 +1,61 @@
+/*
+ * 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.newtests.producer;
+
+import javax.enterprise.inject.Produces;
+import javax.inject.Named;
+
+public class ProducerBean {
+
+ @Produces
+ @Named
+ public String name1() {
+ return "name1";
+ }
+
+ @Produces
+ @Named
+ public String getName2() {
+ return "name2";
+ }
+
+ @Produces
+ @Named
+ public boolean isName3() {
+ return true;
+ }
+
+ @Produces
+ @Named("name4")
+ public String producesName4() {
+ return "name4";
+ }
+
+ @Produces
+ @Named("name5")
+ public String getName6() {
+ return "name5";
+ }
+
+ @Produces
+ @Named("name6")
+ public boolean isName6() {
+ return true;
+ }
+}