Author: pete.muir(a)jboss.org
Date: 2009-07-31 15:00:50 -0400 (Fri, 31 Jul 2009)
New Revision: 3389
Removed:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/field/definition/enterprise/InfertileChicken.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/field/definition/enterprise/InfertileChickenLocal.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/field/definition/enterprise/LameInfertileChicken.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/field/definition/enterprise/LameInfertileChickenLocal.java
Modified:
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ProducerFieldBean.java
ri/trunk/spi/src/main/java/org/jboss/webbeans/ejb/api/SessionObjectReference.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/field/definition/enterprise/Chicken.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/field/definition/enterprise/Egg.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/field/definition/enterprise/EnterpriseProducerFieldDefinitionTest.java
tck/trunk/impl/src/main/resources/tck-audit.xml
Log:
WBRI-208, remove the producer field access as spec now says only static fields on session
beans, remove offending tests, add one for static fields :-)
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ProducerFieldBean.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ProducerFieldBean.java 2009-07-31
15:45:48 UTC (rev 3388)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ProducerFieldBean.java 2009-07-31
19:00:50 UTC (rev 3389)
@@ -24,8 +24,6 @@
import javax.enterprise.context.spi.CreationalContext;
import org.jboss.webbeans.BeanManagerImpl;
-import org.jboss.webbeans.bean.proxy.EnterpriseBeanInstance;
-import org.jboss.webbeans.bean.proxy.Marker;
import org.jboss.webbeans.bootstrap.BeanDeployerEnvironment;
import org.jboss.webbeans.introspector.WBField;
import org.jboss.webbeans.util.Names;
@@ -86,20 +84,7 @@
@Override
protected T produceInstance(CreationalContext<T> creationalContext)
{
- Object receiver = getReceiver(creationalContext);
- if (getDeclaringBean() instanceof EnterpriseBean<?> && receiver
instanceof EnterpriseBeanInstance)
- {
- EnterpriseBeanInstance declaringInstance = (EnterpriseBeanInstance) receiver;
- Object object =
declaringInstance.getSessionObjectReference(Marker.INSTANCE).getFieldValue(field.getDeclaringType().getJavaClass(),
field.getName());
-
- @SuppressWarnings("unchecked")
- T instance = (T) object;
- return instance;
- }
- else
- {
- return field.get(receiver);
- }
+ return field.get(getReceiver(creationalContext));
}
Modified:
ri/trunk/spi/src/main/java/org/jboss/webbeans/ejb/api/SessionObjectReference.java
===================================================================
---
ri/trunk/spi/src/main/java/org/jboss/webbeans/ejb/api/SessionObjectReference.java 2009-07-31
15:45:48 UTC (rev 3388)
+++
ri/trunk/spi/src/main/java/org/jboss/webbeans/ejb/api/SessionObjectReference.java 2009-07-31
19:00:50 UTC (rev 3389)
@@ -51,25 +51,4 @@
*/
public void remove();
- /**
- * Retrieve the value of a field. The field may have any visibility modifier.
- *
- * Used for retrieving producer field value.
- *
- * If invoked on an SLSB, Web Beans places no requirements on which bean
- * instance is returned.
- *
- * @param declaringClass the class declaring the field
- * @param fieldName the name of the field
- * @return the current field value
- * @throws IllegalArgumentException if the declaringClass is null
- * @throws IllegalArgumentException if the fieldName is null
- * @throws IllegalArgumentException if the declaring class is not part of the
- * inheritance hierarchy of this session object reference's bean
- * class
- * @throws IllegalArgumentException if the declaringClass represents an
- * interface
- */
- public Object getFieldValue(Class<?> declaringClass, String fieldName);
-
}
Modified:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/field/definition/enterprise/Chicken.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/field/definition/enterprise/Chicken.java 2009-07-31
15:45:48 UTC (rev 3388)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/field/definition/enterprise/Chicken.java 2009-07-31
19:00:50 UTC (rev 3389)
@@ -6,6 +6,9 @@
@Stateful
public class Chicken implements ChickenLocal
{
+
+ public static final int SIZE = 5;
+
@Produces @Foo
- private Egg egg = new Egg(this);
+ private static Egg egg = new Egg(SIZE);
}
Modified:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/field/definition/enterprise/Egg.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/field/definition/enterprise/Egg.java 2009-07-31
15:45:48 UTC (rev 3388)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/field/definition/enterprise/Egg.java 2009-07-31
19:00:50 UTC (rev 3389)
@@ -3,17 +3,20 @@
public class Egg
{
- private final Chicken mother;
+ private final int size;
- public Egg(Chicken mother)
+ public Egg(int size)
{
super();
- this.mother = mother;
+ this.size = size;
}
- public Chicken getMother()
+ /**
+ * @return the size
+ */
+ public int getSize()
{
- return mother;
+ return size;
}
}
Modified:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/field/definition/enterprise/EnterpriseProducerFieldDefinitionTest.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/field/definition/enterprise/EnterpriseProducerFieldDefinitionTest.java 2009-07-31
15:45:48 UTC (rev 3388)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/field/definition/enterprise/EnterpriseProducerFieldDefinitionTest.java 2009-07-31
19:00:50 UTC (rev 3389)
@@ -1,11 +1,10 @@
package org.jboss.jsr299.tck.tests.implementation.producer.field.definition.enterprise;
-import java.lang.annotation.Annotation;
-
import javax.enterprise.inject.AnnotationLiteral;
import org.jboss.jsr299.tck.AbstractJSR299Test;
import org.jboss.test.audit.annotations.SpecAssertion;
+import org.jboss.test.audit.annotations.SpecAssertions;
import org.jboss.test.audit.annotations.SpecVersion;
import org.jboss.testharness.impl.packaging.Artifact;
import org.jboss.testharness.impl.packaging.IntegrationTest;
@@ -21,21 +20,18 @@
@SpecVersion("20090625")
public class EnterpriseProducerFieldDefinitionTest extends AbstractJSR299Test
{
- private static final Annotation FOO_LITERAL = new AnnotationLiteral<Foo>() {};
- @Test(groups = {"producerField", "ri-broken"})
- @SpecAssertion(section = "4.2", id = "eb")
- // WBRI-208
- public void testNonStaticProducerFieldNotInherited()
+ @Test
+ @SpecAssertions({
+ @SpecAssertion(section = "3.4", id = "ab"),
+ @SpecAssertion(section = "3.4", id = "ca")
+ })
+ public void testStaticProducerField()
{
- assert !(getInstanceByType(Egg.class,FOO_LITERAL).getMother() instanceof
InfertileChicken);
+ assert getInstanceByType(Egg.class, new AnnotationLiteral<Foo>() {}) !=
null;
+ assert getInstanceByType(Egg.class, new AnnotationLiteral<Foo>()
{}).getSize() == Chicken.SIZE;
}
-
- @Test(groups = {"producerField", "ri-broken"})
- @SpecAssertion(section = "4.2", id = "ed")
- // WBRI-208
- public void testNonStaticProducerFieldNotIndirectlyInherited()
- {
- assert !(getInstanceByType(Egg.class,FOO_LITERAL).getMother() instanceof
LameInfertileChicken);
- }
+
+
+
}
Deleted:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/field/definition/enterprise/InfertileChicken.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/field/definition/enterprise/InfertileChicken.java 2009-07-31
15:45:48 UTC (rev 3388)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/field/definition/enterprise/InfertileChicken.java 2009-07-31
19:00:50 UTC (rev 3389)
@@ -1,6 +0,0 @@
-package org.jboss.jsr299.tck.tests.implementation.producer.field.definition.enterprise;
-
-public class InfertileChicken extends Chicken implements InfertileChickenLocal
-{
-
-}
\ No newline at end of file
Deleted:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/field/definition/enterprise/InfertileChickenLocal.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/field/definition/enterprise/InfertileChickenLocal.java 2009-07-31
15:45:48 UTC (rev 3388)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/field/definition/enterprise/InfertileChickenLocal.java 2009-07-31
19:00:50 UTC (rev 3389)
@@ -1,9 +0,0 @@
-package org.jboss.jsr299.tck.tests.implementation.producer.field.definition.enterprise;
-
-import javax.ejb.Local;
-
-@Local
-public interface InfertileChickenLocal
-{
-
-}
Deleted:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/field/definition/enterprise/LameInfertileChicken.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/field/definition/enterprise/LameInfertileChicken.java 2009-07-31
15:45:48 UTC (rev 3388)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/field/definition/enterprise/LameInfertileChicken.java 2009-07-31
19:00:50 UTC (rev 3389)
@@ -1,9 +0,0 @@
-package org.jboss.jsr299.tck.tests.implementation.producer.field.definition.enterprise;
-
-import javax.ejb.Stateful;
-
-@Stateful
-public class LameInfertileChicken extends InfertileChicken implements
LameInfertileChickenLocal
-{
-
-}
Deleted:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/field/definition/enterprise/LameInfertileChickenLocal.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/field/definition/enterprise/LameInfertileChickenLocal.java 2009-07-31
15:45:48 UTC (rev 3388)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/field/definition/enterprise/LameInfertileChickenLocal.java 2009-07-31
19:00:50 UTC (rev 3389)
@@ -1,9 +0,0 @@
-package org.jboss.jsr299.tck.tests.implementation.producer.field.definition.enterprise;
-
-import javax.ejb.Local;
-
-@Local
-public interface LameInfertileChickenLocal
-{
-
-}
Modified: tck/trunk/impl/src/main/resources/tck-audit.xml
===================================================================
--- tck/trunk/impl/src/main/resources/tck-audit.xml 2009-07-31 15:45:48 UTC (rev 3388)
+++ tck/trunk/impl/src/main/resources/tck-audit.xml 2009-07-31 19:00:50 UTC (rev 3389)
@@ -1035,6 +1035,10 @@
<assertion id="c">
<text>A producer field may be non-static.</text>
</assertion>
+
+ <assertion id="ca">
+ <text> If the bean is a session bean, the producer field must be a static
field of the bean class.</text>
+ </assertion>
<assertion id="d">
<text>If a producer field sometimes contains a null value when accessed, then
the producer field must have scope |@Dependent|</text>
@@ -1629,20 +1633,14 @@
<assertion id="ea">
<text>For class X which is extended _directly_ by the bean class of a
_managed_ bean Y, if X declares a _non-static producer field_ x then Y does not inherit
this field unless Y is explicitly declared to specialize X.</text>
+ <note>We don't test session beans, as they can't have non-static
producer fields</note>
</assertion>
- <assertion id="eb">
- <text>For class X which is extended _directly_ by the bean class of a
_session_ bean Y, if X declares a _non-static producer field_ x then Y does not inherit
this field unless Y is explicitly declared to specialize X.</text>
- </assertion>
-
<assertion id="ec">
<text>For class X which is extended _indirectly_ by the bean class of a
_managed_ bean Y, if X declares a _non-static producer field_ x then Y does not inherit
this field unless Y is explicitly declared to specialize X.</text>
+ <note>We don't test session beans, as they can't have non-static
producer fields</note>
</assertion>
- <assertion id="ed">
- <text>For class X which is extended _indirectly_ by the bean class of a
_session_ bean Y, if X declares a _non-static producer field_ x then Y does not inherit
this field unless Y is explicitly declared to specialize X.</text>
- </assertion>
-
<assertion id="f">
<text>If X is a generic type, and an injection point declared by X is
inherited by Y, and the declared type of the injection point contains type variables
declared by X, the type of the injection point inherited in Y is the declared type, after
substitution of actual type arguments declared by Y or any intermediate class that is a
subclass of X and a superclass of Y.</text>
</assertion>