[weld-commits] Weld SVN: r5871 - cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/byname/broken/injectionPointWithNamed and 6 other directories.
weld-commits at lists.jboss.org
weld-commits at lists.jboss.org
Wed Feb 17 12:29:28 EST 2010
Author: pete.muir at jboss.org
Date: 2010-02-17 12:29:27 -0500 (Wed, 17 Feb 2010)
New Revision: 5871
Added:
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/byname/broken/injectionPointWithNamed/Baz.java
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/byname/broken/injectionPointWithNamed2/Bar.java
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/byname/broken/injectionPointWithNamed3/
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/byname/broken/injectionPointWithNamed3/Bar.java
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/byname/broken/injectionPointWithNamed3/Foo.java
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/byname/broken/injectionPointWithNamed3/NamedNonFieldInjectionPointTest.java
Modified:
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/byname/broken/injectionPointWithNamed/Bar.java
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/byname/broken/injectionPointWithNamed/Foo.java
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/byname/broken/injectionPointWithNamed2/Foo.java
core/trunk/impl/src/main/java/org/jboss/weld/bootstrap/Validator.java
core/trunk/impl/src/main/java/org/jboss/weld/event/ObserverMethodImpl.java
core/trunk/impl/src/main/java/org/jboss/weld/logging/messages/ValidatorMessage.java
core/trunk/impl/src/main/resources/org/jboss/weld/messages/validator_en.properties
Log:
WELD-427
Modified: cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/byname/broken/injectionPointWithNamed/Bar.java
===================================================================
--- cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/byname/broken/injectionPointWithNamed/Bar.java 2010-02-17 17:13:38 UTC (rev 5870)
+++ cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/byname/broken/injectionPointWithNamed/Bar.java 2010-02-17 17:29:27 UTC (rev 5871)
@@ -1,19 +1,3 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2010, Red Hat, Inc., and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * Licensed 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.jboss.jsr299.tck.tests.lookup.byname.broken.injectionPointWithNamed;
import javax.inject.Named;
Added: cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/byname/broken/injectionPointWithNamed/Baz.java
===================================================================
--- cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/byname/broken/injectionPointWithNamed/Baz.java (rev 0)
+++ cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/byname/broken/injectionPointWithNamed/Baz.java 2010-02-17 17:29:27 UTC (rev 5871)
@@ -0,0 +1,11 @@
+package org.jboss.jsr299.tck.tests.lookup.byname.broken.injectionPointWithNamed;
+
+public class Baz
+{
+
+ public Baz(String name)
+ {
+ // TODO Auto-generated constructor stub
+ }
+
+}
Property changes on: cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/byname/broken/injectionPointWithNamed/Baz.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Modified: cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/byname/broken/injectionPointWithNamed/Foo.java
===================================================================
--- cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/byname/broken/injectionPointWithNamed/Foo.java 2010-02-17 17:13:38 UTC (rev 5870)
+++ cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/byname/broken/injectionPointWithNamed/Foo.java 2010-02-17 17:29:27 UTC (rev 5871)
@@ -21,13 +21,10 @@
public class Foo
{
- public Foo(Bar bar)
- {
- }
@Produces
- public Foo produceFoo(@Named Bar bar)
+ public Baz produceFoo(@Named Bar bar)
{
- return new Foo(bar);
+ return new Baz("");
}
}
Added: cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/byname/broken/injectionPointWithNamed2/Bar.java
===================================================================
--- cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/byname/broken/injectionPointWithNamed2/Bar.java (rev 0)
+++ cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/byname/broken/injectionPointWithNamed2/Bar.java 2010-02-17 17:29:27 UTC (rev 5871)
@@ -0,0 +1,9 @@
+package org.jboss.jsr299.tck.tests.lookup.byname.broken.injectionPointWithNamed2;
+
+import javax.inject.Named;
+
+ at Named
+public class Bar
+{
+
+}
Property changes on: cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/byname/broken/injectionPointWithNamed2/Bar.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Modified: cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/byname/broken/injectionPointWithNamed2/Foo.java
===================================================================
--- cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/byname/broken/injectionPointWithNamed2/Foo.java 2010-02-17 17:13:38 UTC (rev 5870)
+++ cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/byname/broken/injectionPointWithNamed2/Foo.java 2010-02-17 17:29:27 UTC (rev 5871)
@@ -21,7 +21,7 @@
public class Foo
{
- public void observe(@Observes @Named Foo foo)
+ public void observe(@Observes Bar bar, @Named Bar bar1)
{
}
Added: cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/byname/broken/injectionPointWithNamed3/Bar.java
===================================================================
--- cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/byname/broken/injectionPointWithNamed3/Bar.java (rev 0)
+++ cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/byname/broken/injectionPointWithNamed3/Bar.java 2010-02-17 17:29:27 UTC (rev 5871)
@@ -0,0 +1,9 @@
+package org.jboss.jsr299.tck.tests.lookup.byname.broken.injectionPointWithNamed3;
+
+import javax.inject.Named;
+
+ at Named
+public class Bar
+{
+
+}
Property changes on: cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/byname/broken/injectionPointWithNamed3/Bar.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Added: cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/byname/broken/injectionPointWithNamed3/Foo.java
===================================================================
--- cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/byname/broken/injectionPointWithNamed3/Foo.java (rev 0)
+++ cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/byname/broken/injectionPointWithNamed3/Foo.java 2010-02-17 17:29:27 UTC (rev 5871)
@@ -0,0 +1,29 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed 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.jboss.jsr299.tck.tests.lookup.byname.broken.injectionPointWithNamed3;
+
+import javax.inject.Inject;
+import javax.inject.Named;
+
+public class Foo
+{
+ @Inject
+ public void initialize(@Named Bar bar)
+ {
+
+ }
+}
Property changes on: cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/byname/broken/injectionPointWithNamed3/Foo.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Added: cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/byname/broken/injectionPointWithNamed3/NamedNonFieldInjectionPointTest.java
===================================================================
--- cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/byname/broken/injectionPointWithNamed3/NamedNonFieldInjectionPointTest.java (rev 0)
+++ cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/byname/broken/injectionPointWithNamed3/NamedNonFieldInjectionPointTest.java 2010-02-17 17:29:27 UTC (rev 5871)
@@ -0,0 +1,42 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed 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.jboss.jsr299.tck.tests.lookup.byname.broken.injectionPointWithNamed3;
+
+import org.jboss.jsr299.tck.AbstractJSR299Test;
+import org.jboss.jsr299.tck.DeploymentFailure;
+import org.jboss.test.audit.annotations.SpecAssertion;
+import org.jboss.test.audit.annotations.SpecVersion;
+import org.jboss.testharness.impl.packaging.Artifact;
+import org.jboss.testharness.impl.packaging.ExpectedDeploymentException;
+import org.testng.annotations.Test;
+
+ at Artifact
+ at ExpectedDeploymentException(DeploymentFailure.class)
+ at SpecVersion(spec="cdi", version="20091101")
+public class NamedNonFieldInjectionPointTest extends AbstractJSR299Test
+{
+
+ @Test
+ @SpecAssertion(section = "3.11", id = "b")
+ //WELD-427
+ public void testNamedInitializerMethodInjectionPointNotAllowed() throws Exception
+ {
+ assert false;
+ }
+
+}
Property changes on: cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/byname/broken/injectionPointWithNamed3/NamedNonFieldInjectionPointTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Modified: core/trunk/impl/src/main/java/org/jboss/weld/bootstrap/Validator.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bootstrap/Validator.java 2010-02-17 17:13:38 UTC (rev 5870)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bootstrap/Validator.java 2010-02-17 17:29:27 UTC (rev 5871)
@@ -39,12 +39,14 @@
import static org.jboss.weld.logging.messages.ValidatorMessage.INTERCEPTOR_NOT_ANNOTATED_OR_REGISTERED;
import static org.jboss.weld.logging.messages.ValidatorMessage.INTERCEPTOR_SPECIFIED_TWICE;
import static org.jboss.weld.logging.messages.ValidatorMessage.NEW_WITH_QUALIFIERS;
+import static org.jboss.weld.logging.messages.ValidatorMessage.NON_FIELD_INJECTION_POINT_CANNOT_USE_NAMED;
import static org.jboss.weld.logging.messages.ValidatorMessage.NON_SERIALIZABLE_BEAN_INJECTED_INTO_PASSIVATING_BEAN;
import static org.jboss.weld.logging.messages.ValidatorMessage.NOT_PROXYABLE;
import static org.jboss.weld.logging.messages.ValidatorMessage.PASSIVATING_BEAN_WITH_NONSERIALIZABLE_DECORATOR;
import static org.jboss.weld.logging.messages.ValidatorMessage.PASSIVATING_BEAN_WITH_NONSERIALIZABLE_INTERCEPTOR;
import java.lang.annotation.Annotation;
+import java.lang.reflect.Field;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.TypeVariable;
import java.lang.reflect.WildcardType;
@@ -66,6 +68,7 @@
import javax.enterprise.inject.spi.InjectionPoint;
import javax.enterprise.inject.spi.InjectionTarget;
import javax.enterprise.inject.spi.Interceptor;
+import javax.inject.Named;
import org.jboss.interceptor.model.InterceptionModel;
import org.jboss.weld.bean.AbstractClassBean;
@@ -252,6 +255,10 @@
{
throw new DefinitionException(INJECTION_POINT_WITH_TYPE_VARIABLE, ij);
}
+ if (!(ij.getMember() instanceof Field) && ij.getAnnotated().isAnnotationPresent(Named.class) && ij.getAnnotated().getAnnotation(Named.class).value().equals(""))
+ {
+ throw new DefinitionException(NON_FIELD_INJECTION_POINT_CANNOT_USE_NAMED, ij);
+ }
checkFacadeInjectionPoint(ij, Instance.class);
checkFacadeInjectionPoint(ij, Event.class);
Annotation[] bindings = ij.getQualifiers().toArray(new Annotation[0]);
Modified: core/trunk/impl/src/main/java/org/jboss/weld/event/ObserverMethodImpl.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/event/ObserverMethodImpl.java 2010-02-17 17:13:38 UTC (rev 5870)
+++ core/trunk/impl/src/main/java/org/jboss/weld/event/ObserverMethodImpl.java 2010-02-17 17:29:27 UTC (rev 5871)
@@ -21,6 +21,7 @@
import static org.jboss.weld.logging.messages.EventMessage.INVALID_PRODUCER;
import static org.jboss.weld.logging.messages.EventMessage.INVALID_SCOPED_CONDITIONAL_OBSERVER;
import static org.jboss.weld.logging.messages.EventMessage.MULTIPLE_EVENT_PARAMETERS;
+import static org.jboss.weld.logging.messages.ValidatorMessage.NON_FIELD_INJECTION_POINT_CANNOT_USE_NAMED;
import java.lang.annotation.Annotation;
import java.lang.reflect.Type;
@@ -40,6 +41,7 @@
import javax.enterprise.inject.spi.Extension;
import javax.enterprise.inject.spi.ObserverMethod;
import javax.inject.Inject;
+import javax.inject.Named;
import javax.inject.Qualifier;
import org.jboss.weld.bean.RIBean;
@@ -48,6 +50,7 @@
import org.jboss.weld.injection.MethodInjectionPoint;
import org.jboss.weld.injection.WeldInjectionPoint;
import org.jboss.weld.introspector.WeldMethod;
+import org.jboss.weld.introspector.WeldParameter;
import org.jboss.weld.manager.BeanManagerImpl;
import org.jboss.weld.util.Beans;
@@ -147,6 +150,13 @@
{
throw new DefinitionException(INVALID_INITIALIZER, this);
}
+ for (WeldParameter<?, ?> parameter : getMethod().getWeldParameters())
+ {
+ if (parameter.isAnnotationPresent(Named.class) && parameter.getAnnotation(Named.class).value().equals(""))
+ {
+ throw new DefinitionException(NON_FIELD_INJECTION_POINT_CANNOT_USE_NAMED, getMethod());
+ }
+ }
}
Modified: core/trunk/impl/src/main/java/org/jboss/weld/logging/messages/ValidatorMessage.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/logging/messages/ValidatorMessage.java 2010-02-17 17:13:38 UTC (rev 5870)
+++ core/trunk/impl/src/main/java/org/jboss/weld/logging/messages/ValidatorMessage.java 2010-02-17 17:29:27 UTC (rev 5871)
@@ -63,5 +63,6 @@
@MessageId("001423") ALTERNATIVE_BEAN_CLASS_SPECIFIED_MULTIPLE_TIMES,
@MessageId("001424") DISPOSAL_METHODS_WITHOUT_PRODUCER,
@MessageId("001425") INJECTION_POINT_HAS_WILDCARD,
- @MessageId("001426") INJECTION_POINT_MUST_HAVE_TYPE_PARAMETER;
+ @MessageId("001426") INJECTION_POINT_MUST_HAVE_TYPE_PARAMETER,
+ @MessageId("001427") NON_FIELD_INJECTION_POINT_CANNOT_USE_NAMED;
}
Modified: core/trunk/impl/src/main/resources/org/jboss/weld/messages/validator_en.properties
===================================================================
--- core/trunk/impl/src/main/resources/org/jboss/weld/messages/validator_en.properties 2010-02-17 17:13:38 UTC (rev 5870)
+++ core/trunk/impl/src/main/resources/org/jboss/weld/messages/validator_en.properties 2010-02-17 17:29:27 UTC (rev 5871)
@@ -25,4 +25,4 @@
DISPOSAL_METHODS_WITHOUT_PRODUCER=The following disposal methods were declared but did not resolve to a producer method: {0}
INJECTION_POINT_HAS_WILDCARD=An injection point of type {0} cannot have a wildcard type parameter: {0}
INJECTION_POINT_MUST_HAVE_TYPE_PARAMETER=An injection point of type {0} must have a type parameter: {1}
-
+NON_FIELD_INJECTION_POINT_CANNOT_USE_NAMED=Only field injection points can use the @Named qualifier with no value. {0} is not a field injection point.
More information about the weld-commits
mailing list