Weld SVN: r5857 - core/trunk/impl/src/main/java/org/jboss/weld/logging/messages and 2 other directories.
by weld-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2010-02-16 17:38:58 -0500 (Tue, 16 Feb 2010)
New Revision: 5857
Modified:
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/initializer/broken/generic/GenericInitializerMethodTest.java
core/trunk/impl/src/main/java/org/jboss/weld/logging/messages/UtilMessage.java
core/trunk/impl/src/main/java/org/jboss/weld/util/Beans.java
core/trunk/impl/src/main/resources/org/jboss/weld/messages/util_en.properties
Log:
WELD-425
Modified: cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/initializer/broken/generic/GenericInitializerMethodTest.java
===================================================================
--- cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/initializer/broken/generic/GenericInitializerMethodTest.java 2010-02-16 22:27:47 UTC (rev 5856)
+++ cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/initializer/broken/generic/GenericInitializerMethodTest.java 2010-02-16 22:38:58 UTC (rev 5857)
@@ -32,7 +32,6 @@
{
@Test(groups = "ri-broken")
@SpecAssertion(section = "3.9.1", id = "ab")
- //WELD-425
public void testGenericInitializerMethodNotAllowed()
{
assert false;
Modified: core/trunk/impl/src/main/java/org/jboss/weld/logging/messages/UtilMessage.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/logging/messages/UtilMessage.java 2010-02-16 22:27:47 UTC (rev 5856)
+++ core/trunk/impl/src/main/java/org/jboss/weld/logging/messages/UtilMessage.java 2010-02-16 22:38:58 UTC (rev 5857)
@@ -62,6 +62,7 @@
@MessageId("000823") ERROR_INVOKING_METHOD,
@MessageId("000824") ACCESS_ERROR_ON_FIELD,
@MessageId("000825") NO_SUCH_METHOD,
- @MessageId("000826") ANNOTATION_VALUES_INACCESSIBLE;
+ @MessageId("000826") ANNOTATION_VALUES_INACCESSIBLE,
+ @MessageId("000827") INITIALIZER_METHOD_IS_GENERIC;
}
Modified: core/trunk/impl/src/main/java/org/jboss/weld/util/Beans.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/util/Beans.java 2010-02-16 22:27:47 UTC (rev 5856)
+++ core/trunk/impl/src/main/java/org/jboss/weld/util/Beans.java 2010-02-16 22:38:58 UTC (rev 5857)
@@ -30,6 +30,7 @@
import static org.jboss.weld.logging.messages.UtilMessage.INITIALIZER_CANNOT_BE_DISPOSAL_METHOD;
import static org.jboss.weld.logging.messages.UtilMessage.INITIALIZER_CANNOT_BE_OBSERVER;
import static org.jboss.weld.logging.messages.UtilMessage.INITIALIZER_CANNOT_BE_PRODUCER;
+import static org.jboss.weld.logging.messages.UtilMessage.INITIALIZER_METHOD_IS_GENERIC;
import static org.jboss.weld.logging.messages.UtilMessage.INVALID_QUANTITY_INJECTABLE_FIELDS_AND_INITIALIZER_METHODS;
import static org.jboss.weld.logging.messages.UtilMessage.QUALIFIER_ON_FINAL_FIELD;
import static org.jboss.weld.logging.messages.UtilMessage.REDUNDANT_QUALIFIER;
@@ -407,6 +408,10 @@
{
throw new DefinitionException(INITIALIZER_CANNOT_BE_OBSERVER, method, type);
}
+ else if (method.getJavaMember().getTypeParameters().length > 0)
+ {
+ throw new DefinitionException(INITIALIZER_METHOD_IS_GENERIC, method, type);
+ }
else
{
if (!isOverridden(method, seenMethods))
Modified: core/trunk/impl/src/main/resources/org/jboss/weld/messages/util_en.properties
===================================================================
--- core/trunk/impl/src/main/resources/org/jboss/weld/messages/util_en.properties 2010-02-16 22:27:47 UTC (rev 5856)
+++ core/trunk/impl/src/main/resources/org/jboss/weld/messages/util_en.properties 2010-02-16 22:38:58 UTC (rev 5857)
@@ -25,3 +25,4 @@
ACCESS_ERROR_ON_FIELD=Error getting field {0} on {1}
NO_SUCH_METHOD=Method {0} not implemented by instance {1}
ANNOTATION_VALUES_INACCESSIBLE=Cannot access values() on annotation
+INITIALIZER_METHOD_IS_GENERIC=Initializer method {0} declared on {1} may not be a generic method
14 years, 10 months
Weld SVN: r5856 - core/trunk/impl/src/main/java/org/jboss/weld/bean and 2 other directories.
by weld-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2010-02-16 17:27:47 -0500 (Tue, 16 Feb 2010)
New Revision: 5856
Modified:
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/field/definition/broken/inject/InjectAnnotatedProducerFieldTest.java
core/trunk/impl/src/main/java/org/jboss/weld/bean/ProducerField.java
core/trunk/impl/src/main/java/org/jboss/weld/logging/messages/BeanMessage.java
core/trunk/impl/src/main/resources/org/jboss/weld/messages/bean_en.properties
Log:
WELD-421
Modified: cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/field/definition/broken/inject/InjectAnnotatedProducerFieldTest.java
===================================================================
--- cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/field/definition/broken/inject/InjectAnnotatedProducerFieldTest.java 2010-02-16 21:57:38 UTC (rev 5855)
+++ cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/field/definition/broken/inject/InjectAnnotatedProducerFieldTest.java 2010-02-16 22:27:47 UTC (rev 5856)
@@ -36,7 +36,6 @@
@SpecAssertion(section = "3.4.2", id = "g"),
@SpecAssertion(section = "3.8.1", id = "b")
})
- //WELD-421
public void testInjectAnnotatedProducerFieldNotAllowed()
{
assert false;
Modified: core/trunk/impl/src/main/java/org/jboss/weld/bean/ProducerField.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bean/ProducerField.java 2010-02-16 21:57:38 UTC (rev 5855)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bean/ProducerField.java 2010-02-16 22:27:47 UTC (rev 5856)
@@ -16,18 +16,25 @@
*/
package org.jboss.weld.bean;
+import static org.jboss.weld.logging.Category.BEAN;
+import static org.jboss.weld.logging.LoggerFactory.loggerFactory;
+import static org.jboss.weld.logging.messages.BeanMessage.INJECTED_FIELD_CANNOT_BE_PRODUCER;
+
import java.lang.reflect.Field;
import java.util.Set;
import javax.enterprise.context.spi.CreationalContext;
import javax.enterprise.inject.spi.InjectionPoint;
import javax.enterprise.inject.spi.Producer;
+import javax.inject.Inject;
import org.jboss.interceptor.util.InterceptionUtils;
import org.jboss.weld.bootstrap.BeanDeployerEnvironment;
+import org.jboss.weld.exceptions.DefinitionException;
import org.jboss.weld.introspector.WeldField;
import org.jboss.weld.manager.BeanManagerImpl;
import org.jboss.weld.util.AnnotatedTypes;
+import org.slf4j.cal10n.LocLogger;
/**
* Represents a producer field
@@ -38,6 +45,8 @@
*/
public class ProducerField<X, T> extends AbstractProducerBean<X, T, Field>
{
+ private static final LocLogger log = loggerFactory().getLogger(BEAN);
+
// The underlying field
private WeldField<T, ? super X> field;
@@ -54,6 +63,7 @@
return new ProducerField<X, T>(field, declaringBean, beanManager);
}
+
/**
* Constructor
*
@@ -121,9 +131,19 @@
}
});
+ checkProducerFieldAnnotations();
}
}
+
+ protected void checkProducerFieldAnnotations()
+ {
+ if (getWeldAnnotated().isAnnotationPresent(Inject.class))
+ {
+ throw new DefinitionException(INJECTED_FIELD_CANNOT_BE_PRODUCER, getWeldAnnotated(), getWeldAnnotated().getDeclaringType());
+ }
+ }
+
protected void defaultDispose(T instance)
{
// No disposal by default
Modified: core/trunk/impl/src/main/java/org/jboss/weld/logging/messages/BeanMessage.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/logging/messages/BeanMessage.java 2010-02-16 21:57:38 UTC (rev 5855)
+++ core/trunk/impl/src/main/java/org/jboss/weld/logging/messages/BeanMessage.java 2010-02-16 22:27:47 UTC (rev 5856)
@@ -127,6 +127,7 @@
@MessageId("000090") ABSTRACT_METHOD_MUST_MATCH_DECORATED_TYPE,
@MessageId("000091") IP_NOT_CONSTRUCTOR_OR_METHOD,
@MessageId("000092") PARAM_NOT_IN_PARAM_LIST,
- @MessageId("000093") CANNOT_READ_OBJECT;
+ @MessageId("000093") CANNOT_READ_OBJECT,
+ @MessageId("000094") INJECTED_FIELD_CANNOT_BE_PRODUCER;
}
Modified: core/trunk/impl/src/main/resources/org/jboss/weld/messages/bean_en.properties
===================================================================
--- core/trunk/impl/src/main/resources/org/jboss/weld/messages/bean_en.properties 2010-02-16 21:57:38 UTC (rev 5855)
+++ core/trunk/impl/src/main/resources/org/jboss/weld/messages/bean_en.properties 2010-02-16 22:27:47 UTC (rev 5856)
@@ -92,3 +92,5 @@
IP_NOT_CONSTRUCTOR_OR_METHOD=Cannot handle injection point as a constructor or method: {0}
PARAM_NOT_IN_PARAM_LIST=Parameter position {0} is not in the parameter list: {1}
CANNOT_READ_OBJECT=Cannot read object
+INITIALIZER_CANNOT_BE_PRODUCER=Initializer method {0} cannot be annotated @Produces on {1}
+INJECTED_FIELD_CANNOT_BE_PRODUCER=Injected field {0} cannot be annotated @Produces on {1}
14 years, 10 months
Weld SVN: r5855 - cdi-tck/branches/1.0.
by weld-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2010-02-16 16:57:38 -0500 (Tue, 16 Feb 2010)
New Revision: 5855
Modified:
cdi-tck/branches/1.0/pom.xml
Log:
update uel
Modified: cdi-tck/branches/1.0/pom.xml
===================================================================
--- cdi-tck/branches/1.0/pom.xml 2010-02-16 21:55:26 UTC (rev 5854)
+++ cdi-tck/branches/1.0/pom.xml 2010-02-16 21:57:38 UTC (rev 5855)
@@ -89,7 +89,7 @@
<jstl.api.version>1.2</jstl.api.version>
<jta.api.version>1.1</jta.api.version>
<jms.api.version>1.1</jms.api.version>
- <uel.api.version>2.1.2-b04</uel.api.version>
+ <uel.api.version>2.2</uel.api.version>
<jsf.api.version>1.2_13</jsf.api.version>
<jaxws.api.version>2.1</jaxws.api.version>
<interceptor.api.version>1.1</interceptor.api.version>
14 years, 10 months
Weld SVN: r5854 - in core/trunk: tests/src/test/java/org/jboss/weld/tests and 3 other directories.
by weld-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2010-02-16 16:55:26 -0500 (Tue, 16 Feb 2010)
New Revision: 5854
Added:
core/trunk/tests/src/test/java/org/jboss/weld/tests/alternatives/
core/trunk/tests/src/test/java/org/jboss/weld/tests/alternatives/Alternatives2Test.java
core/trunk/tests/src/test/java/org/jboss/weld/tests/alternatives/AlternativesTest.java
core/trunk/tests/src/test/java/org/jboss/weld/tests/alternatives/Consumer.java
core/trunk/tests/src/test/java/org/jboss/weld/tests/alternatives/Foo.java
core/trunk/tests/src/test/java/org/jboss/weld/tests/alternatives/Producer.java
core/trunk/tests/src/test/java/org/jboss/weld/tests/alternatives/Test.java
core/trunk/tests/src/test/resources/org/jboss/weld/tests/alternatives/
core/trunk/tests/src/test/resources/org/jboss/weld/tests/alternatives/beans.xml
Modified:
core/trunk/impl/src/main/java/org/jboss/weld/bean/ProducerField.java
core/trunk/impl/src/main/java/org/jboss/weld/bean/ProducerMethod.java
Log:
WELD-429
Modified: core/trunk/impl/src/main/java/org/jboss/weld/bean/ProducerField.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bean/ProducerField.java 2010-02-16 21:20:00 UTC (rev 5853)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bean/ProducerField.java 2010-02-16 21:55:26 UTC (rev 5854)
@@ -16,9 +16,7 @@
*/
package org.jboss.weld.bean;
-import java.lang.annotation.Annotation;
import java.lang.reflect.Field;
-import java.util.Collections;
import java.util.Set;
import javax.enterprise.context.spi.CreationalContext;
@@ -170,10 +168,4 @@
return false;
}
- @Override
- public Set<Class<? extends Annotation>> getStereotypes()
- {
- return Collections.emptySet();
- }
-
}
Modified: core/trunk/impl/src/main/java/org/jboss/weld/bean/ProducerMethod.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bean/ProducerMethod.java 2010-02-16 21:20:00 UTC (rev 5853)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bean/ProducerMethod.java 2010-02-16 21:55:26 UTC (rev 5854)
@@ -21,10 +21,8 @@
import static org.jboss.weld.logging.messages.BeanMessage.MULTIPLE_DISPOSAL_METHODS;
import static org.jboss.weld.logging.messages.BeanMessage.PRODUCER_METHOD_NOT_SPECIALIZING;
-import java.lang.annotation.Annotation;
import java.lang.reflect.Method;
import java.lang.reflect.Type;
-import java.util.Collections;
import java.util.Set;
import javax.enterprise.context.spi.CreationalContext;
@@ -298,10 +296,4 @@
return id;
}
- @Override
- public Set<Class<? extends Annotation>> getStereotypes()
- {
- return Collections.emptySet();
- }
-
}
Added: core/trunk/tests/src/test/java/org/jboss/weld/tests/alternatives/Alternatives2Test.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/alternatives/Alternatives2Test.java (rev 0)
+++ core/trunk/tests/src/test/java/org/jboss/weld/tests/alternatives/Alternatives2Test.java 2010-02-16 21:55:26 UTC (rev 5854)
@@ -0,0 +1,33 @@
+/*
+ * 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.weld.tests.alternatives;
+
+import org.jboss.testharness.impl.packaging.Artifact;
+import org.jboss.weld.test.AbstractWeldTest;
+import org.testng.annotations.Test;
+
+@Artifact
+public class Alternatives2Test extends AbstractWeldTest
+{
+
+ @Test
+ public void testAlternativesOnProducers()
+ {
+ assert getReference(Consumer.class).getFoo().getName().equals("Normal");
+ }
+
+}
Property changes on: core/trunk/tests/src/test/java/org/jboss/weld/tests/alternatives/Alternatives2Test.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Added: core/trunk/tests/src/test/java/org/jboss/weld/tests/alternatives/AlternativesTest.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/alternatives/AlternativesTest.java (rev 0)
+++ core/trunk/tests/src/test/java/org/jboss/weld/tests/alternatives/AlternativesTest.java 2010-02-16 21:55:26 UTC (rev 5854)
@@ -0,0 +1,35 @@
+/*
+ * 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.weld.tests.alternatives;
+
+import org.jboss.testharness.impl.packaging.Artifact;
+import org.jboss.testharness.impl.packaging.jsr299.BeansXml;
+import org.jboss.weld.test.AbstractWeldTest;
+import org.testng.annotations.Test;
+
+@Artifact
+@BeansXml("beans.xml")
+public class AlternativesTest extends AbstractWeldTest
+{
+
+ @Test
+ public void testAlternativesOnProducers()
+ {
+ assert getReference(Consumer.class).getFoo().getName().equals("Test");
+ }
+
+}
Property changes on: core/trunk/tests/src/test/java/org/jboss/weld/tests/alternatives/AlternativesTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Added: core/trunk/tests/src/test/java/org/jboss/weld/tests/alternatives/Consumer.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/alternatives/Consumer.java (rev 0)
+++ core/trunk/tests/src/test/java/org/jboss/weld/tests/alternatives/Consumer.java 2010-02-16 21:55:26 UTC (rev 5854)
@@ -0,0 +1,15 @@
+package org.jboss.weld.tests.alternatives;
+
+import javax.inject.Inject;
+
+public class Consumer
+{
+
+ @Inject Foo foo;
+
+ public Foo getFoo()
+ {
+ return foo;
+ }
+
+}
Property changes on: core/trunk/tests/src/test/java/org/jboss/weld/tests/alternatives/Consumer.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Added: core/trunk/tests/src/test/java/org/jboss/weld/tests/alternatives/Foo.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/alternatives/Foo.java (rev 0)
+++ core/trunk/tests/src/test/java/org/jboss/weld/tests/alternatives/Foo.java 2010-02-16 21:55:26 UTC (rev 5854)
@@ -0,0 +1,18 @@
+package org.jboss.weld.tests.alternatives;
+
+public class Foo
+{
+
+ private final String name;
+
+ public Foo(String name)
+ {
+ this.name = name;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+}
Property changes on: core/trunk/tests/src/test/java/org/jboss/weld/tests/alternatives/Foo.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Added: core/trunk/tests/src/test/java/org/jboss/weld/tests/alternatives/Producer.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/alternatives/Producer.java (rev 0)
+++ core/trunk/tests/src/test/java/org/jboss/weld/tests/alternatives/Producer.java 2010-02-16 21:55:26 UTC (rev 5854)
@@ -0,0 +1,20 @@
+package org.jboss.weld.tests.alternatives;
+
+import javax.enterprise.inject.Produces;
+
+public class Producer
+{
+
+ @Produces @Test
+ public Foo getFoo()
+ {
+ return new Foo("Test");
+ }
+
+ @Produces
+ public Foo getManager()
+ {
+ return new Foo("Normal");
+ }
+
+}
Property changes on: core/trunk/tests/src/test/java/org/jboss/weld/tests/alternatives/Producer.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Added: core/trunk/tests/src/test/java/org/jboss/weld/tests/alternatives/Test.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/alternatives/Test.java (rev 0)
+++ core/trunk/tests/src/test/java/org/jboss/weld/tests/alternatives/Test.java 2010-02-16 21:55:26 UTC (rev 5854)
@@ -0,0 +1,15 @@
+package org.jboss.weld.tests.alternatives;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+import javax.enterprise.inject.Alternative;
+import javax.enterprise.inject.Stereotype;
+
+@Stereotype
+@Alternative
+(a)Retention(RetentionPolicy.RUNTIME)
+(a)Target({ElementType.TYPE, ElementType.METHOD, ElementType.FIELD})
+public @interface Test {}
\ No newline at end of file
Property changes on: core/trunk/tests/src/test/java/org/jboss/weld/tests/alternatives/Test.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Added: core/trunk/tests/src/test/resources/org/jboss/weld/tests/alternatives/beans.xml
===================================================================
--- core/trunk/tests/src/test/resources/org/jboss/weld/tests/alternatives/beans.xml (rev 0)
+++ core/trunk/tests/src/test/resources/org/jboss/weld/tests/alternatives/beans.xml 2010-02-16 21:55:26 UTC (rev 5854)
@@ -0,0 +1,6 @@
+<beans xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/beans_1_0.xsd">
+ <alternatives>
+ <stereotype>org.jboss.weld.tests.alternatives.Test</stereotype>
+ </alternatives>
+</beans>
\ No newline at end of file
Property changes on: core/trunk/tests/src/test/resources/org/jboss/weld/tests/alternatives/beans.xml
___________________________________________________________________
Name: svn:mime-type
+ text/plain
14 years, 10 months
Weld SVN: r5853 - in core/trunk: impl/src/main/java/org/jboss/weld/resolution and 1 other directories.
by weld-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2010-02-16 16:20:00 -0500 (Tue, 16 Feb 2010)
New Revision: 5853
Added:
core/trunk/impl/src/main/java/org/jboss/weld/literal/NamedLiteral.java
Modified:
core/trunk/impl/src/main/java/org/jboss/weld/resolution/ResolvableBuilder.java
core/trunk/tests/src/test/java/org/jboss/weld/tests/resolution/named/NamedBeanConsumer.java
core/trunk/tests/src/test/java/org/jboss/weld/tests/resolution/named/NamedBeanTest.java
Log:
WELD-435
Added: core/trunk/impl/src/main/java/org/jboss/weld/literal/NamedLiteral.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/literal/NamedLiteral.java (rev 0)
+++ core/trunk/impl/src/main/java/org/jboss/weld/literal/NamedLiteral.java 2010-02-16 21:20:00 UTC (rev 5853)
@@ -0,0 +1,42 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, 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.weld.literal;
+
+import javax.enterprise.util.AnnotationLiteral;
+import javax.inject.Named;
+
+/**
+ * Annotation literal for @Current
+ *
+ * @author Pete Muir
+ */
+public class NamedLiteral extends AnnotationLiteral<Named> implements Named
+{
+
+ private final String value;
+
+ public String value()
+ {
+ return value;
+ }
+
+ public NamedLiteral(String value)
+ {
+ this.value = value;
+ }
+
+}
Property changes on: core/trunk/impl/src/main/java/org/jboss/weld/literal/NamedLiteral.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Modified: core/trunk/impl/src/main/java/org/jboss/weld/resolution/ResolvableBuilder.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/resolution/ResolvableBuilder.java 2010-02-16 21:08:57 UTC (rev 5852)
+++ core/trunk/impl/src/main/java/org/jboss/weld/resolution/ResolvableBuilder.java 2010-02-16 21:20:00 UTC (rev 5853)
@@ -21,6 +21,7 @@
import static org.jboss.weld.logging.messages.ResolutionMessage.CANNOT_EXTRACT_RAW_TYPE;
import java.lang.annotation.Annotation;
+import java.lang.reflect.Field;
import java.lang.reflect.Type;
import java.util.Arrays;
import java.util.Collections;
@@ -34,12 +35,14 @@
import javax.enterprise.inject.New;
import javax.enterprise.inject.spi.Bean;
import javax.enterprise.inject.spi.InjectionPoint;
+import javax.inject.Named;
import javax.inject.Provider;
import org.jboss.weld.Container;
import org.jboss.weld.exceptions.ForbiddenArgumentException;
import org.jboss.weld.literal.AnyLiteral;
import org.jboss.weld.literal.DefaultLiteral;
+import org.jboss.weld.literal.NamedLiteral;
import org.jboss.weld.literal.NewLiteral;
import org.jboss.weld.metadata.cache.MetaAnnotationStore;
import org.jboss.weld.util.reflection.Reflections;
@@ -78,6 +81,18 @@
{
this(injectionPoint.getType());
addQualifiers(injectionPoint.getQualifiers());
+ if (mappedQualifiers.containsKey(Named.class) && injectionPoint.getMember() instanceof Field)
+ {
+ Named named = (Named) mappedQualifiers.get(Named.class);
+ if (named.value().equals(""))
+ {
+ qualifiers.remove(named);
+ // This is field injection point with an @Named qualifier, with no value specified, we need to assume the name of the field is the value
+ named = new NamedLiteral(injectionPoint.getMember().getName());
+ qualifiers.add(named);
+ mappedQualifiers.put(Named.class, named);
+ }
+ }
setDeclaringBean(injectionPoint.getBean());
}
Modified: core/trunk/tests/src/test/java/org/jboss/weld/tests/resolution/named/NamedBeanConsumer.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/resolution/named/NamedBeanConsumer.java 2010-02-16 21:08:57 UTC (rev 5852)
+++ core/trunk/tests/src/test/java/org/jboss/weld/tests/resolution/named/NamedBeanConsumer.java 2010-02-16 21:20:00 UTC (rev 5853)
@@ -1,10 +1,13 @@
package org.jboss.weld.tests.resolution.named;
+import javax.inject.Inject;
+import javax.inject.Named;
+
public class NamedBeanConsumer
{
- /*@Inject @Named*/ FooBean foo;
+ @Inject @Named FooBean foo;
public FooBean getFoo()
{
Modified: core/trunk/tests/src/test/java/org/jboss/weld/tests/resolution/named/NamedBeanTest.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/resolution/named/NamedBeanTest.java 2010-02-16 21:08:57 UTC (rev 5852)
+++ core/trunk/tests/src/test/java/org/jboss/weld/tests/resolution/named/NamedBeanTest.java 2010-02-16 21:20:00 UTC (rev 5853)
@@ -36,7 +36,7 @@
assert instance != null;
}
- @Test(description = "WELD-435", groups = "broken")
+ @Test(description = "WELD-435")
public void testNamedInjectedFieldUsesFieldName()
{
assert getReference(NamedBeanConsumer.class).getFoo() != null;
14 years, 10 months
Weld SVN: r5852 - in core/trunk/impl/src/main/java/org/jboss/weld: manager and 1 other directories.
by weld-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2010-02-16 16:08:57 -0500 (Tue, 16 Feb 2010)
New Revision: 5852
Removed:
core/trunk/impl/src/main/java/org/jboss/weld/bean/builtin/FacadeBeanResolvableTransformer.java
core/trunk/impl/src/main/java/org/jboss/weld/resolution/NewResolvableTransformer.java
core/trunk/impl/src/main/java/org/jboss/weld/resolution/ResolvableTransformer.java
Modified:
core/trunk/impl/src/main/java/org/jboss/weld/bean/builtin/InstanceImpl.java
core/trunk/impl/src/main/java/org/jboss/weld/manager/BeanManagerImpl.java
core/trunk/impl/src/main/java/org/jboss/weld/resolution/InterceptorResolvableBuilder.java
core/trunk/impl/src/main/java/org/jboss/weld/resolution/ResolvableBuilder.java
core/trunk/impl/src/main/java/org/jboss/weld/resolution/TypeSafeBeanResolver.java
core/trunk/impl/src/main/java/org/jboss/weld/resolution/TypeSafeDisposerResolver.java
core/trunk/impl/src/main/java/org/jboss/weld/resolution/TypeSafeInterceptorResolver.java
core/trunk/impl/src/main/java/org/jboss/weld/resolution/TypeSafeObserverResolver.java
core/trunk/impl/src/main/java/org/jboss/weld/resolution/TypeSafeResolver.java
Log:
Simplify resolution a bit
Deleted: core/trunk/impl/src/main/java/org/jboss/weld/bean/builtin/FacadeBeanResolvableTransformer.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bean/builtin/FacadeBeanResolvableTransformer.java 2010-02-16 19:13:20 UTC (rev 5851)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bean/builtin/FacadeBeanResolvableTransformer.java 2010-02-16 21:08:57 UTC (rev 5852)
@@ -1,95 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, 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.weld.bean.builtin;
-
-import java.lang.annotation.Annotation;
-import java.lang.reflect.Type;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Set;
-
-import javax.enterprise.inject.Any;
-
-import org.jboss.weld.literal.AnyLiteral;
-import org.jboss.weld.resolution.ForwardingResolvable;
-import org.jboss.weld.resolution.Resolvable;
-import org.jboss.weld.resolution.ResolvableTransformer;
-
-/**
- * AnnotatedItem transformer which can be used for FacadeBeans
- *
- * @author Pete Muir
- *
- */
-public class FacadeBeanResolvableTransformer implements ResolvableTransformer
-{
-
- private static final Set<Annotation> DEFAULT_QUALIFIERS = Collections.<Annotation>singleton( AnyLiteral.INSTANCE );
-
- private final Class<?> clazz;
- private final HashSet<Type> types;
-
- public FacadeBeanResolvableTransformer(Class<?> clazz)
- {
- this.clazz = clazz;
- this.types = new HashSet<Type>();
- types.add(clazz);
- }
-
- public Resolvable transform(final Resolvable resolvable)
- {
- if (resolvable.isAssignableTo(clazz))
- {
- return new ForwardingResolvable()
- {
-
- @Override
- protected Resolvable delegate()
- {
- return resolvable;
- }
-
- @Override
- public Set<Annotation> getQualifiers()
- {
- return Collections.unmodifiableSet(DEFAULT_QUALIFIERS);
- }
-
- @Override
- public Set<Type> getTypes()
- {
- return Collections.unmodifiableSet(types);
- }
-
- @Override
- public boolean isAssignableTo(Class<?> c)
- {
- return c.isAssignableFrom(clazz);
- }
-
- @Override
- public boolean isAnnotationPresent(Class<? extends Annotation> annotationType)
- {
- return Any.class.equals(annotationType);
- }
-
- };
- }
- return resolvable;
- }
-
-}
Modified: core/trunk/impl/src/main/java/org/jboss/weld/bean/builtin/InstanceImpl.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bean/builtin/InstanceImpl.java 2010-02-16 19:13:20 UTC (rev 5851)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bean/builtin/InstanceImpl.java 2010-02-16 21:08:57 UTC (rev 5852)
@@ -66,7 +66,7 @@
public T get()
{
- Bean<?> bean = getBeanManager().getBean(new ResolvableBuilder().setType(getType()).addQualifiers(getQualifiers()).setDeclaringBean(getInjectionPoint().getBean()).create());
+ Bean<?> bean = getBeanManager().getBean(new ResolvableBuilder(getType()).addQualifiers(getQualifiers()).setDeclaringBean(getInjectionPoint().getBean()).create());
// Push in an empty CC to ensure that we don't get the CC of whatever is injecting the bean containing the Instance injection point
try
{
Modified: core/trunk/impl/src/main/java/org/jboss/weld/manager/BeanManagerImpl.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/manager/BeanManagerImpl.java 2010-02-16 19:13:20 UTC (rev 5851)
+++ core/trunk/impl/src/main/java/org/jboss/weld/manager/BeanManagerImpl.java 2010-02-16 21:08:57 UTC (rev 5852)
@@ -543,7 +543,7 @@
public Set<Bean<?>> getBeans(Type beanType, Annotation... qualifiers)
{
- return beanResolver.resolve(new ResolvableBuilder().setType(beanType).addQualifiers(qualifiers).create());
+ return beanResolver.resolve(new ResolvableBuilder(beanType).addQualifiers(qualifiers).create());
}
public Set<Bean<?>> getBeans(InjectionPoint injectionPoint)
@@ -555,7 +555,7 @@
{
Container.instance().services().get(CurrentInjectionPoint.class).push(injectionPoint);
}
- return beanResolver.resolve(new ResolvableBuilder().setInjectionPoint(injectionPoint).create());
+ return beanResolver.resolve(new ResolvableBuilder(injectionPoint).create());
}
finally
{
@@ -798,7 +798,7 @@
{
if (!injectionPoint.isDelegate())
{
- Bean<?> resolvedBean = getBean(new ResolvableBuilder().setInjectionPoint(injectionPoint).create());
+ Bean<?> resolvedBean = getBean(new ResolvableBuilder(injectionPoint).create());
return getReference(injectionPoint, resolvedBean, creationalContext);
}
else
@@ -863,7 +863,7 @@
*/
public List<Interceptor<?>> resolveInterceptors(InterceptionType type, Annotation... interceptorBindings)
{
- return new ArrayList<Interceptor<?>>(interceptorResolver.resolve(new InterceptorResolvableBuilder().setInterceptionType(type).setType(Object.class).addQualifiers(interceptorBindings).create()));
+ return new ArrayList<Interceptor<?>>(interceptorResolver.resolve(new InterceptorResolvableBuilder(Object.class).setInterceptionType(type).addQualifiers(interceptorBindings).create()));
}
/**
Modified: core/trunk/impl/src/main/java/org/jboss/weld/resolution/InterceptorResolvableBuilder.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/resolution/InterceptorResolvableBuilder.java 2010-02-16 19:13:20 UTC (rev 5851)
+++ core/trunk/impl/src/main/java/org/jboss/weld/resolution/InterceptorResolvableBuilder.java 2010-02-16 21:08:57 UTC (rev 5852)
@@ -11,7 +11,6 @@
import java.util.Set;
import javax.enterprise.inject.spi.Bean;
-import javax.enterprise.inject.spi.InjectionPoint;
import javax.enterprise.inject.spi.InterceptionType;
import org.jboss.weld.Container;
@@ -21,6 +20,16 @@
public class InterceptorResolvableBuilder extends ResolvableBuilder
{
+ public InterceptorResolvableBuilder()
+ {
+ super();
+ }
+
+ public InterceptorResolvableBuilder(Type type)
+ {
+ super(type);
+ }
+
private InterceptionType interceptionType;
@Override
@@ -85,20 +94,6 @@
}
@Override
- public InterceptorResolvableBuilder setInjectionPoint(InjectionPoint injectionPoint)
- {
- super.setInjectionPoint(injectionPoint);
- return this;
- }
-
- @Override
- public InterceptorResolvableBuilder setType(Type type)
- {
- super.setType(type);
- return this;
- }
-
- @Override
public InterceptorResolvable create()
{
if (qualifiers.size() == 0)
Deleted: core/trunk/impl/src/main/java/org/jboss/weld/resolution/NewResolvableTransformer.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/resolution/NewResolvableTransformer.java 2010-02-16 19:13:20 UTC (rev 5851)
+++ core/trunk/impl/src/main/java/org/jboss/weld/resolution/NewResolvableTransformer.java 2010-02-16 21:08:57 UTC (rev 5852)
@@ -1,117 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, 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.weld.resolution;
-
-import java.lang.annotation.Annotation;
-import java.lang.reflect.Type;
-import java.util.HashSet;
-import java.util.Set;
-
-import javax.enterprise.inject.New;
-
-import org.jboss.weld.literal.NewLiteral;
-import org.jboss.weld.util.reflection.HierarchyDiscovery;
-
-/**
- * @author pmuir
- *
- */
-public class NewResolvableTransformer implements ResolvableTransformer
-{
-
- public Resolvable transform(final Resolvable element)
- {
- if (element.isAnnotationPresent(New.class) && element.getJavaClass() != null)
- {
- New originalNewAnnotation = element.getAnnotation(New.class);
- if (originalNewAnnotation.value().equals(New.class))
- {
- final Set<Annotation> bindings = new HashSet<Annotation>(element.getQualifiers());
- final New newNewAnnotation = new NewLiteral()
- {
-
- @Override
- public Class<?> value()
- {
- return element.getJavaClass();
- }
-
- };
- bindings.remove(originalNewAnnotation);
- bindings.add(newNewAnnotation);
- return new ForwardingResolvable()
- {
-
- @Override
- protected Resolvable delegate()
- {
- return element;
- }
-
- @Override
- public Set<Annotation> getQualifiers()
- {
- return bindings;
- }
-
- @Override
- public <A extends Annotation> A getAnnotation(Class<A> annotationType)
- {
- if (annotationType.equals(New.class))
- {
- return annotationType.cast(newNewAnnotation);
- }
- else
- {
- return delegate().getAnnotation(annotationType);
- }
- }
-
- };
- }
- else
- {
- final Class<?> javaClass = originalNewAnnotation.value();
- final Set<Type> typeClosure = new HierarchyDiscovery(javaClass).getTypeClosure();
- return new ForwardingResolvable()
- {
-
- @Override
- protected Resolvable delegate()
- {
- return element;
- }
-
- @Override
- public Class<?> getJavaClass()
- {
- return javaClass;
- }
-
- @Override
- public Set<Type> getTypes()
- {
- return typeClosure;
- }
-
- };
- }
- }
- return element;
- }
-
-}
Modified: core/trunk/impl/src/main/java/org/jboss/weld/resolution/ResolvableBuilder.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/resolution/ResolvableBuilder.java 2010-02-16 19:13:20 UTC (rev 5851)
+++ core/trunk/impl/src/main/java/org/jboss/weld/resolution/ResolvableBuilder.java 2010-02-16 21:08:57 UTC (rev 5852)
@@ -23,17 +23,24 @@
import java.lang.annotation.Annotation;
import java.lang.reflect.Type;
import java.util.Arrays;
+import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
+import javax.enterprise.event.Event;
+import javax.enterprise.inject.Instance;
+import javax.enterprise.inject.New;
import javax.enterprise.inject.spi.Bean;
import javax.enterprise.inject.spi.InjectionPoint;
+import javax.inject.Provider;
import org.jboss.weld.Container;
import org.jboss.weld.exceptions.ForbiddenArgumentException;
+import org.jboss.weld.literal.AnyLiteral;
import org.jboss.weld.literal.DefaultLiteral;
+import org.jboss.weld.literal.NewLiteral;
import org.jboss.weld.metadata.cache.MetaAnnotationStore;
import org.jboss.weld.util.reflection.Reflections;
@@ -53,45 +60,39 @@
this.mappedQualifiers = new HashMap<Class<? extends Annotation>, Annotation>();
}
- public ResolvableBuilder setType(Type type)
+ public ResolvableBuilder(Type type)
{
- if (rawType != null)
+ this();
+ if (type != null)
{
- throw new IllegalStateException("Cannot change type once set");
+ this.rawType = Reflections.getRawType(type);
+ if (rawType == null)
+ {
+ throw new ForbiddenArgumentException(CANNOT_EXTRACT_RAW_TYPE, type);
+ }
+ this.types.add(type);
}
- if (type == null)
- {
- throw new IllegalArgumentException("type cannot be null");
- }
- this.rawType = Reflections.getRawType(type);
- if (rawType == null)
- {
- throw new ForbiddenArgumentException(CANNOT_EXTRACT_RAW_TYPE, type);
- }
- this.types.add(type);
- return this;
}
-
- public ResolvableBuilder setInjectionPoint(InjectionPoint injectionPoint)
+
+ public ResolvableBuilder(InjectionPoint injectionPoint)
{
- setType(injectionPoint.getType());
+ this(injectionPoint.getType());
addQualifiers(injectionPoint.getQualifiers());
setDeclaringBean(injectionPoint.getBean());
- return this;
}
-
+
public ResolvableBuilder setDeclaringBean(Bean<?> declaringBean)
{
this.declaringBean = declaringBean;
return this;
}
-
+
public ResolvableBuilder addType(Type type)
{
this.types.add(type);
return this;
}
-
+
public ResolvableBuilder addTypes(Set<Type> types)
{
this.types.addAll(types);
@@ -104,17 +105,64 @@
{
this.qualifiers.add(DefaultLiteral.INSTANCE);
}
+ if (Reflections.isAssignableFrom(Event.class, types))
+ {
+ return createFacade(Event.class);
+ }
+ else if (Reflections.isAssignableFrom(Instance.class, types))
+ {
+ return createFacade(Instance.class);
+ }
+ else if (Reflections.isAssignableFrom(Provider.class, types))
+ {
+ return createFacade(Provider.class);
+ }
+ else
+ {
+ return new ResolvableImpl(rawType, types, qualifiers, mappedQualifiers, declaringBean);
+ }
+ }
+
+ private Resolvable createFacade(Class<?> rawType)
+ {
+ Set<Annotation> qualifiers = Collections.<Annotation> singleton(AnyLiteral.INSTANCE);
+ Set<Type> types = Collections.<Type> singleton(rawType);
return new ResolvableImpl(rawType, types, qualifiers, mappedQualifiers, declaringBean);
}
public ResolvableBuilder addQualifier(Annotation qualifier)
{
+ // Handle the @New qualifier special case
+ if (qualifier.annotationType().equals(New.class))
+ {
+ New newQualifier = New.class.cast(qualifier);
+ if (newQualifier.value().equals(New.class) && rawType == null)
+ {
+ throw new IllegalStateException("Cannot transform @New when there is no known raw type");
+ }
+ else if (newQualifier.value().equals(New.class))
+ {
+ qualifier = new NewLiteral()
+ {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public Class<?> value()
+ {
+ return rawType;
+ }
+
+ };
+ }
+ }
+
checkQualifier(qualifier);
this.qualifiers.add(qualifier);
this.mappedQualifiers.put(qualifier.annotationType(), qualifier);
return this;
}
-
+
public ResolvableBuilder addQualifierIfAbsent(Annotation qualifier)
{
if (!qualifiers.contains(qualifier))
@@ -215,5 +263,4 @@
}
-
}
Deleted: core/trunk/impl/src/main/java/org/jboss/weld/resolution/ResolvableTransformer.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/resolution/ResolvableTransformer.java 2010-02-16 19:13:20 UTC (rev 5851)
+++ core/trunk/impl/src/main/java/org/jboss/weld/resolution/ResolvableTransformer.java 2010-02-16 21:08:57 UTC (rev 5852)
@@ -1,24 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, 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.weld.resolution;
-
-public interface ResolvableTransformer<R extends Resolvable>
-{
-
- public R transform(R element);
-
-}
Modified: core/trunk/impl/src/main/java/org/jboss/weld/resolution/TypeSafeBeanResolver.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/resolution/TypeSafeBeanResolver.java 2010-02-16 19:13:20 UTC (rev 5851)
+++ core/trunk/impl/src/main/java/org/jboss/weld/resolution/TypeSafeBeanResolver.java 2010-02-16 21:08:57 UTC (rev 5852)
@@ -26,7 +26,6 @@
import javax.enterprise.util.TypeLiteral;
import javax.inject.Provider;
-import org.jboss.weld.bean.builtin.FacadeBeanResolvableTransformer;
import org.jboss.weld.manager.BeanManagerImpl;
import org.jboss.weld.util.Beans;
import org.jboss.weld.util.reflection.Reflections;
@@ -45,7 +44,6 @@
private static final Class<Provider<?>> PROVIDER_TYPE = new TypeLiteral<Provider<?>>() {}.getRawType();
private static final Class<Event<?>> EVENT_TYPE = new TypeLiteral<Event<?>>() {}.getRawType();
- private final Set<ResolvableTransformer<Resolvable>> transformers;
private final BeanManagerImpl beanManager;
private final ConcurrentMap<Set<Bean<?>>, Set<Bean<?>>> disambiguatedBeans;
@@ -88,11 +86,6 @@
super(beans);
this.beanManager = beanManager;
this.disambiguatedBeans = new MapMaker().makeComputingMap(new BeanDisambiguation(beanManager));
- transformers = new HashSet<ResolvableTransformer<Resolvable>>();
- transformers.add(new FacadeBeanResolvableTransformer(EVENT_TYPE));
- transformers.add(new FacadeBeanResolvableTransformer(INSTANCE_TYPE));
- transformers.add(new FacadeBeanResolvableTransformer(PROVIDER_TYPE));
- transformers.add(new NewResolvableTransformer());
}
@Override
@@ -116,12 +109,6 @@
}
@Override
- protected Iterable<ResolvableTransformer<Resolvable>> getTransformers()
- {
- return transformers;
- }
-
- @Override
protected Set<T> sortResult(Set<T> matched)
{
return matched;
Modified: core/trunk/impl/src/main/java/org/jboss/weld/resolution/TypeSafeDisposerResolver.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/resolution/TypeSafeDisposerResolver.java 2010-02-16 19:13:20 UTC (rev 5851)
+++ core/trunk/impl/src/main/java/org/jboss/weld/resolution/TypeSafeDisposerResolver.java 2010-02-16 21:08:57 UTC (rev 5852)
@@ -16,7 +16,6 @@
*/
package org.jboss.weld.resolution;
-import java.util.Collections;
import java.util.Set;
import org.jboss.weld.bean.DisposalMethod;
@@ -60,12 +59,6 @@
}
@Override
- protected Iterable<ResolvableTransformer<Resolvable>> getTransformers()
- {
- return Collections.emptySet();
- }
-
- @Override
protected Set<DisposalMethod<?, ?>> sortResult(Set<DisposalMethod<?, ?>> matched)
{
return matched;
Modified: core/trunk/impl/src/main/java/org/jboss/weld/resolution/TypeSafeInterceptorResolver.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/resolution/TypeSafeInterceptorResolver.java 2010-02-16 19:13:20 UTC (rev 5851)
+++ core/trunk/impl/src/main/java/org/jboss/weld/resolution/TypeSafeInterceptorResolver.java 2010-02-16 21:08:57 UTC (rev 5852)
@@ -17,7 +17,6 @@
package org.jboss.weld.resolution;
-import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Set;
@@ -74,12 +73,6 @@
return matched;
}
- @Override
- protected Iterable<ResolvableTransformer<InterceptorResolvable>> getTransformers()
- {
- return Collections.emptySet();
- }
-
public BeanManagerImpl getManager()
{
return manager;
Modified: core/trunk/impl/src/main/java/org/jboss/weld/resolution/TypeSafeObserverResolver.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/resolution/TypeSafeObserverResolver.java 2010-02-16 19:13:20 UTC (rev 5851)
+++ core/trunk/impl/src/main/java/org/jboss/weld/resolution/TypeSafeObserverResolver.java 2010-02-16 21:08:57 UTC (rev 5852)
@@ -16,7 +16,6 @@
*/
package org.jboss.weld.resolution;
-import java.util.Collections;
import java.util.Set;
import javax.enterprise.inject.spi.ObserverMethod;
@@ -61,12 +60,6 @@
}
@Override
- protected Iterable<ResolvableTransformer<Resolvable>> getTransformers()
- {
- return Collections.emptySet();
- }
-
- @Override
protected Set<ObserverMethod<?>> sortResult(Set<ObserverMethod<?>> matched)
{
return matched;
Modified: core/trunk/impl/src/main/java/org/jboss/weld/resolution/TypeSafeResolver.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/resolution/TypeSafeResolver.java 2010-02-16 19:13:20 UTC (rev 5851)
+++ core/trunk/impl/src/main/java/org/jboss/weld/resolution/TypeSafeResolver.java 2010-02-16 21:08:57 UTC (rev 5852)
@@ -130,7 +130,7 @@
*/
public Set<T> resolve(R resolvable)
{
- return Collections.unmodifiableSet(resolved.get(new Key<R>(transform(resolvable))));
+ return Collections.unmodifiableSet(resolved.get(new Key<R>(resolvable)));
}
/**
@@ -154,17 +154,6 @@
return result;
}
- protected R transform(R resolvable)
- {
- for (ResolvableTransformer<R> transformer : getTransformers())
- {
- resolvable = transformer.transform(resolvable);
- }
- return resolvable;
- }
-
- protected abstract Iterable<ResolvableTransformer<R>> getTransformers();
-
protected abstract Set<T> filterResult(Set<T> matched);
protected abstract Set<T> sortResult(Set<T> matched);
14 years, 10 months
Weld SVN: r5851 - in core/trunk/impl/src/main/java/org/jboss/weld: bean/builtin and 5 other directories.
by weld-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2010-02-16 14:13:20 -0500 (Tue, 16 Feb 2010)
New Revision: 5851
Added:
core/trunk/impl/src/main/java/org/jboss/weld/resolution/InterceptorResolvableBuilder.java
core/trunk/impl/src/main/java/org/jboss/weld/resolution/ResolvableBuilder.java
Removed:
core/trunk/impl/src/main/java/org/jboss/weld/resolution/ResolvableFactory.java
core/trunk/impl/src/main/java/org/jboss/weld/resolution/ResolvableWeldClass.java
Modified:
core/trunk/impl/src/main/java/org/jboss/weld/bean/AbstractBean.java
core/trunk/impl/src/main/java/org/jboss/weld/bean/builtin/FacadeBeanResolvableTransformer.java
core/trunk/impl/src/main/java/org/jboss/weld/bean/builtin/InstanceImpl.java
core/trunk/impl/src/main/java/org/jboss/weld/bootstrap/BeanDeployerEnvironment.java
core/trunk/impl/src/main/java/org/jboss/weld/bootstrap/Validator.java
core/trunk/impl/src/main/java/org/jboss/weld/manager/BeanManagerImpl.java
core/trunk/impl/src/main/java/org/jboss/weld/resolution/ForwardingInterceptorResolvable.java
core/trunk/impl/src/main/java/org/jboss/weld/resolution/ForwardingResolvable.java
core/trunk/impl/src/main/java/org/jboss/weld/resolution/NewResolvableTransformer.java
core/trunk/impl/src/main/java/org/jboss/weld/resolution/Resolvable.java
core/trunk/impl/src/main/java/org/jboss/weld/resolution/TypeSafeBeanResolver.java
core/trunk/impl/src/main/java/org/jboss/weld/resolution/TypeSafeDecoratorResolver.java
core/trunk/impl/src/main/java/org/jboss/weld/resolution/TypeSafeDisposerResolver.java
core/trunk/impl/src/main/java/org/jboss/weld/resolution/TypeSafeObserverResolver.java
core/trunk/impl/src/main/java/org/jboss/weld/resolution/TypeSafeResolver.java
core/trunk/impl/src/main/java/org/jboss/weld/util/collections/Arrays2.java
core/trunk/impl/src/main/java/org/jboss/weld/util/reflection/Reflections.java
Log:
Streamline classes used in resolution
Modified: core/trunk/impl/src/main/java/org/jboss/weld/bean/AbstractBean.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bean/AbstractBean.java 2010-02-16 19:12:06 UTC (rev 5850)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bean/AbstractBean.java 2010-02-16 19:13:20 UTC (rev 5851)
@@ -385,7 +385,7 @@
*
* @return The set of API types
*
- * @see org.jboss.weld.bean.BaseBean#getTypeClosure()
+ * @see org.jboss.weld.bean.BaseBean#getTypes()
*/
public Set<Type> getTypes()
{
Modified: core/trunk/impl/src/main/java/org/jboss/weld/bean/builtin/FacadeBeanResolvableTransformer.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bean/builtin/FacadeBeanResolvableTransformer.java 2010-02-16 19:12:06 UTC (rev 5850)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bean/builtin/FacadeBeanResolvableTransformer.java 2010-02-16 19:13:20 UTC (rev 5851)
@@ -70,7 +70,7 @@
}
@Override
- public Set<Type> getTypeClosure()
+ public Set<Type> getTypes()
{
return Collections.unmodifiableSet(types);
}
Modified: core/trunk/impl/src/main/java/org/jboss/weld/bean/builtin/InstanceImpl.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bean/builtin/InstanceImpl.java 2010-02-16 19:12:06 UTC (rev 5850)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bean/builtin/InstanceImpl.java 2010-02-16 19:13:20 UTC (rev 5851)
@@ -38,7 +38,7 @@
import org.jboss.weld.exceptions.InvalidObjectException;
import org.jboss.weld.injection.CurrentInjectionPoint;
import org.jboss.weld.manager.BeanManagerImpl;
-import org.jboss.weld.resolution.ResolvableWeldClass;
+import org.jboss.weld.resolution.ResolvableBuilder;
import org.jboss.weld.util.Beans;
import org.jboss.weld.util.Names;
@@ -65,8 +65,8 @@
}
public T get()
- {
- Bean<?> bean = getBeanManager().getBean(ResolvableWeldClass.of(getType(), getQualifiers(), getBeanManager()), getQualifiers());
+ {
+ Bean<?> bean = getBeanManager().getBean(new ResolvableBuilder().setType(getType()).addQualifiers(getQualifiers()).setDeclaringBean(getInjectionPoint().getBean()).create());
// Push in an empty CC to ensure that we don't get the CC of whatever is injecting the bean containing the Instance injection point
try
{
Modified: core/trunk/impl/src/main/java/org/jboss/weld/bootstrap/BeanDeployerEnvironment.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bootstrap/BeanDeployerEnvironment.java 2010-02-16 19:12:06 UTC (rev 5850)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bootstrap/BeanDeployerEnvironment.java 2010-02-16 19:13:20 UTC (rev 5851)
@@ -50,7 +50,7 @@
import org.jboss.weld.introspector.WeldClass;
import org.jboss.weld.introspector.WeldMethod;
import org.jboss.weld.manager.BeanManagerImpl;
-import org.jboss.weld.resolution.ResolvableFactory;
+import org.jboss.weld.resolution.ResolvableBuilder;
import org.jboss.weld.resolution.TypeSafeDisposerResolver;
import org.jboss.weld.resources.ClassTransformer;
import org.jboss.weld.util.AnnotatedTypes;
@@ -282,12 +282,12 @@
* disposal methods are used. For internal use.
*
* @param apiType The API type to match
- * @param bindings The binding types to match
+ * @param qualifiers The binding types to match
* @return The set of matching disposal methods
*/
- public <X> Set<DisposalMethod<X, ?>> resolveDisposalBeans(Set<Type> types, Set<Annotation> bindings, AbstractClassBean<X> declaringBean)
+ public <X> Set<DisposalMethod<X, ?>> resolveDisposalBeans(Set<Type> types, Set<Annotation> qualifiers, AbstractClassBean<X> declaringBean)
{
- Set<DisposalMethod<X, ?>> beans = (Set) disposalMethodResolver.resolve(ResolvableFactory.of(types, bindings, declaringBean));
+ Set<DisposalMethod<X, ?>> beans = (Set) disposalMethodResolver.resolve(new ResolvableBuilder().addTypes(types).addQualifiers(qualifiers).setDeclaringBean(declaringBean).create());
resolvedDisposalBeans.addAll(beans);
return Collections.unmodifiableSet(beans);
}
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-16 19:12:06 UTC (rev 5850)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bootstrap/Validator.java 2010-02-16 19:13:20 UTC (rev 5851)
@@ -84,10 +84,8 @@
import org.jboss.weld.exceptions.NullableDependencyException;
import org.jboss.weld.exceptions.UnproxyableResolutionException;
import org.jboss.weld.exceptions.UnserializableDependencyException;
-import org.jboss.weld.introspector.WeldAnnotated;
import org.jboss.weld.manager.BeanManagerImpl;
import org.jboss.weld.metadata.cache.MetaAnnotationStore;
-import org.jboss.weld.resolution.ResolvableWeldClass;
import org.jboss.weld.serialization.spi.helpers.SerializableContextual;
import org.jboss.weld.util.Beans;
import org.jboss.weld.util.Proxies;
@@ -180,7 +178,7 @@
InjectionTarget<Object> injectionTarget = (InjectionTarget<Object>) beanManager.createInjectionTarget(beanManager.createAnnotatedType(interceptorClass));
for (InjectionPoint injectionPoint : injectionTarget.getInjectionPoints())
{
- Bean<?> resolvedBean = beanManager.resolve(beanManager.getInjectableBeans(injectionPoint));
+ Bean<?> resolvedBean = beanManager.resolve(beanManager.getBeans(injectionPoint));
validateInjectionPointPassivationCapable(injectionPoint, resolvedBean, beanManager);
}
}
@@ -204,7 +202,7 @@
}
for (InjectionPoint injectionPoint : serializableContextual.get().getInjectionPoints())
{
- Bean<?> resolvedBean = beanManager.resolve(beanManager.getInjectableBeans(injectionPoint));
+ Bean<?> resolvedBean = beanManager.resolve(beanManager.getBeans(injectionPoint));
validateInjectionPointPassivationCapable(injectionPoint, resolvedBean, beanManager);
}
}
@@ -222,7 +220,7 @@
}
for (InjectionPoint ij : decorator.getInjectionPoints())
{
- Bean<?> resolvedBean = beanManager.resolve(beanManager.getInjectableBeans(ij));
+ Bean<?> resolvedBean = beanManager.resolve(beanManager.getBeans(ij));
validateInjectionPointPassivationCapable(ij, resolvedBean, beanManager);
}
}
@@ -257,8 +255,7 @@
checkFacadeInjectionPoint(ij, Instance.class);
checkFacadeInjectionPoint(ij, Event.class);
Annotation[] bindings = ij.getQualifiers().toArray(new Annotation[0]);
- WeldAnnotated<?, ?> annotatedItem = ResolvableWeldClass.of(ij.getType(), bindings, beanManager);
- Set<?> resolvedBeans = beanManager.getBeanResolver().resolve(beanManager.getInjectableBeans(ij));
+ Set<?> resolvedBeans = beanManager.getBeanResolver().resolve(beanManager.getBeans(ij));
if (!isInjectionPointSatisfied(ij, resolvedBeans, beanManager))
{
throw new DeploymentException(INJECTION_POINT_HAS_UNSATISFIED_DEPENDENCIES, ij, Arrays.toString(bindings));
@@ -275,7 +272,7 @@
{
throw new UnproxyableResolutionException(INJECTION_POINT_HAS_NON_PROXYABLE_DEPENDENCIES, ij);
}
- if (annotatedItem.isPrimitive() && resolvedBean.isNullable())
+ if (Reflections.isPrimitive(ij.getType()) && resolvedBean.isNullable())
{
throw new NullableDependencyException(INJECTION_POINT_HAS_NULLABLE_DEPENDENCIES, ij);
}
Modified: core/trunk/impl/src/main/java/org/jboss/weld/manager/BeanManagerImpl.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/manager/BeanManagerImpl.java 2010-02-16 19:12:06 UTC (rev 5850)
+++ core/trunk/impl/src/main/java/org/jboss/weld/manager/BeanManagerImpl.java 2010-02-16 19:13:20 UTC (rev 5851)
@@ -19,11 +19,6 @@
import static org.jboss.weld.logging.messages.BeanManagerMessage.AMBIGUOUS_BEANS_FOR_DEPENDENCY;
import static org.jboss.weld.logging.messages.BeanManagerMessage.CONTEXT_NOT_ACTIVE;
import static org.jboss.weld.logging.messages.BeanManagerMessage.DUPLICATE_ACTIVE_CONTEXTS;
-import static org.jboss.weld.logging.messages.BeanManagerMessage.DUPLICATE_INTERCEPTOR_BINDING;
-import static org.jboss.weld.logging.messages.BeanManagerMessage.DUPLICATE_QUALIFIERS;
-import static org.jboss.weld.logging.messages.BeanManagerMessage.INTERCEPTOR_BINDINGS_EMPTY;
-import static org.jboss.weld.logging.messages.BeanManagerMessage.INTERCEPTOR_RESOLUTION_WITH_NONBINDING_TYPE;
-import static org.jboss.weld.logging.messages.BeanManagerMessage.INVALID_QUALIFIER;
import static org.jboss.weld.logging.messages.BeanManagerMessage.NON_NORMAL_SCOPE;
import static org.jboss.weld.logging.messages.BeanManagerMessage.NOT_INTERCEPTOR_BINDING_TYPE;
import static org.jboss.weld.logging.messages.BeanManagerMessage.NOT_PROXYABLE;
@@ -38,7 +33,6 @@
import java.lang.annotation.Annotation;
import java.lang.reflect.Type;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
@@ -66,7 +60,6 @@
import javax.enterprise.inject.spi.Interceptor;
import javax.enterprise.inject.spi.ObserverMethod;
import javax.enterprise.inject.spi.PassivationCapable;
-import javax.inject.Qualifier;
import org.jboss.interceptor.registry.InterceptorRegistry;
import org.jboss.weld.Container;
@@ -96,16 +89,15 @@
import org.jboss.weld.exceptions.UnproxyableResolutionException;
import org.jboss.weld.exceptions.UnsatisfiedResolutionException;
import org.jboss.weld.injection.CurrentInjectionPoint;
-import org.jboss.weld.introspector.WeldAnnotated;
import org.jboss.weld.literal.AnyLiteral;
import org.jboss.weld.manager.api.WeldManager;
import org.jboss.weld.metadata.cache.MetaAnnotationStore;
import org.jboss.weld.metadata.cache.ScopeModel;
import org.jboss.weld.resolution.InterceptorResolvable;
+import org.jboss.weld.resolution.InterceptorResolvableBuilder;
import org.jboss.weld.resolution.NameBasedResolver;
import org.jboss.weld.resolution.Resolvable;
-import org.jboss.weld.resolution.ResolvableFactory;
-import org.jboss.weld.resolution.ResolvableWeldClass;
+import org.jboss.weld.resolution.ResolvableBuilder;
import org.jboss.weld.resolution.TypeSafeBeanResolver;
import org.jboss.weld.resolution.TypeSafeDecoratorResolver;
import org.jboss.weld.resolution.TypeSafeInterceptorResolver;
@@ -486,37 +478,11 @@
@SuppressWarnings("unchecked")
- public <T> Set<ObserverMethod<? super T>> resolveObserverMethods(Type eventType, Annotation... bindings)
+ public <T> Set<ObserverMethod<? super T>> resolveObserverMethods(Type eventType, Annotation... qualifiers)
{
- checkQualifiers(Arrays.asList(bindings));
- HashSet<Annotation> bindingAnnotations = new HashSet<Annotation>(Arrays.asList(bindings));
- bindingAnnotations.add(AnyLiteral.INSTANCE);
- Set<ObserverMethod<? super T>> observers = new HashSet<ObserverMethod<? super T>>();
- Set<ObserverMethod<?>> eventObservers = observerResolver.resolve(ResolvableFactory.of(new HierarchyDiscovery(eventType).getTypeClosure(), bindingAnnotations, null));
- for (ObserverMethod<?> observer : eventObservers)
- {
- observers.add((ObserverMethod<T>) observer);
- }
- return observers;
+ return (Set) observerResolver.resolve(new ResolvableBuilder().addTypes(new HierarchyDiscovery(eventType).getTypeClosure()).addQualifiers(qualifiers).addQualifierIfAbsent(AnyLiteral.INSTANCE).create());
}
-
- private void checkQualifiers(Collection<Annotation> bindings)
- {
- HashSet<Annotation> bindingAnnotations = new HashSet<Annotation>(bindings);
- for (Annotation annotation : bindings)
- {
- if (!getServices().get(MetaAnnotationStore.class).getBindingTypeModel(annotation.annotationType()).isValid())
- {
- throw new ForbiddenArgumentException(INVALID_QUALIFIER, annotation);
- }
- }
- if (bindingAnnotations.size() < bindings.size())
- {
- throw new ForbiddenArgumentException(DUPLICATE_QUALIFIERS, bindings);
- }
- }
-
/**
* A collection of enabled alternative classes
*
@@ -575,39 +541,12 @@
this.enabledInterceptorClasses = enabledInterceptorClasses;
}
- public Set<Bean<?>> getBeans(Type beanType, Annotation... bindings)
+ public Set<Bean<?>> getBeans(Type beanType, Annotation... qualifiers)
{
- return getBeans(ResolvableWeldClass.of(beanType, bindings, this), bindings);
+ return beanResolver.resolve(new ResolvableBuilder().setType(beanType).addQualifiers(qualifiers).create());
}
-
- public Set<Bean<?>> getBeans(WeldAnnotated<?, ?> element, Annotation... bindings)
- {
- for (Annotation annotation : element.getAnnotations())
- {
- if (!getServices().get(MetaAnnotationStore.class).getBindingTypeModel(annotation.annotationType()).isValid())
- {
- throw new ForbiddenArgumentException(INVALID_QUALIFIER, annotation);
- }
- }
-// for (Type type : element.getActualTypeArguments())
-// {
-// if (type instanceof WildcardType)
-// {
-// throw new IllegalArgumentException("Cannot resolve a type parameterized with a wildcard " + element);
-// }
-// if (type instanceof TypeVariable<?>)
-// {
-// throw new IllegalArgumentException("Cannot resolve a type parameterized with a type parameter " + element);
-// }
-// }
- if (bindings != null && bindings.length > element.getMetaAnnotations(Qualifier.class).size())
- {
- throw new ForbiddenArgumentException(DUPLICATE_QUALIFIERS, Arrays.asList(bindings));
- }
- return beanResolver.resolve(ResolvableFactory.of(element));
- }
- public Set<Bean<?>> getInjectableBeans(InjectionPoint injectionPoint)
+ public Set<Bean<?>> getBeans(InjectionPoint injectionPoint)
{
boolean registerInjectionPoint = !injectionPoint.getType().equals(InjectionPoint.class);
try
@@ -616,17 +555,7 @@
{
Container.instance().services().get(CurrentInjectionPoint.class).push(injectionPoint);
}
- // TODO Do this properly
- Set<Bean<?>> beans = getBeans(ResolvableWeldClass.of(injectionPoint.getType(), injectionPoint.getQualifiers().toArray(new Annotation[0]), this));
- Set<Bean<?>> injectableBeans = new HashSet<Bean<?>>();
- for (Bean<?> bean : beans)
- {
- if (!(bean instanceof Decorator<?> || bean instanceof Interceptor<?>))
- {
- injectableBeans.add(bean);
- }
- }
- return injectableBeans;
+ return beanResolver.resolve(new ResolvableBuilder().setInjectionPoint(injectionPoint).create());
}
finally
{
@@ -869,8 +798,7 @@
{
if (!injectionPoint.isDelegate())
{
- WeldAnnotated<?, ?> element = ResolvableWeldClass.of(injectionPoint.getType(), injectionPoint.getQualifiers().toArray(new Annotation[0]), this);
- Bean<?> resolvedBean = getBean(element, element.getBindingsAsArray());
+ Bean<?> resolvedBean = getBean(new ResolvableBuilder().setInjectionPoint(injectionPoint).create());
return getReference(injectionPoint, resolvedBean, creationalContext);
}
else
@@ -879,12 +807,12 @@
}
}
- public <T> Bean<T> getBean(WeldAnnotated<T, ?> element, Annotation... qualifiers)
+ public <T> Bean<T> getBean(Resolvable resolvable)
{
- Bean<T> bean = (Bean<T>) resolve(getBeans(element, qualifiers));
+ Bean<T> bean = (Bean<T>) resolve(beanResolver.resolve(resolvable));
if (bean == null)
{
- throw new UnsatisfiedResolutionException(UNRESOLVABLE_ELEMENT, element);
+ throw new UnsatisfiedResolutionException(UNRESOLVABLE_ELEMENT, resolvable);
}
boolean normalScoped = getServices().get(MetaAnnotationStore.class).getScopeModel(bean.getScope()).isNormal();
@@ -902,25 +830,24 @@
public List<Decorator<?>> resolveDecorators(Set<Type> types, Annotation... qualifiers)
{
- checkResolveDecoratorsArguments(types, Arrays.asList(qualifiers));
+ checkResolveDecoratorsArguments(types);
// TODO Fix this cast and make the resolver return a list
- return new ArrayList<Decorator<?>>(decoratorResolver.resolve(ResolvableFactory.of(types, qualifiers, null)));
+ return new ArrayList<Decorator<?>>(decoratorResolver.resolve(new ResolvableBuilder().addTypes(types).addQualifiers(qualifiers).create()));
}
public List<Decorator<?>> resolveDecorators(Set<Type> types, Set<Annotation> qualifiers)
{
- checkResolveDecoratorsArguments(types, qualifiers);
+ checkResolveDecoratorsArguments(types);
// TODO Fix this cast and make the resolver return a list
- return new ArrayList<Decorator<?>>(decoratorResolver.resolve(ResolvableFactory.of(types, qualifiers, null)));
+ return new ArrayList<Decorator<?>>(decoratorResolver.resolve(new ResolvableBuilder().addTypes(types).addQualifiers(qualifiers).create()));
}
- private void checkResolveDecoratorsArguments(Set<Type> types, Collection<Annotation> qualifiers)
+ private void checkResolveDecoratorsArguments(Set<Type> types)
{
if (types.isEmpty())
{
throw new ForbiddenArgumentException(NO_DECORATOR_TYPES);
}
- checkQualifiers(qualifiers);
}
/**
@@ -936,18 +863,7 @@
*/
public List<Interceptor<?>> resolveInterceptors(InterceptionType type, Annotation... interceptorBindings)
{
- if (interceptorBindings.length == 0)
- throw new ForbiddenArgumentException(INTERCEPTOR_BINDINGS_EMPTY);
- Set<Class<?>> uniqueInterceptorBindings = new HashSet<Class<?>>();
- for (Annotation interceptorBinding: interceptorBindings)
- {
- if (uniqueInterceptorBindings.contains(interceptorBinding.annotationType()))
- throw new ForbiddenArgumentException(DUPLICATE_INTERCEPTOR_BINDING, interceptorBinding.annotationType());
- if (!isInterceptorBinding(interceptorBinding.annotationType()))
- throw new ForbiddenArgumentException(INTERCEPTOR_RESOLUTION_WITH_NONBINDING_TYPE, interceptorBinding.annotationType());
- uniqueInterceptorBindings.add(interceptorBinding.annotationType());
- }
- return new ArrayList<Interceptor<?>>(interceptorResolver.resolve(ResolvableFactory.of(type,interceptorBindings)));
+ return new ArrayList<Interceptor<?>>(interceptorResolver.resolve(new InterceptorResolvableBuilder().setInterceptionType(type).setType(Object.class).addQualifiers(interceptorBindings).create()));
}
/**
Modified: core/trunk/impl/src/main/java/org/jboss/weld/resolution/ForwardingInterceptorResolvable.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/resolution/ForwardingInterceptorResolvable.java 2010-02-16 19:12:06 UTC (rev 5850)
+++ core/trunk/impl/src/main/java/org/jboss/weld/resolution/ForwardingInterceptorResolvable.java 2010-02-16 19:13:20 UTC (rev 5851)
@@ -57,7 +57,7 @@
return null;
}
- public Set<Type> getTypeClosure()
+ public Set<Type> getTypes()
{
// TODO Auto-generated method stub
return null;
Modified: core/trunk/impl/src/main/java/org/jboss/weld/resolution/ForwardingResolvable.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/resolution/ForwardingResolvable.java 2010-02-16 19:12:06 UTC (rev 5850)
+++ core/trunk/impl/src/main/java/org/jboss/weld/resolution/ForwardingResolvable.java 2010-02-16 19:13:20 UTC (rev 5851)
@@ -20,7 +20,7 @@
import java.lang.reflect.Type;
import java.util.Set;
-import org.jboss.weld.bean.AbstractClassBean;
+import javax.enterprise.inject.spi.Bean;
public abstract class ForwardingResolvable implements Resolvable
{
@@ -37,9 +37,9 @@
return delegate().isAnnotationPresent(annotationType);
}
- public Set<Type> getTypeClosure()
+ public Set<Type> getTypes()
{
- return delegate().getTypeClosure();
+ return delegate().getTypes();
}
public boolean isAssignableTo(Class<?> clazz)
@@ -57,7 +57,7 @@
return delegate().getJavaClass();
}
- public AbstractClassBean<?> getDeclaringBean()
+ public Bean<?> getDeclaringBean()
{
return delegate().getDeclaringBean();
}
Added: core/trunk/impl/src/main/java/org/jboss/weld/resolution/InterceptorResolvableBuilder.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/resolution/InterceptorResolvableBuilder.java (rev 0)
+++ core/trunk/impl/src/main/java/org/jboss/weld/resolution/InterceptorResolvableBuilder.java 2010-02-16 19:13:20 UTC (rev 5851)
@@ -0,0 +1,129 @@
+package org.jboss.weld.resolution;
+
+import static org.jboss.weld.logging.messages.BeanManagerMessage.DUPLICATE_INTERCEPTOR_BINDING;
+import static org.jboss.weld.logging.messages.BeanManagerMessage.INTERCEPTOR_BINDINGS_EMPTY;
+import static org.jboss.weld.logging.messages.BeanManagerMessage.INTERCEPTOR_RESOLUTION_WITH_NONBINDING_TYPE;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Type;
+import java.util.Arrays;
+import java.util.Map;
+import java.util.Set;
+
+import javax.enterprise.inject.spi.Bean;
+import javax.enterprise.inject.spi.InjectionPoint;
+import javax.enterprise.inject.spi.InterceptionType;
+
+import org.jboss.weld.Container;
+import org.jboss.weld.exceptions.ForbiddenArgumentException;
+import org.jboss.weld.metadata.cache.MetaAnnotationStore;
+
+public class InterceptorResolvableBuilder extends ResolvableBuilder
+{
+
+ private InterceptionType interceptionType;
+
+ @Override
+ protected void checkQualifier(Annotation qualifier)
+ {
+ if (!Container.instance().services().get(MetaAnnotationStore.class).getInterceptorBindingModel(qualifier.annotationType()).isValid())
+ {
+ throw new ForbiddenArgumentException(INTERCEPTOR_RESOLUTION_WITH_NONBINDING_TYPE, qualifier);
+ }
+ if (qualifiers.contains(qualifier))
+ {
+ throw new ForbiddenArgumentException(DUPLICATE_INTERCEPTOR_BINDING, Arrays.asList(qualifiers));
+ }
+ }
+
+ public InterceptorResolvableBuilder setInterceptionType(InterceptionType interceptionType)
+ {
+ this.interceptionType = interceptionType;
+ return this;
+ }
+
+ @Override
+ public InterceptorResolvableBuilder addQualifier(Annotation qualifier)
+ {
+ super.addQualifier(qualifier);
+ return this;
+ }
+
+ @Override
+ public InterceptorResolvableBuilder addQualifiers(Annotation[] qualifiers)
+ {
+ super.addQualifiers(qualifiers);
+ return this;
+ }
+
+ @Override
+ public InterceptorResolvableBuilder addQualifiers(Set<Annotation> qualifiers)
+ {
+ super.addQualifiers(qualifiers);
+ return this;
+ }
+
+ @Override
+ public InterceptorResolvableBuilder addType(Type type)
+ {
+ super.addType(type);
+ return this;
+ }
+
+ @Override
+ public InterceptorResolvableBuilder addTypes(Set<Type> types)
+ {
+ super.addTypes(types);
+ return this;
+ }
+
+ @Override
+ public InterceptorResolvableBuilder setDeclaringBean(Bean<?> declaringBean)
+ {
+ super.setDeclaringBean(declaringBean);
+ return this;
+ }
+
+ @Override
+ public InterceptorResolvableBuilder setInjectionPoint(InjectionPoint injectionPoint)
+ {
+ super.setInjectionPoint(injectionPoint);
+ return this;
+ }
+
+ @Override
+ public InterceptorResolvableBuilder setType(Type type)
+ {
+ super.setType(type);
+ return this;
+ }
+
+ @Override
+ public InterceptorResolvable create()
+ {
+ if (qualifiers.size() == 0)
+ {
+ throw new ForbiddenArgumentException(INTERCEPTOR_BINDINGS_EMPTY);
+ }
+ return new InterceptorResolvableImpl(rawType, types, qualifiers, mappedQualifiers, declaringBean, interceptionType);
+ }
+
+
+ private static class InterceptorResolvableImpl extends ResolvableImpl implements InterceptorResolvable
+ {
+ private final InterceptionType interceptionType;
+
+ private InterceptorResolvableImpl(Class<?> rawType, Set<Type> typeClosure, Set<Annotation> qualifiers, Map<Class<? extends Annotation>, Annotation> mappedQualifiers, Bean<?> declaringBean, InterceptionType interceptionType)
+ {
+ super(rawType, typeClosure, qualifiers, mappedQualifiers, declaringBean);
+ this.interceptionType = interceptionType;
+ }
+
+ public InterceptionType getInterceptionType()
+ {
+ return interceptionType;
+ }
+
+ }
+
+}
Property changes on: core/trunk/impl/src/main/java/org/jboss/weld/resolution/InterceptorResolvableBuilder.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Modified: core/trunk/impl/src/main/java/org/jboss/weld/resolution/NewResolvableTransformer.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/resolution/NewResolvableTransformer.java 2010-02-16 19:12:06 UTC (rev 5850)
+++ core/trunk/impl/src/main/java/org/jboss/weld/resolution/NewResolvableTransformer.java 2010-02-16 19:13:20 UTC (rev 5851)
@@ -103,7 +103,7 @@
}
@Override
- public Set<Type> getTypeClosure()
+ public Set<Type> getTypes()
{
return typeClosure;
}
Modified: core/trunk/impl/src/main/java/org/jboss/weld/resolution/Resolvable.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/resolution/Resolvable.java 2010-02-16 19:12:06 UTC (rev 5850)
+++ core/trunk/impl/src/main/java/org/jboss/weld/resolution/Resolvable.java 2010-02-16 19:13:20 UTC (rev 5851)
@@ -20,7 +20,7 @@
import java.lang.reflect.Type;
import java.util.Set;
-import org.jboss.weld.bean.AbstractClassBean;
+import javax.enterprise.inject.spi.Bean;
/**
* Something that is resovable by the resolver. A resolvable is defined by it's
@@ -67,11 +67,11 @@
public boolean isAssignableTo(Class<?> clazz);
/**
- * The type closure of this resolvable
+ * The types that this resolvable may be assigned to
*
* @return
*/
- public Set<Type> getTypeClosure();
+ public Set<Type> getTypes();
/**
* Get the underlying java class used to generate this resolvable, or null
@@ -85,6 +85,6 @@
* Get the declaring the injection point, or null if there is none
* @return
*/
- public AbstractClassBean<?> getDeclaringBean();
+ public Bean<?> getDeclaringBean();
}
Added: core/trunk/impl/src/main/java/org/jboss/weld/resolution/ResolvableBuilder.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/resolution/ResolvableBuilder.java (rev 0)
+++ core/trunk/impl/src/main/java/org/jboss/weld/resolution/ResolvableBuilder.java 2010-02-16 19:13:20 UTC (rev 5851)
@@ -0,0 +1,219 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, 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.weld.resolution;
+
+import static org.jboss.weld.logging.messages.BeanManagerMessage.DUPLICATE_QUALIFIERS;
+import static org.jboss.weld.logging.messages.BeanManagerMessage.INVALID_QUALIFIER;
+import static org.jboss.weld.logging.messages.ResolutionMessage.CANNOT_EXTRACT_RAW_TYPE;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Type;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import javax.enterprise.inject.spi.Bean;
+import javax.enterprise.inject.spi.InjectionPoint;
+
+import org.jboss.weld.Container;
+import org.jboss.weld.exceptions.ForbiddenArgumentException;
+import org.jboss.weld.literal.DefaultLiteral;
+import org.jboss.weld.metadata.cache.MetaAnnotationStore;
+import org.jboss.weld.util.reflection.Reflections;
+
+public class ResolvableBuilder
+{
+
+ protected Class<?> rawType;
+ protected final Set<Type> types;
+ protected final Set<Annotation> qualifiers;
+ protected final Map<Class<? extends Annotation>, Annotation> mappedQualifiers;
+ protected Bean<?> declaringBean;
+
+ public ResolvableBuilder()
+ {
+ this.types = new HashSet<Type>();
+ this.qualifiers = new HashSet<Annotation>();
+ this.mappedQualifiers = new HashMap<Class<? extends Annotation>, Annotation>();
+ }
+
+ public ResolvableBuilder setType(Type type)
+ {
+ if (rawType != null)
+ {
+ throw new IllegalStateException("Cannot change type once set");
+ }
+ if (type == null)
+ {
+ throw new IllegalArgumentException("type cannot be null");
+ }
+ this.rawType = Reflections.getRawType(type);
+ if (rawType == null)
+ {
+ throw new ForbiddenArgumentException(CANNOT_EXTRACT_RAW_TYPE, type);
+ }
+ this.types.add(type);
+ return this;
+ }
+
+ public ResolvableBuilder setInjectionPoint(InjectionPoint injectionPoint)
+ {
+ setType(injectionPoint.getType());
+ addQualifiers(injectionPoint.getQualifiers());
+ setDeclaringBean(injectionPoint.getBean());
+ return this;
+ }
+
+ public ResolvableBuilder setDeclaringBean(Bean<?> declaringBean)
+ {
+ this.declaringBean = declaringBean;
+ return this;
+ }
+
+ public ResolvableBuilder addType(Type type)
+ {
+ this.types.add(type);
+ return this;
+ }
+
+ public ResolvableBuilder addTypes(Set<Type> types)
+ {
+ this.types.addAll(types);
+ return this;
+ }
+
+ public Resolvable create()
+ {
+ if (qualifiers.size() == 0)
+ {
+ this.qualifiers.add(DefaultLiteral.INSTANCE);
+ }
+ return new ResolvableImpl(rawType, types, qualifiers, mappedQualifiers, declaringBean);
+ }
+
+ public ResolvableBuilder addQualifier(Annotation qualifier)
+ {
+ checkQualifier(qualifier);
+ this.qualifiers.add(qualifier);
+ this.mappedQualifiers.put(qualifier.annotationType(), qualifier);
+ return this;
+ }
+
+ public ResolvableBuilder addQualifierIfAbsent(Annotation qualifier)
+ {
+ if (!qualifiers.contains(qualifier))
+ {
+ addQualifier(qualifier);
+ }
+ return this;
+ }
+
+ public ResolvableBuilder addQualifiers(Annotation[] qualifiers)
+ {
+ for (Annotation qualifier : qualifiers)
+ {
+ addQualifier(qualifier);
+ }
+ return this;
+ }
+
+ public ResolvableBuilder addQualifiers(Set<Annotation> qualifiers)
+ {
+ for (Annotation qualifier : qualifiers)
+ {
+ addQualifier(qualifier);
+ }
+ return this;
+ }
+
+ protected void checkQualifier(Annotation qualifier)
+ {
+ if (!Container.instance().services().get(MetaAnnotationStore.class).getBindingTypeModel(qualifier.annotationType()).isValid())
+ {
+ throw new ForbiddenArgumentException(INVALID_QUALIFIER, qualifier);
+ }
+ if (qualifiers.contains(qualifier))
+ {
+ throw new ForbiddenArgumentException(DUPLICATE_QUALIFIERS, Arrays.asList(qualifiers));
+ }
+ }
+
+ protected static class ResolvableImpl implements Resolvable
+ {
+
+ private final Set<Annotation> qualifiers;
+ private final Map<Class<? extends Annotation>, Annotation> mappedQualifiers;
+ private final Set<Type> typeClosure;
+ private final Class<?> rawType;
+ private final Bean<?> declaringBean;
+
+ protected ResolvableImpl(Class<?> rawType, Set<Type> typeClosure, Set<Annotation> qualifiers, Map<Class<? extends Annotation>, Annotation> mappedQualifiers, Bean<?> declaringBean)
+ {
+ this.qualifiers = qualifiers;
+ this.mappedQualifiers = mappedQualifiers;
+ this.typeClosure = typeClosure;
+ this.rawType = rawType;
+ this.declaringBean = declaringBean;
+ }
+
+ public Set<Annotation> getQualifiers()
+ {
+ return qualifiers;
+ }
+
+ public boolean isAnnotationPresent(Class<? extends Annotation> annotationType)
+ {
+ return mappedQualifiers.containsKey(annotationType);
+ }
+
+ public Set<Type> getTypes()
+ {
+ return typeClosure;
+ }
+
+ public boolean isAssignableTo(Class<?> clazz)
+ {
+ return Reflections.isAssignableFrom(clazz, typeClosure);
+ }
+
+ public <A extends Annotation> A getAnnotation(Class<A> annotationType)
+ {
+ return (A) mappedQualifiers.get(annotationType);
+ }
+
+ public Class<?> getJavaClass()
+ {
+ return rawType;
+ }
+
+ public Bean<?> getDeclaringBean()
+ {
+ return declaringBean;
+ }
+
+ @Override
+ public String toString()
+ {
+ return "Types: " + getTypes() + "; Bindings: " + getQualifiers();
+ }
+
+ }
+
+
+}
Property changes on: core/trunk/impl/src/main/java/org/jboss/weld/resolution/ResolvableBuilder.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Deleted: core/trunk/impl/src/main/java/org/jboss/weld/resolution/ResolvableFactory.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/resolution/ResolvableFactory.java 2010-02-16 19:12:06 UTC (rev 5850)
+++ core/trunk/impl/src/main/java/org/jboss/weld/resolution/ResolvableFactory.java 2010-02-16 19:13:20 UTC (rev 5851)
@@ -1,153 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, 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.weld.resolution;
-
-import java.lang.annotation.Annotation;
-import java.lang.reflect.Type;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-
-import javax.enterprise.inject.spi.InterceptionType;
-
-import org.jboss.weld.bean.AbstractClassBean;
-import org.jboss.weld.introspector.WeldAnnotated;
-import org.jboss.weld.literal.DefaultLiteral;
-import org.jboss.weld.util.collections.Arrays2;
-import org.jboss.weld.util.reflection.Reflections;
-
-public class ResolvableFactory
-{
-
- public static Resolvable of(WeldAnnotated<?, ?> annotated)
- {
- if (annotated instanceof Resolvable)
- {
- return (Resolvable) annotated;
- }
- else
- {
- Set<Type> types = new HashSet<Type>();
- types.add(annotated.getBaseType());
- return new ResolvableImpl(types, annotated.getQualifiers(), null);
- }
- }
-
- public static Resolvable of(Set<Type> typeClosure, Set<Annotation> qualifiers, AbstractClassBean<?> declaringBean)
- {
- return new ResolvableImpl(typeClosure, qualifiers, declaringBean);
- }
-
- public static Resolvable of(Set<Type> typeClosure, Annotation[] qualifiers, AbstractClassBean<?> declaringBean)
- {
- return new ResolvableImpl(typeClosure, Arrays2.asSet(qualifiers), declaringBean);
- }
-
- public static InterceptorResolvable of(InterceptionType interceptionType, Annotation[] qualifiers)
- {
- return new InterceptorResolvableImpl(Arrays2.asSet(qualifiers), interceptionType );
- }
-
- private ResolvableFactory() {}
-
- private static class ResolvableImpl implements Resolvable
- {
-
- private final Set<Annotation> qualifiers;
- private final Map<Class<? extends Annotation>, Annotation> annotations;
- private final Set<Type> typeClosure;
- private final AbstractClassBean<?> declaringBean;
-
- public ResolvableImpl(Set<Type> typeClosure, Set<Annotation> qualifiers, AbstractClassBean<?> declaringBean)
- {
- this.qualifiers = qualifiers;
- if (qualifiers.size() == 0)
- {
- this.qualifiers.add(DefaultLiteral.INSTANCE);
- }
- this.annotations = new HashMap<Class<? extends Annotation>, Annotation>();
- this.typeClosure = typeClosure;
- for (Annotation annotation : qualifiers)
- {
- annotations.put(annotation.annotationType(), annotation);
- }
- this.declaringBean = declaringBean;
- }
-
- public Set<Annotation> getQualifiers()
- {
- return qualifiers;
- }
-
- public boolean isAnnotationPresent(Class<? extends Annotation> annotationType)
- {
- return annotations.containsKey(annotationType);
- }
-
- public Set<Type> getTypeClosure()
- {
- return typeClosure;
- }
-
- public boolean isAssignableTo(Class<?> clazz)
- {
- return Reflections.isAssignableFrom(clazz, typeClosure);
- }
-
- public <A extends Annotation> A getAnnotation(Class<A> annotationType)
- {
- return (A) annotations.get(annotationType);
- }
-
- public Class<?> getJavaClass()
- {
- // No underlying java class
- return null;
- }
-
- public AbstractClassBean<?> getDeclaringBean()
- {
- return declaringBean;
- }
-
- @Override
- public String toString()
- {
- return "Types: " + getTypeClosure() + "; Bindings: " + getQualifiers();
- }
-
- }
-
- private static class InterceptorResolvableImpl extends ResolvableImpl implements InterceptorResolvable
- {
- private final InterceptionType interceptionType;
-
- private InterceptorResolvableImpl(Set<Annotation> bindings, InterceptionType interceptionType)
- {
- super(Collections.singleton((Type)Object.class), bindings, null);
- this.interceptionType = interceptionType;
- }
-
- public InterceptionType getInterceptionType()
- {
- return interceptionType;
- }
- }
-
-}
Deleted: core/trunk/impl/src/main/java/org/jboss/weld/resolution/ResolvableWeldClass.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/resolution/ResolvableWeldClass.java 2010-02-16 19:12:06 UTC (rev 5850)
+++ core/trunk/impl/src/main/java/org/jboss/weld/resolution/ResolvableWeldClass.java 2010-02-16 19:13:20 UTC (rev 5851)
@@ -1,215 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, 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.weld.resolution;
-
-import static org.jboss.weld.logging.messages.ResolutionMessage.CANNOT_EXTRACT_RAW_TYPE;
-import static org.jboss.weld.logging.messages.ResolutionMessage.CANNOT_EXTRACT_TYPE_INFORMATION;
-import static org.jboss.weld.logging.messages.ResolutionMessage.INVALID_MEMBER_TYPE;
-import static org.jboss.weld.util.reflection.Reflections.EMPTY_ANNOTATIONS;
-
-import java.lang.annotation.Annotation;
-import java.lang.reflect.Field;
-import java.lang.reflect.Member;
-import java.lang.reflect.Method;
-import java.lang.reflect.ParameterizedType;
-import java.lang.reflect.Type;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-
-import javax.enterprise.inject.spi.InjectionPoint;
-
-import org.jboss.weld.bean.AbstractClassBean;
-import org.jboss.weld.exceptions.ForbiddenArgumentException;
-import org.jboss.weld.exceptions.InvalidOperationException;
-import org.jboss.weld.injection.WeldInjectionPoint;
-import org.jboss.weld.introspector.WeldAnnotated;
-import org.jboss.weld.introspector.jlr.AbstractWeldAnnotated;
-import org.jboss.weld.manager.BeanManagerImpl;
-import org.jboss.weld.metadata.TypeStore;
-import org.jboss.weld.util.Names;
-import org.jboss.weld.util.reflection.Reflections;
-
-public class ResolvableWeldClass<T> extends AbstractWeldAnnotated<T, Class<T>> implements Resolvable
-{
- private final Class<T> rawType;
- private final Set<Type> typeClosure;
- private final Type[] actualTypeArguments;
-
- public static <T> WeldAnnotated<T, Class<T>> of(Type type, Annotation[] annotations, BeanManagerImpl manager)
- {
- return new ResolvableWeldClass<T>(type, annotations, manager);
- }
-
- public static <T> WeldAnnotated<T, Class<T>> of(InjectionPoint injectionPoint, BeanManagerImpl manager)
- {
- if (injectionPoint instanceof WeldInjectionPoint)
- {
- @SuppressWarnings("unchecked")
- WeldAnnotated<T, Class<T>> ip = (WeldAnnotated<T, Class<T>>) injectionPoint;
- return ip;
- }
- else
- {
- return new ResolvableWeldClass<T>(injectionPoint.getType(), injectionPoint.getAnnotated().getAnnotations(), manager);
- }
- }
-
- public static <T> WeldAnnotated<T, Class<T>> of(Member member, Annotation[] annotations, BeanManagerImpl manager)
- {
- if (member instanceof Field)
- {
- return new ResolvableWeldClass<T>(((Field) member).getGenericType(), annotations, manager);
- }
- else if (member instanceof Method)
- {
- return new ResolvableWeldClass<T>(((Method) member).getGenericReturnType(), annotations, manager);
- }
- else
- {
- throw new ForbiddenArgumentException(INVALID_MEMBER_TYPE, member);
- }
- }
-
- private ResolvableWeldClass(Type type, Map<Class<? extends Annotation>, Annotation> annotationMap, Map<Class<? extends Annotation>, Annotation> declaredAnnotationMap, BeanManagerImpl manager)
- {
- super(annotationMap, declaredAnnotationMap, manager.getServices().get(TypeStore.class));
-
- if (type instanceof ParameterizedType)
- {
- ParameterizedType parameterizedType = (ParameterizedType) type;
- if (parameterizedType.getRawType() instanceof Class<?>)
- {
- this.rawType = (Class<T>) parameterizedType.getRawType();
- }
- else
- {
- throw new ForbiddenArgumentException(CANNOT_EXTRACT_RAW_TYPE, type);
- }
- this.actualTypeArguments = ((ParameterizedType) type).getActualTypeArguments();
- }
- else if (type instanceof Class<?>)
- {
- this.rawType = (Class<T>) type;
- this.actualTypeArguments = new Type[0];
- }
- else
- {
- throw new ForbiddenArgumentException(CANNOT_EXTRACT_TYPE_INFORMATION, type);
- }
- this.typeClosure = new HashSet<Type>();
- typeClosure.add(type);
- }
-
- private ResolvableWeldClass(Type type, Annotation[] annotations, BeanManagerImpl manager)
- {
- this(type, buildAnnotationMap(annotations), buildAnnotationMap(EMPTY_ANNOTATIONS), manager);
- }
-
- private ResolvableWeldClass(Type type, Set<Annotation>annotations, BeanManagerImpl manager)
- {
- this(type, buildAnnotationMap(annotations), buildAnnotationMap(EMPTY_ANNOTATIONS), manager);
- }
-
- @Override
- public String toString()
- {
- return Names.toString(getJavaClass(), getAnnotations(), getActualTypeArguments());
- }
-
- @Override
- public Class<T> getDelegate()
- {
- return rawType;
- }
-
- @Override
- public Type[] getActualTypeArguments()
- {
- return actualTypeArguments;
- }
-
- public String getName()
- {
- throw new InvalidOperationException();
- }
-
- @Override
- public Class<T> getJavaClass()
- {
- return rawType;
- }
-
- public boolean isFinal()
- {
- throw new InvalidOperationException();
- }
-
- public boolean isPublic()
- {
- throw new InvalidOperationException();
- }
-
- public boolean isPrivate()
- {
- throw new InvalidOperationException();
- }
-
- public boolean isPackagePrivate()
- {
- throw new InvalidOperationException();
- }
-
- public Package getPackage()
- {
- throw new InvalidOperationException();
- }
-
- public boolean isStatic()
- {
- throw new InvalidOperationException();
- }
-
- @Override
- public boolean isProxyable()
- {
- throw new InvalidOperationException();
- }
-
- @Override
- public Set<Type> getTypeClosure()
- {
- return typeClosure;
- }
-
- public AbstractClassBean<?> getDeclaringBean()
- {
- return null;
- }
-
- @Override
- public Type getBaseType()
- {
- return getJavaClass();
- }
-
- public boolean isAssignableTo(Class<?> clazz)
- {
- return Reflections.isAssignableFrom(clazz, getBaseType());
- }
-
-}
\ No newline at end of file
Modified: core/trunk/impl/src/main/java/org/jboss/weld/resolution/TypeSafeBeanResolver.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/resolution/TypeSafeBeanResolver.java 2010-02-16 19:12:06 UTC (rev 5850)
+++ core/trunk/impl/src/main/java/org/jboss/weld/resolution/TypeSafeBeanResolver.java 2010-02-16 19:13:20 UTC (rev 5851)
@@ -98,7 +98,7 @@
@Override
protected boolean matches(Resolvable resolvable, T bean)
{
- return Reflections.matches(resolvable.getTypeClosure(), bean.getTypes()) && Beans.containsAllBindings(resolvable.getQualifiers(), bean.getQualifiers(), beanManager);
+ return Reflections.matches(resolvable.getTypes(), bean.getTypes()) && Beans.containsAllBindings(resolvable.getQualifiers(), bean.getQualifiers(), beanManager);
}
/**
Modified: core/trunk/impl/src/main/java/org/jboss/weld/resolution/TypeSafeDecoratorResolver.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/resolution/TypeSafeDecoratorResolver.java 2010-02-16 19:12:06 UTC (rev 5850)
+++ core/trunk/impl/src/main/java/org/jboss/weld/resolution/TypeSafeDecoratorResolver.java 2010-02-16 19:13:20 UTC (rev 5851)
@@ -43,7 +43,7 @@
@Override
protected boolean matches(Resolvable resolvable, Decorator<?> bean)
{
- return Reflections.matches(Collections.singleton(bean.getDelegateType()), resolvable.getTypeClosure())
+ return Reflections.matches(Collections.singleton(bean.getDelegateType()), resolvable.getTypes())
&& Beans.containsAllBindings(bean.getDelegateQualifiers(), resolvable.getQualifiers(), getBeanManager())
&& getBeanManager().getEnabledDecoratorClasses().contains(bean.getBeanClass());
}
Modified: core/trunk/impl/src/main/java/org/jboss/weld/resolution/TypeSafeDisposerResolver.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/resolution/TypeSafeDisposerResolver.java 2010-02-16 19:12:06 UTC (rev 5850)
+++ core/trunk/impl/src/main/java/org/jboss/weld/resolution/TypeSafeDisposerResolver.java 2010-02-16 19:13:20 UTC (rev 5851)
@@ -42,7 +42,7 @@
@Override
protected boolean matches(Resolvable resolvable, DisposalMethod<?, ?> disposer)
{
- return resolvable.getDeclaringBean().equals(disposer.getDeclaringBean()) && Reflections.isAssignableFrom(disposer.getType(), resolvable.getTypeClosure()) && Beans.containsAllBindings(disposer.getQualifiers(), resolvable.getQualifiers(), manager);
+ return resolvable.getDeclaringBean().equals(disposer.getDeclaringBean()) && Reflections.isAssignableFrom(disposer.getType(), resolvable.getTypes()) && Beans.containsAllBindings(disposer.getQualifiers(), resolvable.getQualifiers(), manager);
}
/**
Modified: core/trunk/impl/src/main/java/org/jboss/weld/resolution/TypeSafeObserverResolver.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/resolution/TypeSafeObserverResolver.java 2010-02-16 19:12:06 UTC (rev 5850)
+++ core/trunk/impl/src/main/java/org/jboss/weld/resolution/TypeSafeObserverResolver.java 2010-02-16 19:13:20 UTC (rev 5851)
@@ -43,7 +43,7 @@
@Override
protected boolean matches(Resolvable resolvable, ObserverMethod<?> observer)
{
- return Reflections.isAssignableFrom(observer.getObservedType(), resolvable.getTypeClosure()) && Beans.containsAllBindings(observer.getObservedQualifiers(), resolvable.getQualifiers(), manager);
+ return Reflections.isAssignableFrom(observer.getObservedType(), resolvable.getTypes()) && Beans.containsAllBindings(observer.getObservedQualifiers(), resolvable.getQualifiers(), manager);
}
/**
Modified: core/trunk/impl/src/main/java/org/jboss/weld/resolution/TypeSafeResolver.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/resolution/TypeSafeResolver.java 2010-02-16 19:12:06 UTC (rev 5850)
+++ core/trunk/impl/src/main/java/org/jboss/weld/resolution/TypeSafeResolver.java 2010-02-16 19:13:20 UTC (rev 5851)
@@ -54,7 +54,7 @@
if (obj instanceof Resolvable)
{
Resolvable that = (Resolvable) obj;
- return this.getResolvable().getTypeClosure().equals(that.getTypeClosure()) && this.getResolvable().getQualifiers().equals(that.getQualifiers());
+ return this.getResolvable().getTypes().equals(that.getTypes()) && this.getResolvable().getQualifiers().equals(that.getQualifiers());
}
else
{
@@ -66,7 +66,7 @@
public int hashCode()
{
int result = 17;
- result = 31 * result + this.getResolvable().getTypeClosure().hashCode();
+ result = 31 * result + this.getResolvable().getTypes().hashCode();
result = 31 * result + this.getResolvable().getQualifiers().hashCode();
return result;
}
Modified: core/trunk/impl/src/main/java/org/jboss/weld/util/collections/Arrays2.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/util/collections/Arrays2.java 2010-02-16 19:12:06 UTC (rev 5850)
+++ core/trunk/impl/src/main/java/org/jboss/weld/util/collections/Arrays2.java 2010-02-16 19:13:20 UTC (rev 5851)
@@ -40,12 +40,12 @@
return containsAll(array, values) && array.length == values.length;
}
- public static <T> Set<T> asSet(T... types)
+ public static <T> Set<T> asSet(T... array)
{
Set<T> result = new HashSet<T>();
- for (T type : types)
+ for (T a : array)
{
- result.add(type);
+ result.add(a);
}
return result;
}
Modified: core/trunk/impl/src/main/java/org/jboss/weld/util/reflection/Reflections.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/util/reflection/Reflections.java 2010-02-16 19:12:06 UTC (rev 5850)
+++ core/trunk/impl/src/main/java/org/jboss/weld/util/reflection/Reflections.java 2010-02-16 19:13:20 UTC (rev 5851)
@@ -200,7 +200,7 @@
{
return Modifier.isTransient(member.getModifiers());
}
-
+
/**
* Checks if a method is abstract
*
@@ -636,6 +636,12 @@
return clazz.isPrimitive() || Serializable.class.isAssignableFrom(clazz);
}
+ public static boolean isPrimitive(Type type)
+ {
+ Class<?> rawType = getRawType(type);
+ return rawType == null ? false : rawType.isPrimitive();
+ }
+
@SuppressWarnings("unchecked")
public static <T> Class<T> getRawType(Type type)
{
14 years, 10 months
Weld SVN: r5850 - core/trunk/impl/src/main/java/org/jboss/weld/jsf.
by weld-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2010-02-16 14:12:06 -0500 (Tue, 16 Feb 2010)
New Revision: 5850
Modified:
core/trunk/impl/src/main/java/org/jboss/weld/jsf/JsfApiAbstraction.java
Log:
commit something like Dan's changes
Modified: core/trunk/impl/src/main/java/org/jboss/weld/jsf/JsfApiAbstraction.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/jsf/JsfApiAbstraction.java 2010-02-16 19:11:20 UTC (rev 5849)
+++ core/trunk/impl/src/main/java/org/jboss/weld/jsf/JsfApiAbstraction.java 2010-02-16 19:12:06 UTC (rev 5850)
@@ -19,7 +19,6 @@
import org.jboss.weld.bootstrap.api.Service;
import org.jboss.weld.resources.spi.ResourceLoader;
import org.jboss.weld.util.ApiAbstraction;
-import org.jboss.weld.util.reflection.SecureReflections;
/**
* Utility class for JSF related components, concepts etc. It can also
@@ -46,12 +45,14 @@
this.UICOMPONENT_CLASS = classForName("javax.faces.component.UIComponent");
this.FACES_CONTEXT = classForName("javax.faces.context.FacesContext");
this.BEHAVIOR_CLASS = classForName("javax.faces.component.behavior.Behavior");
- double version = 2.0;
- if (this.FACES_CONTEXT != null)
+ if (this.BEHAVIOR_CLASS.getName().equals("javax.faces.component.behavior.Behavior"))
{
- version = SecureReflections.isMethodExists(FACES_CONTEXT, "isPostback") ? 2.0 : 1.2;
+ MINIMUM_API_VERSION = 2.0;
}
- MINIMUM_API_VERSION = version;
+ else
+ {
+ MINIMUM_API_VERSION = 1.2;
+ }
}
public boolean isApiVersionCompatibleWith(double version)
14 years, 10 months
Weld SVN: r5849 - core/trunk/tests/src/test/java/org/jboss/weld/tests/resolution/named.
by weld-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2010-02-16 14:11:20 -0500 (Tue, 16 Feb 2010)
New Revision: 5849
Added:
core/trunk/tests/src/test/java/org/jboss/weld/tests/resolution/named/FooBean.java
core/trunk/tests/src/test/java/org/jboss/weld/tests/resolution/named/NamedBeanConsumer.java
core/trunk/tests/src/test/java/org/jboss/weld/tests/resolution/named/NamedBeanTest.java
Removed:
core/trunk/tests/src/test/java/org/jboss/weld/tests/resolution/named/NamedBeanWithBindingTest.java
Log:
test for WELD-435
Added: core/trunk/tests/src/test/java/org/jboss/weld/tests/resolution/named/FooBean.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/resolution/named/FooBean.java (rev 0)
+++ core/trunk/tests/src/test/java/org/jboss/weld/tests/resolution/named/FooBean.java 2010-02-16 19:11:20 UTC (rev 5849)
@@ -0,0 +1,9 @@
+package org.jboss.weld.tests.resolution.named;
+
+import javax.inject.Named;
+
+@Named("foo")
+public class FooBean
+{
+
+}
Property changes on: core/trunk/tests/src/test/java/org/jboss/weld/tests/resolution/named/FooBean.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Added: core/trunk/tests/src/test/java/org/jboss/weld/tests/resolution/named/NamedBeanConsumer.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/resolution/named/NamedBeanConsumer.java (rev 0)
+++ core/trunk/tests/src/test/java/org/jboss/weld/tests/resolution/named/NamedBeanConsumer.java 2010-02-16 19:11:20 UTC (rev 5849)
@@ -0,0 +1,14 @@
+package org.jboss.weld.tests.resolution.named;
+
+
+public class NamedBeanConsumer
+{
+
+ /*@Inject @Named*/ FooBean foo;
+
+ public FooBean getFoo()
+ {
+ return foo;
+ }
+
+}
Property changes on: core/trunk/tests/src/test/java/org/jboss/weld/tests/resolution/named/NamedBeanConsumer.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Copied: core/trunk/tests/src/test/java/org/jboss/weld/tests/resolution/named/NamedBeanTest.java (from rev 5749, core/trunk/tests/src/test/java/org/jboss/weld/tests/resolution/named/NamedBeanWithBindingTest.java)
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/resolution/named/NamedBeanTest.java (rev 0)
+++ core/trunk/tests/src/test/java/org/jboss/weld/tests/resolution/named/NamedBeanTest.java 2010-02-16 19:11:20 UTC (rev 5849)
@@ -0,0 +1,45 @@
+/*
+ * 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.weld.tests.resolution.named;
+
+import javax.enterprise.inject.spi.Bean;
+
+import org.jboss.testharness.impl.packaging.Artifact;
+import org.jboss.weld.test.AbstractWeldTest;
+import org.testng.annotations.Test;
+
+/**
+ * @author Dan Allen
+ */
+@Artifact(addCurrentPackage = true)
+public class NamedBeanTest extends AbstractWeldTest
+{
+ @Test
+ public void testGetNamedBeanWithBinding()
+ {
+ Bean<?> bean = getCurrentManager().resolve(getCurrentManager().getBeans("namedBeanWithBinding"));
+ NamedBeanWithBinding instance = (NamedBeanWithBinding) getCurrentManager().getReference(bean, Object.class, getCurrentManager().createCreationalContext(bean));
+ assert instance != null;
+ }
+
+ @Test(description = "WELD-435", groups = "broken")
+ public void testNamedInjectedFieldUsesFieldName()
+ {
+ assert getReference(NamedBeanConsumer.class).getFoo() != null;
+ }
+
+}
Property changes on: core/trunk/tests/src/test/java/org/jboss/weld/tests/resolution/named/NamedBeanTest.java
___________________________________________________________________
Name: svn:eol-style
+ native
Deleted: core/trunk/tests/src/test/java/org/jboss/weld/tests/resolution/named/NamedBeanWithBindingTest.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/resolution/named/NamedBeanWithBindingTest.java 2010-02-16 19:09:55 UTC (rev 5848)
+++ core/trunk/tests/src/test/java/org/jboss/weld/tests/resolution/named/NamedBeanWithBindingTest.java 2010-02-16 19:11:20 UTC (rev 5849)
@@ -1,38 +0,0 @@
-/*
- * 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.weld.tests.resolution.named;
-
-import javax.enterprise.inject.spi.Bean;
-
-import org.jboss.testharness.impl.packaging.Artifact;
-import org.jboss.weld.test.AbstractWeldTest;
-import org.testng.annotations.Test;
-
-/**
- * @author Dan Allen
- */
-@Artifact(addCurrentPackage = true)
-public class NamedBeanWithBindingTest extends AbstractWeldTest
-{
- @Test
- public void testGetNamedBeanWithBinding()
- {
- Bean<?> bean = getCurrentManager().resolve(getCurrentManager().getBeans("namedBeanWithBinding"));
- NamedBeanWithBinding instance = (NamedBeanWithBinding) getCurrentManager().getReference(bean, Object.class, getCurrentManager().createCreationalContext(bean));
- assert instance != null;
- }
-}
14 years, 10 months
Weld SVN: r5848 - core/trunk/tests/src/test/java/org/jboss/weld/tests/serialization.
by weld-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2010-02-16 14:09:55 -0500 (Tue, 16 Feb 2010)
New Revision: 5848
Modified:
core/trunk/tests/src/test/java/org/jboss/weld/tests/serialization/LoggerConsumer.java
core/trunk/tests/src/test/java/org/jboss/weld/tests/serialization/SerializationTest.java
Log:
fix test to work incontainer
Modified: core/trunk/tests/src/test/java/org/jboss/weld/tests/serialization/LoggerConsumer.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/serialization/LoggerConsumer.java 2010-02-16 15:34:37 UTC (rev 5847)
+++ core/trunk/tests/src/test/java/org/jboss/weld/tests/serialization/LoggerConsumer.java 2010-02-16 19:09:55 UTC (rev 5848)
@@ -16,5 +16,10 @@
{
}
+
+ public Logger getLog()
+ {
+ return log;
+ }
}
Modified: core/trunk/tests/src/test/java/org/jboss/weld/tests/serialization/SerializationTest.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/serialization/SerializationTest.java 2010-02-16 15:34:37 UTC (rev 5847)
+++ core/trunk/tests/src/test/java/org/jboss/weld/tests/serialization/SerializationTest.java 2010-02-16 19:09:55 UTC (rev 5848)
@@ -16,6 +16,8 @@
*/
package org.jboss.weld.tests.serialization;
+import java.io.Serializable;
+
import javax.enterprise.inject.IllegalProductException;
import org.jboss.testharness.impl.packaging.Artifact;
@@ -44,9 +46,20 @@
assert deserializedCMgr.getConversationInstance().get() != null;
}
- @Test(description="http://lists.jboss.org/pipermail/weld-dev/2010-February/002265.html", expectedExceptions=IllegalProductException.class)
+ @Test(description="http://lists.jboss.org/pipermail/weld-dev/2010-February/002265.html")
public void testNonSerializableProductInjectedIntoSessionScopedBean()
{
- getReference(LoggerConsumer.class).ping();
+ try
+ {
+ getReference(LoggerConsumer.class).ping();
+ }
+ catch (Exception e)
+ {
+ // If Logger isn't serializable, we get here
+ assert e instanceof IllegalProductException;
+ return;
+ }
+ // If Logger is serializable we get here
+ assert getReference(LoggerConsumer.class).getLog() instanceof Serializable;
}
}
14 years, 10 months