Weld SVN: r4847 - cdi-tck/trunk/impl/src/main/resources.
by weld-commits@lists.jboss.org
Author: shane.bryzak(a)jboss.com
Date: 2009-11-09 04:31:51 -0500 (Mon, 09 Nov 2009)
New Revision: 4847
Modified:
cdi-tck/trunk/impl/src/main/resources/tck-audit-cdi.xml
Log:
audit corrections for chapter 6 and 7
Modified: cdi-tck/trunk/impl/src/main/resources/tck-audit-cdi.xml
===================================================================
--- cdi-tck/trunk/impl/src/main/resources/tck-audit-cdi.xml 2009-11-09 09:16:38 UTC (rev 4846)
+++ cdi-tck/trunk/impl/src/main/resources/tck-audit-cdi.xml 2009-11-09 09:31:51 UTC (rev 4847)
@@ -3031,7 +3031,7 @@
</assertion>
<assertion id="p">
- <text>The context object is responsible for destroying any contextual instance it creates by passing the instance to the |destroy()| method of the Contextual object representing the contextual type.</text>
+ <text>The context object is responsible for destroying any contextual instance it creates by passing the instance to the |destroy()| method of the |Contextual| object representing the contextual type.</text>
</assertion>
<assertion id="q">
@@ -3116,7 +3116,7 @@
</group>
<assertion id="dg">
- <text>Any instance of the bean injected into method parameters of a disposer method or observer method exists to service the method invocation only (except for observer methods of container lifecycle events).</text>
+ <text>When a bean id declared to have |@Dependent| scope, any instance of the bean injected into method parameters of a disposer method or observer method exists to service the method invocation only (except for observer methods of container lifecycle events).</text>
</assertion>
<assertion id="e">
@@ -3278,11 +3278,11 @@
</assertion>
<assertion id="a">
- <text>If the bean has a normal scope and the given bean type cannot be proxied by the container, as defined in Section 5.5.1, "Unproxyable bean types", the container throws an |UnproxyableResolutionException|.</text>
+ <text>If the bean has a normal scope and the given bean type cannot be proxied by the container, as defined in Section 5.4.1, "Unproxyable bean types", the container throws an |UnproxyableResolutionException|.</text>
</assertion>
<assertion id="b">
- <text>If the bean has a normal scope, then the contextual reference for the bean is a client proxy, as defined in Section 5.5, "Client proxies", created by the container, that implements the given bean type and all bean types of the bean which are Java interfaces.</text>
+ <text>If the bean has a normal scope, then the contextual reference for the bean is a client proxy, as defined in Section 5.4, "Client proxies", created by the container, that implements the given bean type and all bean types of the bean which are Java interfaces.</text>
</assertion>
<assertion id="c">
@@ -3355,7 +3355,7 @@
</group>
<group>
- <text>A producer method is passivation capable if and only if it never returns a value which is not passivation capable at runtime. A producer method with a primitive return type or a return type that implements or extends serializable is passivation capable. A producer method with a return type that is declared |final| and does not implement |Serializable| is not passivation capable.</text>
+ <text>A producer method is passivation capable if and only if it never returns a value which is not passivation capable at runtime. A producer method with a primitive return type or a return type that implements or extends |Serializable| is passivation capable. A producer method with a return type that is declared |final| and does not implement |Serializable| is not passivation capable.</text>
<assertion id="caa">
<text>Test that a producer method with a primitive return type is passivation capable.</text>
@@ -3863,7 +3863,7 @@
</assertion>
<assertion id="m">
- <text>The long-running conversation context associated with a request that results in a JSF redirect (via a navigation rule) is automatically propagated to the resulting non-faces request, and to any other subsequent request to the same URL. This is accomplished via use of a GET request parameter named cid containing the unique identifier of the conversation.</text>
+ <text>The long-running conversation context associated with a request that results in a JSF redirect (via a navigation rule) is automatically propagated to the resulting non-faces request, and to any other subsequent request to the same URL. This is accomplished via use of a GET request parameter named |cid| containing the unique identifier of the conversation.</text>
</assertion>
<assertion id="n">
@@ -3893,11 +3893,11 @@
</assertion>
<assertion id="tb">
- <text>If the propagated conversation cannot be restored, the container must associate the request with a new transient conversation and throw an exception of type |javax.context.NonexistentConversationException| from the restore view phase of the JSF lifecycle. The application may handle this exception using the JSF |ExceptionHandler|.</text>
+ <text>If the propagated conversation cannot be restored, the container must associate the request with a new transient conversation and throw an exception of type |javax.enterprise.context.NonexistentConversationException| from the restore view phase of the JSF lifecycle. The application may handle this exception using the JSF |ExceptionHandler|.</text>
</assertion>
<assertion id="ua">
- <text>The container ensures that a long-running conversation may be associated with at most one request at a time, by blocking or rejecting concurrent requests. If the container rejects a request, it must associate the request with a new transient conversation and throw an exception of type |javax.context.BusyConversationException| from the restore view phase of the JSF lifecycle. The application may handle this exception using the JSF |ExceptionHandler|.</text>
+ <text>The container ensures that a long-running conversation may be associated with at most one request at a time, by blocking or rejecting concurrent requests. If the container rejects a request, it must associate the request with a new transient conversation and throw an exception of type |javax.enterprise.context.BusyConversationException| from the restore view phase of the JSF lifecycle. The application may handle this exception using the JSF |ExceptionHandler|.</text>
</assertion>
</section>
@@ -3930,7 +3930,7 @@
</assertion>
<assertion id="l">
- <text>|getId()| returns the identifier of the current long-running conversation, or a null value of the current conversation is transient.</text>
+ <text>|getId()| returns the identifier of the current long-running conversation, or a null value if the current conversation is transient.</text>
</assertion>
<assertion id="m">
@@ -4074,11 +4074,11 @@
<section id="7.3.1" title="Lifecycle of managed beans">
<assertion id="aa">
- <text>When the |create()| method of the |Bean| object that represents a managed bean is called, the container obtains an instance of the bean, as defined by the Managed Beans specification, calling the bean constructor as defined by Section 5.6.3, "Injection using the bean constructor", and performing dependency injection as defined in Section 5.6.4, "Injection of fields and initializer methods".</text>
+ <text>When the |create()| method of the |Bean| object that represents a managed bean is called, the container obtains an instance of the bean, as defined by the Managed Beans specification, calling the bean constructor as defined by Section 5.5.1, "Injection using the bean constructor", and performing dependency injection as defined in Section 5.5.2, "Injection of fields and initializer methods".</text>
</assertion>
<assertion id="ba">
- <text>When the |destroy()| method is called, the container destroys the instance, as defined by the Managed Beans specification, and any dependent objects, as defined in Section 5.6.5, "Destruction of dependent objects".</text>
+ <text>When the |destroy()| method is called, the container destroys the instance, as defined by the Managed Beans specification, and any dependent objects, as defined in Section 5.5.3, "Destruction of dependent objects".</text>
</assertion>
</section>
@@ -4113,7 +4113,7 @@
<section id="7.3.4" title="Lifecycle of producer methods">
<assertion id="ea">
- <text>When the create() method of a |Bean| object that represents a producer method is called, the container must invoke the producer method as defined by Section 5.6.6, "Invocation of producer or disposer methods". The return value of the producer method, after method interception completes, is the new contextual instance to be returned by |Bean.create()|.</text>
+ <text>When the create() method of a |Bean| object that represents a producer method is called, the container must invoke the producer method as defined by Section 5.5.4, "Invocation of producer or disposer methods". The return value of the producer method, after method interception completes, is the new contextual instance to be returned by |Bean.create()|.</text>
</assertion>
<assertion id="k">
@@ -4125,17 +4125,17 @@
</assertion>
<assertion id="ma">
- <text>When the |destroy()| method is called, and if there is a disposer method for this producer method, the container must invoke the disposer method as defined by Section 5.6.6, "Invocation of producer or disposer methods", passing the instance given to |destroy()| to the disposed parameter.</text>
+ <text>When the |destroy()| method is called, and if there is a disposer method for this producer method, the container must invoke the disposer method as defined by Section 5.5.4, "Invocation of producer or disposer methods", passing the instance given to |destroy()| to the disposed parameter.</text>
</assertion>
<assertion id="r">
- <text>Finally, the container destroys dependent objects, as defined in Section 5.6.5, "Destruction of dependent objects".</text>
+ <text>Finally, the container destroys dependent objects, as defined in Section 5.5.3, "Destruction of dependent objects".</text>
</assertion>
</section>
<section id="7.3.5" title="Lifecycle of producer fields">
<assertion id="ga">
- <text>When the |create()| method of a |Bean| object that represents a producer field is called, the container must access the producer field as defined by Section 5.6.7, "Access to producer field values" to obtain the current value of the field. The value of the producer field is the new contextual instance to be returned by |Bean.create()|.</text>
+ <text>When the |create()| method of a |Bean| object that represents a producer field is called, the container must access the producer field as defined by Section 5.5.5, "Access to producer field values" to obtain the current value of the field. The value of the producer field is the new contextual instance to be returned by |Bean.create()|.</text>
</assertion>
<assertion id="m">
16 years, 5 months
Weld SVN: r4846 - in cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/interceptors/tests/lifecycleCallback: exceptions and 1 other directory.
by weld-commits@lists.jboss.org
Author: jharting
Date: 2009-11-09 04:16:38 -0500 (Mon, 09 Nov 2009)
New Revision: 4846
Added:
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/interceptors/tests/lifecycleCallback/exceptions/
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/interceptors/tests/lifecycleCallback/exceptions/Goat.java
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/interceptors/tests/lifecycleCallback/exceptions/GoatInterceptor.java
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/interceptors/tests/lifecycleCallback/exceptions/LifecycleCallbackInterceptorExceptionTest.java
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/interceptors/tests/lifecycleCallback/exceptions/Sheep.java
Log:
Tests for lifecycle callback interceptor methods.
Added: cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/interceptors/tests/lifecycleCallback/exceptions/Goat.java
===================================================================
--- cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/interceptors/tests/lifecycleCallback/exceptions/Goat.java (rev 0)
+++ cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/interceptors/tests/lifecycleCallback/exceptions/Goat.java 2009-11-09 09:16:38 UTC (rev 4846)
@@ -0,0 +1,14 @@
+package org.jboss.jsr299.tck.interceptors.tests.lifecycleCallback.exceptions;
+
+import javax.annotation.PostConstruct;
+import javax.interceptor.Interceptors;
+
+(a)Interceptors(GoatInterceptor.class)
+class Goat
+{
+ @PostConstruct
+ public void postConstruct()
+ {
+ throw new IllegalStateException();
+ }
+}
Added: cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/interceptors/tests/lifecycleCallback/exceptions/GoatInterceptor.java
===================================================================
--- cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/interceptors/tests/lifecycleCallback/exceptions/GoatInterceptor.java (rev 0)
+++ cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/interceptors/tests/lifecycleCallback/exceptions/GoatInterceptor.java 2009-11-09 09:16:38 UTC (rev 4846)
@@ -0,0 +1,30 @@
+package org.jboss.jsr299.tck.interceptors.tests.lifecycleCallback.exceptions;
+
+import javax.annotation.PostConstruct;
+import javax.interceptor.InvocationContext;
+
+class GoatInterceptor
+{
+ private static boolean exceptionCaught = false;
+
+ @PostConstruct
+ public void postConstruct(InvocationContext ctx)
+ {
+ try
+ {
+ ctx.proceed();
+ }
+ catch (IllegalStateException ise)
+ {
+ exceptionCaught = true;
+ }
+ catch (Exception e)
+ {
+ }
+ }
+
+ public static boolean isExceptionCaught()
+ {
+ return exceptionCaught;
+ }
+}
Added: cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/interceptors/tests/lifecycleCallback/exceptions/LifecycleCallbackInterceptorExceptionTest.java
===================================================================
--- cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/interceptors/tests/lifecycleCallback/exceptions/LifecycleCallbackInterceptorExceptionTest.java (rev 0)
+++ cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/interceptors/tests/lifecycleCallback/exceptions/LifecycleCallbackInterceptorExceptionTest.java 2009-11-09 09:16:38 UTC (rev 4846)
@@ -0,0 +1,48 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.jsr299.tck.interceptors.tests.lifecycleCallback.exceptions;
+
+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.testng.annotations.Test;
+
+
+@Artifact
+@SpecVersion(spec = "int", version = "3.1.PFD")
+public class LifecycleCallbackInterceptorExceptionTest extends AbstractJSR299Test
+{
+ @Test(expectedExceptions = RuntimeException.class)
+ @SpecAssertion(section = "5.2", id = "a")
+ public void testPostConstructCanThrowRuntimeException()
+ {
+ getInstanceByType(Sheep.class);
+ }
+
+ @Test
+ @SpecAssertions( {
+ @SpecAssertion(section = "5.2", id = "c"),
+ @SpecAssertion(section = "5.2", id = "d")
+ })
+ public void testLifecycleCallbackInterceptorCanCatchException()
+ {
+ getInstanceByType(Goat.class);
+ assert GoatInterceptor.isExceptionCaught();
+ }
+}
Added: cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/interceptors/tests/lifecycleCallback/exceptions/Sheep.java
===================================================================
--- cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/interceptors/tests/lifecycleCallback/exceptions/Sheep.java (rev 0)
+++ cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/interceptors/tests/lifecycleCallback/exceptions/Sheep.java 2009-11-09 09:16:38 UTC (rev 4846)
@@ -0,0 +1,12 @@
+package org.jboss.jsr299.tck.interceptors.tests.lifecycleCallback.exceptions;
+
+import javax.annotation.PostConstruct;
+
+class Sheep
+{
+ @PostConstruct
+ public void postConstruct()
+ {
+ throw new RuntimeException();
+ }
+}
16 years, 5 months
Weld SVN: r4845 - doc/trunk/reference/en-US.
by weld-commits@lists.jboss.org
Author: gavin.king(a)jboss.com
Date: 2009-11-09 04:06:30 -0500 (Mon, 09 Nov 2009)
New Revision: 4845
Modified:
doc/trunk/reference/en-US/injection.xml
Log:
various revisions
Modified: doc/trunk/reference/en-US/injection.xml
===================================================================
--- doc/trunk/reference/en-US/injection.xml 2009-11-09 09:01:22 UTC (rev 4844)
+++ doc/trunk/reference/en-US/injection.xml 2009-11-09 09:06:30 UTC (rev 4845)
@@ -385,25 +385,73 @@
</para>
<para>
- To fix an <literal>UnsatisfiedDependencyException</literal>, simply provide a bean which implements the bean
- type and has all the qualifier types of the injection point — or explicitly enable an
- <literal>@Alternative</literal> bean that implements the bean type and has the appropriate qualifier types.
+ To fix an <literal>UnsatisfiedDependencyException</literal>, either:
</para>
-
+
+ <itemizedlist>
+ <listitem>
+ <para>
+ create a bean which implements the bean type and has all the qualifier types of the injection point,
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ make sure that the bean you already have is in the classpath of the module with the injection point, or
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ explicitly enable an <literal>@Alternative</literal> bean that implements the bean type and has the
+ appropriate qualifier types, using <literal>beans.xml</literal>.
+ </para>
+ </listitem>
+ </itemizedlist>
+
<para>
- To fix an <literal>AmbiguousDependencyException</literal>, introduce a qualifier to distinguish between the two
- implementations of the bean type, or disable one of two <literal>@Alternative</literal> beans that are trying
- to occupy the same space. An <literal>AmbiguousDependencyException</literal> can only occur if two enabled
- beans share the same qualifier types (and one bean does not specialize the other, which we'll get into
- in <xref linkend="specialization"/>).
+ To fix an <literal>AmbiguousDependencyException</literal>, either:
</para>
+
+ <itemizedlist>
+ <listitem>
+ <para>
+ introduce a qualifier to distinguish between the two implementations of the bean type,
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ disable one of the beans by annotating it <literal>@Alternative</literal>,
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ move one of the implementations to a module that is not in the classpath of the module with the
+ injection point, or
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ disable one of two <literal>@Alternative</literal> beans that are trying to occupy the same space,
+ using <literal>beans.xml</literal>.
+ </para>
+ </listitem>
+ </itemizedlist>
+
+ <para>
+ An <literal>AmbiguousDependencyException</literal> can only occur if two enabled beans share the same
+ qualifier types.
+ </para>
<tip>
<para>Just remember: "There can be only one."</para>
</tip>
+
+ <para>
+ On the other hand, if you really do have an optional or multivalued injection point, you should change
+ the type of your injection point to <literal>Instance</literal>, as we'll see in <xref linkend="lookup"/>.
+ </para>
<para>
- There's one more issue you need to be aware of when using dependency injection in beans: client proxies.
+ There's one more issue you need to be aware of when using the dependency injection service: client proxies.
</para>
</section>
@@ -413,7 +461,7 @@
<para>
Clients of an injected bean do not usually hold a direct reference to a bean instance, unless the bean is
- dependent-scoped—in that case, the instance belongs to the bean.
+ a dependent object (scope <literal>@Dependent</literal>).
</para>
<para>
@@ -447,9 +495,10 @@
</note>
<para>
- Unfortunately, due to limitations of the Java language, some Java types cannot be proxied by the container. If
- one of these types declares any scope other than <literal>@Dependent</literal>, the container throws an
- <literal>UnproxyableDependencyException</literal> when processing its use as an injection point.
+ Unfortunately, due to limitations of the Java language, some Java types cannot be proxied by the container. If
+ an inection point declared with one of these types resolves to a bean with any scope other than
+ <literal>@Dependent</literal>, the container throws an <literal>UnproxyableDependencyException</literal> at
+ system initialization time.
</para>
<para>The following Java types cannot be proxied by the container:</para>
@@ -471,24 +520,36 @@
<para>
It's usually very easy to fix an <literal>UnproxyableDependencyException</literal>. Simply add a constructor
with no parameters to the injected class, introduce an interface, or, if all else fails, change the scope of
- the injected bean to <literal>@Dependent</literal>. Weld will probably support non-standard ways of getting
- around this depending on what is available on the classpath:
+ the injected bean to <literal>@Dependent</literal>.
</para>
+
+ <note>
+ <para>
+ A future release of Weld will likely support a non-standard workaround for this limitation, using
+ non-portable JVM APIs:
+ </para>
<itemizedlist>
<listitem>
<para>
Sun, IcedTea, Mac: <literal>Unsafe.allocateInstance()</literal> (The most efficient)
</para>
+ </listitem>
+ <listitem>
<para>
- Above + IBM, JRockit: <literal>ReflectionFactory.newConstructorForSerialization()</literal>
+ IBM, JRockit: <literal>ReflectionFactory.newConstructorForSerialization()</literal>
</para>
</listitem>
</itemizedlist>
+
+ <para>
+ But we didn't get around to implementing this yet.
+ </para>
+ </note>
</section>
- <section>
+ <section id="lookup">
<title>Obtaining a contextual instance by programmatic lookup</title>
@@ -527,7 +588,7 @@
of the bean programmatically.
</para>
- <programlisting role="JAVA"><![CDATA[PaymentProcessor p = paymentProcessorSource.get()]]></programlisting>
+ <programlisting role="JAVA"><![CDATA[PaymentProcessor p = paymentProcessorSource.get();]]></programlisting>
<para>
Of course, qualifiers can be specified at the injection point, as with a bean injection:
@@ -536,14 +597,14 @@
<programlisting role="JAVA"><![CDATA[@Inject @Asynchronous Instance<PaymentProcessor> paymentProcessorSource;]]></programlisting>
<para>
- You can also select a bean dynamically from the <literal>Instance</literal> based on the bean's qualifier.
+ You can also select a bean dynamically from the <literal>Instance</literal> by passing the bean's qualifier.
First, you need to add the <literal>@Any</literal> annotation at the injection point:
</para>
<programlisting role="JAVA"><![CDATA[@Inject @Any Instance<PaymentProcessor> paymentProcessorSource;]]></programlisting>
<para>
- Then you specify which bean you want, based on its qualifier, using the <literal>select()</literal> method on
+ Then you specify which bean you want, by passing its qualifier to the <literal>select()</literal> method of
<literal>Instance</literal>. You represent a qualifier annotation in code by subclassing the helper class
<literal>AnnotationLiteral</literal>, since it's otherwise difficult to instantiate an annotation type in Java.
</para>
@@ -570,7 +631,7 @@
</para>
<para>
- Here's how you might make use the dynamic selection:
+ Here's how you might make use of dynamic selection:
</para>
<programlisting><![CDATA[Annotation qualifier = synchronously ?
@@ -583,24 +644,20 @@
<title>Bean names and EL lookup</title>
<para>
- You won't always be able to take advantage of the type safety that CDI provides. One of those places is the JSF
- view. To accommodate that environment, CDI must learn to speak the binding language that view templates
- understand. That language is the Unified EL.
+ You won't always be able to take advantage of the typesafety that CDI provides. Sometimes your Java
+ code needs to be called from some other language that doesn't support the Java type system. For example,
+ to bind your beans to a JSF view or JSP page, you need to be able to refer to them in a Unified EL
+ expression.
</para>
<para>
- In order to participate in the Unified EL, a bean must have a name. The old way of assigning a name to a
- managed bean was in the faces-config.xml descriptor. This use of XML completely contradicts the approach
- to metadata that's in CDI. Given that one of the primary goals of JSR-299 is to get JSF talking
- with session beans (and, in turn, the rest of the Java EE platform), CDI needed to find a compromise.
- It did in the form of the <literal>@Named</literal>.
+ Theres only one way to identity a bean in Unified EL: with a name. The old way of assigning a name to a
+ managed bean was the <literal>faces-config.xml</literal> descriptor. This use of XML completely
+ contradicts the approach to metadata that's used in CDI. Given that one of the goals of JSR-299 was to get
+ JSF talking with session beans (and, in turn, the rest of the Java EE platform), CDI needed to find a
+ different approach. The <literal>@Named</literal> annotation assigns a string-based EL name to a bean.
</para>
- <para>
- The <literal>@Named</literal> annotation, when added to a bean class, producer method or producer field,
- gives an alternate way for that bean to be referenced—by a string-based name.
- </para>
-
<programlisting role="JAVA"><![CDATA[public @Named("cart") @SessionScoped
class ShoppingCart implements Serializable {
...
16 years, 5 months
Weld SVN: r4844 - in cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/interceptors/tests: lifecycleCallback and 1 other directory.
by weld-commits@lists.jboss.org
Author: jharting
Date: 2009-11-09 04:01:22 -0500 (Mon, 09 Nov 2009)
New Revision: 4844
Added:
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/interceptors/tests/lifecycleCallback/
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/interceptors/tests/lifecycleCallback/Chicken.java
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/interceptors/tests/lifecycleCallback/Goat.java
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/interceptors/tests/lifecycleCallback/GoatInterceptor.java
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/interceptors/tests/lifecycleCallback/LifecycleCallbackInterceptorTest.java
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/interceptors/tests/lifecycleCallback/PackagePrivateLifecycleInterceptor.java
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/interceptors/tests/lifecycleCallback/PrivateLifecycleInterceptor.java
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/interceptors/tests/lifecycleCallback/ProtectedLifecycleInterceptor.java
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/interceptors/tests/lifecycleCallback/PublicLifecycleInterceptor.java
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/interceptors/tests/lifecycleCallback/Sheep.java
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/interceptors/tests/lifecycleCallback/SheepInterceptor.java
Log:
Tests for lifecycle callback interceptor methods.
Added: cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/interceptors/tests/lifecycleCallback/Chicken.java
===================================================================
--- cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/interceptors/tests/lifecycleCallback/Chicken.java (rev 0)
+++ cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/interceptors/tests/lifecycleCallback/Chicken.java 2009-11-09 09:01:22 UTC (rev 4844)
@@ -0,0 +1,9 @@
+package org.jboss.jsr299.tck.interceptors.tests.lifecycleCallback;
+
+import javax.interceptor.Interceptors;
+
+@Interceptors( { PublicLifecycleInterceptor.class, ProtectedLifecycleInterceptor.class, PackagePrivateLifecycleInterceptor.class, PrivateLifecycleInterceptor.class })
+class Chicken
+{
+
+}
Added: cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/interceptors/tests/lifecycleCallback/Goat.java
===================================================================
--- cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/interceptors/tests/lifecycleCallback/Goat.java (rev 0)
+++ cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/interceptors/tests/lifecycleCallback/Goat.java 2009-11-09 09:01:22 UTC (rev 4844)
@@ -0,0 +1,39 @@
+package org.jboss.jsr299.tck.interceptors.tests.lifecycleCallback;
+
+import javax.annotation.PostConstruct;
+import javax.annotation.PreDestroy;
+import javax.interceptor.Interceptors;
+
+(a)Interceptors(GoatInterceptor.class)
+class Goat
+{
+ private static boolean postConstructInterceptorCalled = false;
+ private static boolean preDestroyInterceptorCalled = false;
+
+ @PostConstruct
+ public void postConstruct()
+ {
+ postConstructInterceptorCalled = true;
+ }
+
+ public String echo(String message)
+ {
+ return message;
+ }
+
+ @PreDestroy
+ public void preDestroy()
+ {
+ preDestroyInterceptorCalled = true;
+ }
+
+ public static boolean isPostConstructInterceptorCalled()
+ {
+ return postConstructInterceptorCalled;
+ }
+
+ public static boolean isPreDestroyInterceptorCalled()
+ {
+ return preDestroyInterceptorCalled;
+ }
+}
Added: cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/interceptors/tests/lifecycleCallback/GoatInterceptor.java
===================================================================
--- cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/interceptors/tests/lifecycleCallback/GoatInterceptor.java (rev 0)
+++ cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/interceptors/tests/lifecycleCallback/GoatInterceptor.java 2009-11-09 09:01:22 UTC (rev 4844)
@@ -0,0 +1,55 @@
+package org.jboss.jsr299.tck.interceptors.tests.lifecycleCallback;
+
+import javax.annotation.PostConstruct;
+import javax.annotation.PreDestroy;
+import javax.interceptor.AroundInvoke;
+import javax.interceptor.InvocationContext;
+
+class GoatInterceptor
+{
+ private static boolean postConstructInterceptorCalled = false;
+ private static boolean preDestroyInterceptorCalled = false;
+
+ @PostConstruct
+ public void postConstruct(InvocationContext ctx)
+ {
+ postConstructInterceptorCalled = true;
+ try
+ {
+ ctx.proceed();
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+
+ @AroundInvoke
+ public Object intercept(InvocationContext ctx) throws Exception {
+ return ctx.proceed() + ctx.getParameters()[0].toString();
+ }
+
+ @PreDestroy
+ public void preDestroy(InvocationContext ctx)
+ {
+ preDestroyInterceptorCalled = true;
+ try
+ {
+ ctx.proceed();
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+
+ public static boolean isPostConstructInterceptorCalled()
+ {
+ return postConstructInterceptorCalled;
+ }
+
+ public static boolean isPreDestroyInterceptorCalled()
+ {
+ return preDestroyInterceptorCalled;
+ }
+}
Added: cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/interceptors/tests/lifecycleCallback/LifecycleCallbackInterceptorTest.java
===================================================================
--- cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/interceptors/tests/lifecycleCallback/LifecycleCallbackInterceptorTest.java (rev 0)
+++ cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/interceptors/tests/lifecycleCallback/LifecycleCallbackInterceptorTest.java 2009-11-09 09:01:22 UTC (rev 4844)
@@ -0,0 +1,103 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.jsr299.tck.interceptors.tests.lifecycleCallback;
+
+import javax.enterprise.context.spi.CreationalContext;
+import javax.enterprise.inject.spi.Bean;
+
+import org.jboss.jsr299.tck.AbstractJSR299Test;
+import org.jboss.test.audit.annotations.SpecAssertion;
+import org.jboss.test.audit.annotations.SpecVersion;
+import org.jboss.testharness.impl.packaging.Artifact;
+import org.testng.annotations.Test;
+
+@Artifact
+@SpecVersion(spec = "int", version = "3.1.PFD")
+public class LifecycleCallbackInterceptorTest extends AbstractJSR299Test
+{
+ @Test
+ @SpecAssertion(section = "5", id = "a")
+ public void testPostConstructInterceptor()
+ {
+ getInstanceByType(Goat.class);
+ assert Goat.isPostConstructInterceptorCalled();
+ assert GoatInterceptor.isPostConstructInterceptorCalled();
+ }
+
+ @Test(groups = "ri-broken")
+ @SpecAssertion(section = "5", id = "a")
+ // WELD-279
+ public void testPreDestroyInterceptor()
+ {
+ // create the instance
+ Bean<Goat> bean = getBeans(Goat.class).iterator().next();
+ CreationalContext<Goat> ctx = getCurrentManager().createCreationalContext(bean);
+ Goat instance = (Goat) getCurrentManager().getReference(bean, Goat.class, ctx);
+ // destroy the instance
+ bean.destroy(instance, ctx);
+ assert Goat.isPreDestroyInterceptorCalled();
+ assert GoatInterceptor.isPreDestroyInterceptorCalled();
+ }
+
+ @Test
+ @SpecAssertion(section = "5", id = "c")
+ public void testAroundInvokeAndLifeCycleCallbackInterceptorsCanBeDefinedOnTheSameClass()
+ {
+ assert getInstanceByType(Goat.class).echo("foo").equals("foofoo");
+ }
+
+ @Test
+ @SpecAssertion(section = "5", id = "j")
+ public void testPublicLifecycleInterceptorMethod()
+ {
+ getInstanceByType(Chicken.class);
+ assert PublicLifecycleInterceptor.isIntercepted();
+ }
+
+ @Test
+ @SpecAssertion(section = "5", id = "k")
+ public void testProtectedLifecycleInterceptorMethod()
+ {
+ getInstanceByType(Chicken.class);
+ assert ProtectedLifecycleInterceptor.isIntercepted();
+ }
+
+ @Test
+ @SpecAssertion(section = "5", id = "l")
+ public void testPrivateLifecycleInterceptorMethod()
+ {
+ getInstanceByType(Chicken.class);
+ assert PrivateLifecycleInterceptor.isIntercepted();
+ }
+
+ @Test
+ @SpecAssertion(section = "5", id = "m")
+ public void testPackagePrivateLifecycleInterceptorMethod()
+ {
+ getInstanceByType(Chicken.class);
+ assert PackagePrivateLifecycleInterceptor.isIntercepted();
+ }
+
+ @Test
+ @SpecAssertion(section = "8", id = "c")
+ public void testLifeCycleCallbackInterceptorNotInvokedForMethodLevelInterceptor()
+ {
+ assert getInstanceByType(Sheep.class).foo().equals("bar");
+ assert SheepInterceptor.isAroundInvokeCalled();
+ assert !SheepInterceptor.isPostConstructCalled();
+ }
+}
Added: cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/interceptors/tests/lifecycleCallback/PackagePrivateLifecycleInterceptor.java
===================================================================
--- cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/interceptors/tests/lifecycleCallback/PackagePrivateLifecycleInterceptor.java (rev 0)
+++ cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/interceptors/tests/lifecycleCallback/PackagePrivateLifecycleInterceptor.java 2009-11-09 09:01:22 UTC (rev 4844)
@@ -0,0 +1,28 @@
+package org.jboss.jsr299.tck.interceptors.tests.lifecycleCallback;
+
+import javax.annotation.PostConstruct;
+import javax.interceptor.InvocationContext;
+
+class PackagePrivateLifecycleInterceptor
+{
+ private static boolean intercepted = false;
+
+ @PostConstruct
+ void postConstruct(InvocationContext ctx)
+ {
+ intercepted = true;
+ try
+ {
+ ctx.proceed();
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException();
+ }
+ }
+
+ public static boolean isIntercepted()
+ {
+ return intercepted;
+ }
+}
Added: cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/interceptors/tests/lifecycleCallback/PrivateLifecycleInterceptor.java
===================================================================
--- cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/interceptors/tests/lifecycleCallback/PrivateLifecycleInterceptor.java (rev 0)
+++ cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/interceptors/tests/lifecycleCallback/PrivateLifecycleInterceptor.java 2009-11-09 09:01:22 UTC (rev 4844)
@@ -0,0 +1,28 @@
+package org.jboss.jsr299.tck.interceptors.tests.lifecycleCallback;
+
+import javax.annotation.PostConstruct;
+import javax.interceptor.InvocationContext;
+
+class PrivateLifecycleInterceptor
+{
+ private static boolean intercepted = false;
+
+ @PostConstruct
+ private void postConstruct(InvocationContext ctx)
+ {
+ intercepted = true;
+ try
+ {
+ ctx.proceed();
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException();
+ }
+ }
+
+ public static boolean isIntercepted()
+ {
+ return intercepted;
+ }
+}
Added: cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/interceptors/tests/lifecycleCallback/ProtectedLifecycleInterceptor.java
===================================================================
--- cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/interceptors/tests/lifecycleCallback/ProtectedLifecycleInterceptor.java (rev 0)
+++ cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/interceptors/tests/lifecycleCallback/ProtectedLifecycleInterceptor.java 2009-11-09 09:01:22 UTC (rev 4844)
@@ -0,0 +1,28 @@
+package org.jboss.jsr299.tck.interceptors.tests.lifecycleCallback;
+
+import javax.annotation.PostConstruct;
+import javax.interceptor.InvocationContext;
+
+class ProtectedLifecycleInterceptor
+{
+ private static boolean intercepted = false;
+
+ @PostConstruct
+ protected void postConstruct(InvocationContext ctx)
+ {
+ intercepted = true;
+ try
+ {
+ ctx.proceed();
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException();
+ }
+ }
+
+ public static boolean isIntercepted()
+ {
+ return intercepted;
+ }
+}
Added: cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/interceptors/tests/lifecycleCallback/PublicLifecycleInterceptor.java
===================================================================
--- cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/interceptors/tests/lifecycleCallback/PublicLifecycleInterceptor.java (rev 0)
+++ cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/interceptors/tests/lifecycleCallback/PublicLifecycleInterceptor.java 2009-11-09 09:01:22 UTC (rev 4844)
@@ -0,0 +1,28 @@
+package org.jboss.jsr299.tck.interceptors.tests.lifecycleCallback;
+
+import javax.annotation.PostConstruct;
+import javax.interceptor.InvocationContext;
+
+class PublicLifecycleInterceptor
+{
+ private static boolean intercepted = false;
+
+ @PostConstruct
+ void postConstruct(InvocationContext ctx)
+ {
+ intercepted = true;
+ try
+ {
+ ctx.proceed();
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException();
+ }
+ }
+
+ public static boolean isIntercepted()
+ {
+ return intercepted;
+ }
+}
Added: cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/interceptors/tests/lifecycleCallback/Sheep.java
===================================================================
--- cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/interceptors/tests/lifecycleCallback/Sheep.java (rev 0)
+++ cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/interceptors/tests/lifecycleCallback/Sheep.java 2009-11-09 09:01:22 UTC (rev 4844)
@@ -0,0 +1,12 @@
+package org.jboss.jsr299.tck.interceptors.tests.lifecycleCallback;
+
+import javax.interceptor.Interceptors;
+
+class Sheep
+{
+ @Interceptors(SheepInterceptor.class)
+ public String foo()
+ {
+ return "bar";
+ }
+}
Added: cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/interceptors/tests/lifecycleCallback/SheepInterceptor.java
===================================================================
--- cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/interceptors/tests/lifecycleCallback/SheepInterceptor.java (rev 0)
+++ cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/interceptors/tests/lifecycleCallback/SheepInterceptor.java 2009-11-09 09:01:22 UTC (rev 4844)
@@ -0,0 +1,34 @@
+package org.jboss.jsr299.tck.interceptors.tests.lifecycleCallback;
+
+import javax.annotation.PostConstruct;
+import javax.interceptor.AroundInvoke;
+import javax.interceptor.InvocationContext;
+
+class SheepInterceptor
+{
+ private static boolean postConstructCalled = false;
+ private static boolean aroundInvokeCalled = false;
+
+ @PostConstruct
+ public void postConstruct()
+ {
+ postConstructCalled = true;
+ }
+
+ @AroundInvoke
+ public Object aroundInvoke(InvocationContext ctx) throws Exception
+ {
+ aroundInvokeCalled = true;
+ return ctx.proceed();
+ }
+
+ public static boolean isPostConstructCalled()
+ {
+ return postConstructCalled;
+ }
+
+ public static boolean isAroundInvokeCalled()
+ {
+ return aroundInvokeCalled;
+ }
+}
\ No newline at end of file
16 years, 5 months
Weld SVN: r4843 - doc/trunk/reference/en-US.
by weld-commits@lists.jboss.org
Author: gavin.king(a)jboss.com
Date: 2009-11-09 03:21:52 -0500 (Mon, 09 Nov 2009)
New Revision: 4843
Modified:
doc/trunk/reference/en-US/injection.xml
Log:
tip
Modified: doc/trunk/reference/en-US/injection.xml
===================================================================
--- doc/trunk/reference/en-US/injection.xml 2009-11-09 08:17:16 UTC (rev 4842)
+++ doc/trunk/reference/en-US/injection.xml 2009-11-09 08:21:52 UTC (rev 4843)
@@ -336,15 +336,17 @@
<title>Qualifiers on producer methods</title>
<para>
- Even producer methods may specify qualifier annotations:
+ Even producer methods may specify qualifiers:
</para>
<programlisting role="JAVA"><![CDATA[@Produces @Asynchronous PaymentProcessor getPaymentProcessor() { ... }]]></programlisting>
- <para>
- This producer might create an asynchronous implementation powered by third party library such as Quartz
- (though definitely check out the new scheduler support in EJB 3.1!).
- </para>
+ <tip>
+ <para>
+ If we really need to create beans with asynchronous semantics, EJB 3.1 asynchronous methods are an
+ excellent solution.
+ </para>
+ </tip>
</section>
16 years, 5 months
Weld SVN: r4842 - doc/trunk/reference/en-US.
by weld-commits@lists.jboss.org
Author: gavin.king(a)jboss.com
Date: 2009-11-09 03:17:16 -0500 (Mon, 09 Nov 2009)
New Revision: 4842
Modified:
doc/trunk/reference/en-US/injection.xml
Log:
improve
Modified: doc/trunk/reference/en-US/injection.xml
===================================================================
--- doc/trunk/reference/en-US/injection.xml 2009-11-09 08:14:52 UTC (rev 4841)
+++ doc/trunk/reference/en-US/injection.xml 2009-11-09 08:17:16 UTC (rev 4842)
@@ -279,9 +279,9 @@
<para>
Annotations can have members just like regular classes. We can use members to further discriminate the
- qualifier. This prevents a potential explosion of new annotations. For instance, if you wanted to create
- several qualifiers representing different payment methods, you could aggregate them into a single annotation
- using a member:
+ qualifier. This prevents a potential explosion of new annotations. For example, instead of creating
+ several qualifiers representing different payment methods, we could aggregate them into a single annotation
+ with a member:
</para>
<programlisting role="JAVA"><![CDATA[@Qualifier
@@ -292,13 +292,13 @@
}]]></programlisting>
<para>
- Then you select one of the possible values when you apply the qualifier:
+ Then we select one of the possible member values when appling the qualifier:
</para>
<programlisting role="JAVA"><![CDATA[private @Inject @PayBy(CHECK) CheckPayment checkPayment;]]></programlisting>
<para>
- You can tell the container to ignore a member of a qualifier type by annotating the member <literal>@NonBinding</literal>.
+ We can force the container to ignore a member of a qualifier type by annotating the member <literal>@NonBinding</literal>.
</para>
<programlisting role="JAVA"><![CDATA[@Qualifier
16 years, 5 months
Weld SVN: r4841 - doc/trunk/reference/en-US.
by weld-commits@lists.jboss.org
Author: gavin.king(a)jboss.com
Date: 2009-11-09 03:14:52 -0500 (Mon, 09 Nov 2009)
New Revision: 4841
Modified:
doc/trunk/reference/en-US/injection.xml
Log:
annotation members are definitely not fields.
Modified: doc/trunk/reference/en-US/injection.xml
===================================================================
--- doc/trunk/reference/en-US/injection.xml 2009-11-09 08:12:43 UTC (rev 4840)
+++ doc/trunk/reference/en-US/injection.xml 2009-11-09 08:14:52 UTC (rev 4841)
@@ -278,10 +278,10 @@
<title>Qualifiers with members</title>
<para>
- Annotations can have members (i.e., fields) just like regular classes. You can use these fields to further
- discriminate the qualifier. This prevents a potential explosion of new annotations.
- For instance, if you wanted to create several qualifiers representing different payment methods, you could
- aggregate them under a single annotation using a member:
+ Annotations can have members just like regular classes. We can use members to further discriminate the
+ qualifier. This prevents a potential explosion of new annotations. For instance, if you wanted to create
+ several qualifiers representing different payment methods, you could aggregate them into a single annotation
+ using a member:
</para>
<programlisting role="JAVA"><![CDATA[@Qualifier
16 years, 5 months
Weld SVN: r4840 - doc/trunk/reference/en-US.
by weld-commits@lists.jboss.org
Author: gavin.king(a)jboss.com
Date: 2009-11-09 03:12:43 -0500 (Mon, 09 Nov 2009)
New Revision: 4840
Modified:
doc/trunk/reference/en-US/injection.xml
Log:
remove vague statements
Modified: doc/trunk/reference/en-US/injection.xml
===================================================================
--- doc/trunk/reference/en-US/injection.xml 2009-11-09 08:10:57 UTC (rev 4839)
+++ doc/trunk/reference/en-US/injection.xml 2009-11-09 08:12:43 UTC (rev 4840)
@@ -274,11 +274,6 @@
implementation.
</para>
- <para>
- Qualifiers will likely replace use of the factory pattern as well. The container becomes your factory and
- the switch between implementations is dictated by the qualifier.
- </para>
-
<section>
<title>Qualifiers with members</title>
16 years, 5 months
Weld SVN: r4839 - doc/trunk/reference/en-US.
by weld-commits@lists.jboss.org
Author: gavin.king(a)jboss.com
Date: 2009-11-09 03:10:57 -0500 (Mon, 09 Nov 2009)
New Revision: 4839
Modified:
doc/trunk/reference/en-US/injection.xml
Log:
minor revisions
Modified: doc/trunk/reference/en-US/injection.xml
===================================================================
--- doc/trunk/reference/en-US/injection.xml 2009-11-09 07:52:52 UTC (rev 4838)
+++ doc/trunk/reference/en-US/injection.xml 2009-11-09 08:10:57 UTC (rev 4839)
@@ -14,9 +14,9 @@
<title>Where you can <literal>@Inject</literal></title>
<para>
- Injection points are declared using the JSR-330 annotation, <literal>@Inject</literal>, along with an optional set of
- qualifiers annotations. CDI supports three primary mechanisms for dependency injection during bean
- construction:
+ Injection points are declared using the JSR-330 annotation, <literal>@Inject</literal>, along with an
+ optional set of qualifier annotations. CDI supports three primary mechanisms for dependency injection
+ during bean construction:
</para>
<para>
@@ -57,8 +57,8 @@
<note>
<para>
- A bean can have multiple initializer methods. If the bean is a session bean, the initializer method is not
- required to be a business method of the session bean.
+ A bean can have multiple initializer methods. If the bean is a session bean, the initializer method
+ is not required to be a business method of the session bean.
</para>
</note>
@@ -80,6 +80,7 @@
<para>
Dependency injection always occurs when the bean instance is first instantiated by the container.
+ Simplifying just a little, things happen in this order:
</para>
<itemizedlist>
@@ -96,8 +97,8 @@
</listitem>
<listitem>
<para>
- Next, the container calls all initializer methods of bean (the call order is not portable, don't rely on
- it).
+ Next, the container calls all initializer methods of bean (the call order is not portable, don't
+ rely on it).
</para>
</listitem>
<listitem>
@@ -106,6 +107,9 @@
</para>
</listitem>
</itemizedlist>
+
+ <para>(The only complication is that the container might call initializer methods declared by a superclass
+ before initializing injected fields declared by a subclass.)</para>
<tip>
<para>
@@ -115,18 +119,18 @@
<para>
Bean constructors, initializer methods and injected fields must be annotated <literal>@Inject</literal>. The
- parameters of bean constructors and initializers are injection points, which means the container will search out
- beans matching the bean type and qualifier and pass them in as arguments.
+ parameters of bean constructors and initializers are injection points, which means the container will search
+ out beans matching the bean type and qualifiers and pass them in as arguments.
</para>
<para>
- If a parameter of bean constructors and initializer methods is not explicitly annotated with a qualifier, the
- default qualifier, <literal>@Default</literal>, is applied. The same is goes for an injected field.
+ If an injected field or a parameter of a bean constructor or initializer method is not explicitly annotated
+ with a qualifier, the default qualifier, <literal>@Default</literal>, is assumed.
</para>
<para>
- CDI also supports parameter injection on methods that are invoked by the container. For instance, parameter
- injection is supported for producer methods:
+ CDI also supports parameter injection for some other methods that are invoked by the container. For instance,
+ parameter injection is supported for producer methods:
</para>
<programlisting role="JAVA"><![CDATA[@Produces Checkout createCheckout(ShoppingCart cart) {
@@ -136,7 +140,7 @@
<para>
This is one of the cases where the <literal>@Inject</literal> annotation <emphasis>is not</emphasis> required at
an injection point. Other cases include observer methods (which we'll meet in <xref linkend="events"/>) and
- disposer methods, which also support parameter injection.
+ disposer methods.
</para>
</section>
@@ -159,7 +163,7 @@
<itemizedlist>
<listitem>
<para>
- allow the client to select which implementation it requires using <emphasis>qualifier</emphasis> or
+ allow the client to select which implementation it requires using a <emphasis>qualifier</emphasis> or
</para>
</listitem>
<listitem>
@@ -170,7 +174,7 @@
</listitem>
<listitem>
<para>
- be deployed in different, isolated modules.
+ allow the beans to be isolated into separate modules.
</para>
</listitem>
</itemizedlist>
@@ -183,7 +187,7 @@
<para>
But then, things start to get complicated. Let's explore how the container determines which bean to inject in
- those more advanced cases. We'll start by taking a closer look at qualifiers.
+ more advanced cases. We'll start by taking a closer look at qualifiers.
</para>
</section>
16 years, 5 months
Weld SVN: r4838 - cdi-tck/trunk/impl/src/main/resources.
by weld-commits@lists.jboss.org
Author: shane.bryzak(a)jboss.com
Date: 2009-11-09 02:52:52 -0500 (Mon, 09 Nov 2009)
New Revision: 4838
Modified:
cdi-tck/trunk/impl/src/main/resources/tck-audit-cdi.xml
Log:
audit corrections
Modified: cdi-tck/trunk/impl/src/main/resources/tck-audit-cdi.xml
===================================================================
--- cdi-tck/trunk/impl/src/main/resources/tck-audit-cdi.xml 2009-11-09 07:50:48 UTC (rev 4837)
+++ cdi-tck/trunk/impl/src/main/resources/tck-audit-cdi.xml 2009-11-09 07:52:52 UTC (rev 4838)
@@ -31,6 +31,10 @@
<assertion id="g">
<text>A bean comprises of a bean implementation.</text>
</assertion>
+
+ <assertion id="h" testable="false">
+ <text>A bean may or may not be an alternative.</text>
+ </assertion>
</section>
<section id="2.1" title="Functionality provided by the container to the bean">
@@ -100,7 +104,7 @@
<section id="2.2.2" title="Restricting the bean types of a bean">
<group>
- <text>The bean types of a bean may be restricted by annotating the bean class or producer method or field with the annotation @javax.enterprise.inject.BeanTypes. When a @BeanTypes annotation is explicitly specified, only the types whose classes are explicitly listed using the value member are bean types of the bean.</text>
+ <text>The bean types of a bean may be restricted by annotating the bean class or producer method or field with the annotation |(a)javax.enterprise.inject.Typed|. When a |@Typed| annotation is explicitly specified, only the types whose classes are explicitly listed using the |value| member, together with |java.lang.Object| are bean types of the bean.</text>
<assertion id="a">
<text>Check managed bean</text>
</assertion>
@@ -125,7 +129,7 @@
</group>
<group>
- <text>If a bean class or producer method or field specifies a |@BeanTypes| annotation, and the value member specifies a class which does not correspond to a type in the unrestricted set of bean types of a bean, the container automatically detects the problem and treats it as a definition error.</text>
+ <text>If a bean class or producer method or field specifies a |@Typed| annotation, and the |value| member specifies a class which does not correspond to a type in the unrestricted set of bean types of a bean, the container automatically detects the problem and treats it as a definition error.</text>
<assertion id="j">
<text>Check managed bean</text>
</assertion>
@@ -154,7 +158,7 @@
<section id="2.3.1" title="Built-in qualifier types">
<assertion id="a0">
- <text>Every bean has the built-in qualifier |@Any|, even if it does not explicitly declare this qualifier, except for beans with the built-in qualifier |@New| defined in Section 3.11, "Beans with the @New qualifier".</text>
+ <text>Every bean has the built-in qualifier |@Any|, even if it does not explicitly declare this qualifier, except for the special |@New| qualified beans defined in Section 3.12, "@New qualified beans".</text>
</assertion>
<assertion id="aa">
@@ -348,7 +352,7 @@
<section id="2.5.1" title="Declaring the bean EL name">
<group>
- <text>To specify the EL name of a bean, the |(a)javax.inject.Named| annotation is applied to the bean class or producer method or field.</text>
+ <text>To specify the EL name of a bean, the qualifier |(a)javax.inject.Named| is applied to the bean class or producer method or field.</text>
<assertion id="a">
<text>Test with a bean class.</text>
@@ -371,7 +375,7 @@
<section id="2.5.2" title="Default bean EL names">
<group>
- <text>A default EL name must be assigned by the container when a bean class or producer method or field of a bean declares a |@Named| annotation and no EL name is explicitly specified by the value member.</text>
+ <text>A default EL name must be assigned by the container when a bean class or producer method or field of a bean declares a |@Named| annotation and no EL name is explicitly specified by the |value| member.</text>
<assertion id="a">
<text>Test with a bean class.</text>
@@ -409,11 +413,24 @@
</section>
<section id="2.6.1" title="Declaring an alternative">
- <assertion id="a">
- <text>An alternative may be declared by annotating the bean class with the |@Alternative| annotation.</text>
- </assertion>
<group>
+ <text>An alternative may be declared by annotating the bean class or producer method or field with the |@Alternative| annotation.</text>
+
+ <assertion id="a">
+ <text>Test with a bean class.</text>
+ </assertion>
+
+ <assertion id="ab">
+ <text>Test with a producer method.</text>
+ </assertion>
+
+ <assertion id="ac">
+ <text>Test with a producer field.</text>
+ </assertion>
+ </group>
+
+ <group>
<text>An alternative may be declared by annotating a bean, producer method or producer field with a stereotype that declares an |@Alternative| annotation.</text>
<assertion id="b">
@@ -735,7 +752,7 @@
<section id="3.1.4" title="Specializing a managed bean">
<group>
- <text>If a bean class of a managed bean X is annotated @Specializes, then the bean class of X must directly extend the bean class of another managed bean Y. Then X directly specializes Y, as defined in Section 4.3, "Specialization".</text>
+ <text>If a bean class of a managed bean X is annotated |@Specializes|, then the bean class of X must directly extend the bean class of another managed bean Y. Then X directly specializes Y, as defined in Section 4.3, "Specialization".</text>
<assertion id="aa">
<text>Test that a specializing bean has all its own qualifiers and the qualifiers of the specialized bean.</text>
@@ -922,7 +939,7 @@
</assertion>
<assertion id="f">
- <text>If a producer method returns a null value at runtime, and the producer method declares scope other than |@Dependent|, an |IllegalProductException| is thrown by the container. This restriction allows the container to use a client proxy, as defined in Section 5.5, "Client proxies".</text>
+ <text>If a producer method returns a null value at runtime, and the producer method declares scope other than |@Dependent|, an |IllegalProductException| is thrown by the container. This restriction allows the container to use a client proxy, as defined in Section 5.4, "Client proxies".</text>
</assertion>
<assertion id="ga">
@@ -982,19 +999,19 @@
</assertion>
<assertion id="ba">
- <text>A producer method may specify a scope</text>
+ <text>A producer method may specify a scope.</text>
</assertion>
<assertion id="bb">
- <text>A producer method may specify a name</text>
+ <text>A producer method may specify a name.</text>
</assertion>
<assertion id="bd">
- <text>A producer method may specify stereotypes</text>
+ <text>A producer method may specify stereotypes.</text>
</assertion>
<assertion id="be">
- <text>A producer method may specify a qualifier</text>
+ <text>A producer method may specify qualifiers.</text>
</assertion>
<group>
@@ -1076,7 +1093,7 @@
</assertion>
<assertion id="ba">
- <text>When searching for disposer methods for a producer method, the container considers the type and qualifiers of the disposed parameter. If a disposed parameter resolves to a producer method declared by the same bean class, according to the rules of typesafe resolution defined in Section 5.3 "Typesafe resolution", the container must call this method when destroying an instance returned by that producer method.</text>
+ <text>When searching for disposer methods for a producer method, the container considers the type and qualifiers of the disposed parameter. If a disposed parameter resolves to a producer method declared by the same bean class, according to the rules of typesafe resolution defined in Section 5.2 "Typesafe resolution", the container must call this method when destroying an instance returned by that producer method.</text>
</assertion>
<assertion id="da">
@@ -1098,15 +1115,15 @@
</assertion>
<assertion id="ca">
- <text>If a disposal method is annotated |@Produces|, the container automatically detects the problem and treats it as a definition error.</text>
+ <text>If a disposer method is annotated |@Produces|, the container automatically detects the problem and treats it as a definition error.</text>
</assertion>
<assertion id="da">
- <text>If a disposal method is annotated |@Inject|, the container automatically detects the problem and treats it as a definition error.</text>
+ <text>If a disposer method is annotated |@Inject|, the container automatically detects the problem and treats it as a definition error.</text>
</assertion>
<assertion id="ea">
- <text>If a disposal method has a parameter annotated |@Observes|, the container automatically detects the problem and treats it as a definition error.</text>
+ <text>If a disposer method has a parameter annotated |@Observes|, the container automatically detects the problem and treats it as a definition error.</text>
</assertion>
<assertion id="fa">
@@ -1124,15 +1141,15 @@
<section id="3.3.7" title="Disposer method resolution">
<assertion id="aa">
- <text>When searching for disposer methods for a producer method, the container searches for disposer methods which are declared by the same bean class as the producer method, and for which the disposed parameter resolves to the producer method, according to the typesafe resolution algorithm defined in Section 5.3, "Typesafe resolution".</text>
+ <text>A disposer method is bound to a producer method if the producer method is declared by the same bean class as the disposer method, and the producer method is assignable to the disposed parameter, according to the rules of typesafe resolution defined in Section 5.2, "Typesafe resolution".</text>
</assertion>
<assertion id="ba">
- <text>If there are multiple disposer methods for a single producer method, the container automatically detects the problem and treats it as a definition error, as defined in Section 12.4, "Problems detected automatically by the container".</text>
+ <text>If there are multiple disposer methods for a single producer method, the container automatically detects the problem and treats it as a definition error.</text>
</assertion>
<assertion id="ca">
- <text>If the disposed parameter of a disposer method does not resolve to any producer method declared by the bean class, the container automatically detects the problem and treats it as a definition error, as defined in Section 12.4, "Problems detected automatically by the container".</text>
+ <text>If there is no producer method declared by the bean class that is assignable to the disposed parameter of a dispose method, the container automatically detects the problem and treats it as a definition error.</text>
</assertion>
</section>
@@ -1170,7 +1187,7 @@
</assertion>
<assertion id="e">
- <text>If a producer method contains a null value at runtime, and the producer field declares any other scope, an |IllegalProductException| is thrown by the container. This restriction allows the container to use a client proxy, as defined in Section 5.5, "Client proxies"</text>
+ <text>If a producer method contains a null value at runtime, and the producer field declares any other scope, an |IllegalProductException| is thrown by the container. This restriction allows the container to use a client proxy, as defined in Section 5.4, "Client proxies"</text>
</assertion>
<assertion id="fa">
@@ -1182,15 +1199,15 @@
</assertion>
<assertion id="ga">
- <text>If a producer field type contains a wildcard type parameter the container automatically detects the problem and treats it as a definition error, as defined in Section 12.4, "Problems detected automatically by the container".</text>
+ <text>If a producer field type contains a wildcard type parameter the container automatically detects the problem and treats it as a definition error.</text>
</assertion>
<assertion id="gb">
- <text>If the producer field type is a parameterized type with a type variable, it must have scope |@Dependent|. If a producer field with a parameterized type with a type variable declares any scope other than |@Dependent|, the container automatically detects the problem and treats it as a definition error, as defined in Section 12.4, "Problems detected automatically by the container".</text>
+ <text>If the producer field type is a parameterized type with a type variable, it must have scope |@Dependent|. If a producer field with a parameterized type with a type variable declares any scope other than |@Dependent|, the container automatically detects the problem and treats it as a definition error.</text>
</assertion>
<assertion id="ha">
- <text>If a producer field type is a type variable the container automatically detects the problem and treats it as a definition error, as defined in Section 12.4, "Problems detected automatically by the container".</text>
+ <text>If a producer field type is a type variable the container automatically detects the problem and treats it as a definition error.</text>
</assertion>
<assertion id="i" testable="false">
@@ -1205,11 +1222,11 @@
<section id="3.4.1" title="Bean types of a producer field">
<assertion id="a">
- <text>The bean types of a producer field depend upon the field type. If the field type is an interface, the unrestricted set of bean types contains the field type, all interfaces it extends directly or indirectly and java.lang.Object</text>
+ <text>The bean types of a producer field depend upon the field type. If the field type is an interface, the unrestricted set of bean types contains the field type, all interfaces it extends directly or indirectly and |java.lang.Object|.</text>
</assertion>
<group>
- <text>The bean types of a producer field depend upon the field type. If a field type is primitive or is a Java array type, the unrestricted set of bean types contains exactly two types: the field type and java.lang.Object</text>
+ <text>The bean types of a producer field depend upon the field type. If a field type is primitive or is a Java array type, the unrestricted set of bean types contains exactly two types: the field type and |java.lang.Object|.</text>
<assertion id="ba">
<text>Check primitive type</text>
</assertion>
@@ -1311,6 +1328,14 @@
<assertion id="hh">
<text>The bean type and qualifiers of the resource are determined by the producer field declaration.</text>
</assertion>
+
+ <assertion id="i">
+ <text>If the producer field declaration specifies an EL name, the container automatically detects the problem and treats it as a definition error.</text>
+ </assertion>
+
+ <assertion id="j">
+ <text>If the matching object in the Java EE component environment is not of the same type as the producer field declaration, the container automatically detects the problem and treats it as a definition errors.</text>
+ </assertion>
</section>
@@ -1353,7 +1378,7 @@
</assertion>
<assertion id="e">
- <text>If a Java EE component class has an injection point of type |UserTransaction| and qualifier |@Default|, and may not validly make use of the JTA |UserTransaction| according to the Java EE platform specification, the container automatically detects the problem and treats it as a definition error, as defined in Section 12.4, "Problems detected automatically by the container".</text>
+ <text>If a Java EE component class has an injection point of type |UserTransaction| and qualifier |@Default|, and may not validly make use of the JTA |UserTransaction| according to the Java EE platform specification, the container automatically detects the problem and treats it as a definition error.</text>
</assertion>
</section>
@@ -1374,22 +1399,21 @@
</assertion>
</group>
-
<assertion id="ba">
<text>If a bean class does not explicitly declare a constructor using |@Inject|, the constructor that accepts no parameters is the bean constructor.</text>
<note>Can't check implicit constructor</note>
</assertion>
<assertion id="ca">
- <text>If a bean class has more than one constructor annotated |@Inject|, the container automatically detects the problem and treats it as a definition error, as defined in Section 12.4, "Problems detected automatically by the container".</text>
+ <text>If a bean class has more than one constructor annotated |@Inject|, the container automatically detects the problem and treats it as a definition error.</text>
</assertion>
<assertion id="da">
- <text>If a bean constructor has a parameter annotated |@Disposes|, the container automatically detects the problem and treats it as a definition error, as defined in Section 12.4, "Problems detected automatically by the container".</text>
+ <text>If a bean constructor has a parameter annotated |@Disposes|, the container automatically detects the problem and treats it as a definition error.</text>
</assertion>
<assertion id="ea">
- <text>If a bean constructor has a parameter annotated |@Observes|, the container automatically detects the problem and treats it as a definition error, as defined in Section 12.4, "Problems detected automatically by the container".</text>
+ <text>If a bean constructor has a parameter annotated |@Observes|, the container automatically detects the problem and treats it as a definition error.</text>
</assertion>
<assertion id="f">
@@ -1428,6 +1452,10 @@
<assertion id="aa">
<text>An injected field may be declared by annotating the field |(a)javax.inject.Inject|.</text>
</assertion>
+
+ <assertion id="b">
+ <text>If an injected field is annotated |@Produces|, the container automatically detects the problem and treats it as a definition error.</text>
+ </assertion>
</section>
<section id="3.9" title="Initializer methods">
@@ -1454,10 +1482,6 @@
<assertion id="e">
<text>If the bean is a session bean, the initializer method is not required to be a business method of the session bean.</text>
</assertion>
-
- <assertion id="ea">
- <text>A generic method may not be an initializer method.</text>
- </assertion>
<assertion id="f">
<text>Method interceptors are never called when the container calls an initializer method</text>
@@ -1479,19 +1503,19 @@
</assertion>
<assertion id="ab">
- <text>If a generic method of a bean is annotated |@Inject|, the container automatically detects the problem and treats it as a definition error, as defined in Section 12.4, "Problems detected automatically by the container".</text>
+ <text>If a generic method of a bean is annotated |@Inject|, the container automatically detects the problem and treats it as a definition error.</text>
</assertion>
<assertion id="ba">
- <text>If an initializer method is annotated |@Produces|, the container automatically detects the problem and treats it as a definition error, as defined in Section 12.4, "Problems detected automatically by the container".</text>
+ <text>If an initializer method is annotated |@Produces|, the container automatically detects the problem and treats it as a definition error.</text>
</assertion>
<assertion id="ca">
- <text>If an initializer method has a parameter annotated |@Disposes|, the container automatically detects the problem and treats it as a definition error, as defined in Section 12.4, "Problems detected automatically by the container".</text>
+ <text>If an initializer method has a parameter annotated |@Disposes|, the container automatically detects the problem and treats it as a definition error.</text>
</assertion>
<assertion id="da">
- <text>If an initializer method has a parameter annotated |@Observes|, the container automatically detects the problem and treats it as a definition error, as defined in Section 12.4, "Problems detected automatically by the container".</text>
+ <text>If an initializer method has a parameter annotated |@Observes|, the container automatically detects the problem and treats it as a definition error.</text>
</assertion>
<assertion id="e">
@@ -1511,11 +1535,11 @@
<section id="3.11" title="The qualifier @Named at injection points">
<assertion id="a">
- <text>If an injected field declares a |@Named| annotation that does not specify the value member, the name of the field is assumed.</text>
+ <text>If an injected field declares a |@Named| annotation that does not specify the |value| member, the name of the field is assumed.</text>
</assertion>
<assertion id="b">
- <text>If any other injection point declares a |@Named| annotation that does not specify the value member, the container automatically detects the problem and treats it as a definition error, as defined in Section 12.4, "Problems detected automatically by the container".</text>
+ <text>If any other injection point declares a |@Named| annotation that does not specify the |value| member, the container automatically detects the problem and treats it as a definition error.</text>
</assertion>
</section>
@@ -1613,7 +1637,7 @@
</assertion>
<group>
- <text>Note that this second bean exists, and may be enabled and available for injection even if the first bean is disabled, as defined by Section 5.2.2, “Enabled and disabled beans” or if the bean class is deployed outside of a bean deployment archive, as defined in Section 12.1, “Bean deployment archives”, and is therefore not discovered during the bean discovery process defined in Chapter 12, Packaging and deployment. The container discovers |@New| qualified beans by inspecting injection points of other enabled beans.</text>
+ <text>Note that this second bean exists, and may be enabled and available for injection even if the first bean is disabled, as defined by Section 5.1.2, “Enabled and disabled beans” or if the bean class is deployed outside of a bean deployment archive, as defined in Section 12.1, “Bean deployment archives”, and is therefore not discovered during the bean discovery process defined in Chapter 12, Packaging and deployment. The container discovers |@New| qualified beans by inspecting injection points of other enabled beans.</text>
<assertion id="ya">
<text>Check that @New on a field injection point outside the BDA, but in the classpath causes a bean with qualifier @New and the given type to be created</text>
</assertion>
@@ -2025,9 +2049,13 @@
<section id="5" title="Dependency injection, lookup, and EL">
<assertion id="b">
- <text>The container is required to support circularities in the bean dependency graph.</text>
+ <text>The container is required to support circularities in the bean dependency graph where at least one bean participating in every circular chain of dependencies has a normal scope, as defined in Section 6.3, "Normal scopes and pseudo-scopes".</text>
<note>The RI has unit tests for this atm</note>
</assertion>
+
+ <assertion id="c" testable="false">
+ <text>The container is not required to support circular chains of dependencies where every bean participating in the chain has a pseudo-scope.</text>
+ </assertion>
</section>
<section id="5.1" title="Modularity">
@@ -2048,7 +2076,7 @@
</group>
<assertion id="d">
- <text>An alternative is never available for injection, lookup or EL resolution in a Java EE module or library that is not a bean deployment archive (a module or library with no beans.xml| file.</text>
+ <text>An alternative is never available for injection, lookup or EL resolution in a Java EE module or library that is not a bean deployment archive (a module or library with no |beans.xml| file.</text>
</assertion>
<assertion id="e">
@@ -2094,15 +2122,15 @@
</assertion>
<assertion id="h">
- <text>Each child <class> element must specify the name of a alternative bean class. If there is no class with the specified name, or if the class with the specified name is not an alternative bean class, the container automatically detects the problem and treats it as a deployment problem, as defined in Section 12.4, "Problems detected automatically by the container".</text>
+ <text>Each child |<class>| element must specify the name of a alternative bean class. If there is no class with the specified name, or if the class with the specified name is not an alternative bean class, the container automatically detects the problem and treats it as a deployment problem.</text>
</assertion>
<assertion id="i">
- <text>Each child <stereotype> element must specify the name of a |@Alternative| stereotype annotation. If there is no annotation with the specified name, or the annotation is not a |@Alternative| stereotype, the container automatically detects the problem and treats it as a deployment problem, as defined in Section 12.4, "Problems detected automatically by the container".</text>
+ <text>Each child |<stereotype>| element must specify the name of a |@Alternative| stereotype annotation. If there is no annotation with the specified name, or the annotation is not a |@Alternative| stereotype, the container automatically detects the problem and treats it as a deployment problem.</text>
</assertion>
<assertion id="j">
- <text>If the same type is listed twice under the <alternatives> element, the container automatically detects the problem and treats it as a deployment problem, as defined in Section 12.4, "Problems detected automatically by the container".</text>
+ <text>If the same type is listed twice under the |<alternatives>| element, the container automatically detects the problem and treats it as a deployment problem.</text>
</assertion>
<assertion id="k">
@@ -2112,20 +2140,20 @@
<section id="5.1.2" title="Enabled and disabled beans">
<assertion id="a" testable="false">
- <text>A bean is said to be enabled if it is deployed in a bean deployment archive, as defined by Section 12.1, "Bean deployment archives", and it is not a producer method or field of a disabled bean, and it is not specialized by any other enabled bean, as defined in Section 4.3, "Specialization", and either it is not an alternative, or it is a selected alternative of at least one bean deployment archive. Otherwise, the bean is said to be disabled.</text>
+ <text>A bean is said to be enabled if it is deployed in a bean deployment archive, and it is not a producer method or field of a disabled bean, and it is not specialized by any other enabled bean, as defined in Section 4.3, "Specialization", and either it is not an alternative, or it is a selected alternative of at least one bean deployment archive. Otherwise, the bean is said to be disabled.</text>
<note>Tested in 5.1.4</note>
</assertion>
</section>
<section id="5.1.3" title="Inconsistent specialization">
<assertion id="a">
- <text>Suppose an enabled bean X specializes a second bean Y. If there is another enabled bean that specializes Y we say that inconsistent specialization exists. The container automatically detects inconsistent specialization and treats it as a deployment problem, as defined in Section 12.4, "Problems detected automatically by the container".</text>
+ <text>Suppose an enabled bean X specializes a second bean Y. If there is another enabled bean that specializes Y we say that inconsistent specialization exists. The container automatically detects inconsistent specialization and treats it as a deployment problem.</text>
</assertion>
</section>
<section id="5.1.4" title="Inter-module injection">
<group>
- <text>A bean is available for injection in a certain Java EE module or library if the bean is not an interceptor or decorator, the bean is enabled, the bean is either not an alternative, or the module or library is a bean deployment archive and the bean is a selected alternative of the bean deployment archive, and the bean class is required to be accessible to classes in the module or library, according to the class loading requirements of the Java EE platform and Java Servlet specifications.</text>
+ <text>A bean is available for injection in a certain module if the bean is not an interceptor or decorator, the bean is enabled, the bean is either not an alternative, or the module is a bean archive and the bean is a selected alternative of the bean archive, and the bean class is required to be accessible to classes in the module, according to the class accessibility requirements of the module architecture.</text>
<assertion id="a">
<text>Check a decorator can not be injected</text>
@@ -2235,7 +2263,7 @@
</group>
<group>
- <text>A bean is assignable to a given injection point if the bean has all the required qualifiers. If no required qualifiers were explicitly specified, the container assumes the required qualifier |@Default|. A bean has the required qualifier if it has a qualifier with (a) the same type and (b) the same annotation member value for each member which is not annotated |(a)javax.enterprise.inject.NonBinding|.</text>
+ <text>A bean is assignable to a given injection point if the bean has all the required qualifiers. If no required qualifiers were explicitly specified, the container assumes the required qualifier |@Default|. A bean has the required qualifier if it has a qualifier with (a) the same type and (b) the same annotation member value for each member which is not annotated |(a)javax.enterprise.util.NonBinding|.</text>
<assertion id="la">
<text>Test with beans with required qualifiers.</text>
@@ -2250,12 +2278,12 @@
</assertion>
<assertion id="ld">
- <text>Test with matching beans with matching qualifier with same annotation member value for each member which is not annotated |(a)javax.enterprise.inject.NonBinding|.</text>
+ <text>Test with matching beans with matching qualifier with same annotation member value for each member which is not annotated |(a)javax.enterprise.util.NonBinding|.</text>
</assertion>
</group>
<assertion id="n">
- <text>A bean is eligible for injection to a certain injection point if it is available for injection in the Java EE module or library that contains the class that declares the injection point, and it is assignable to the injection point.</text>
+ <text>A bean is eligible for injection to a certain injection point if it is available for injection in the module that contains the class that declares the injection point, and it is assignable to the injection point.</text>
</assertion>
<group>
@@ -2273,7 +2301,7 @@
<section id="5.2.1" title="Unsatisfied and ambiguous dependencies">
<assertion id="aa">
- <text>The container must validate all injection points of all enabled beans when the application is initialized to ensure that there are no unsatisfied or ambiguous dependencies. If an unsatisfied or ambiguous dependency exists, the container automatically detects the problem and treats it as a deployment problem, as defined in Section 12.4, "Problems detected automatically by the container".</text>
+ <text>The container must validate all injection points of all enabled beans and of all other Java EE component classes supporting injection when the application is initialized to ensure that there are no unsatisfied or ambiguous dependencies. If an unsatisfied or ambiguous dependency exists, the container automatically detects the problem and treats it as a deployment problem.</text>
<note>These need expanding out - one for each assertion that results in an exception in 5.7.1</note>
</assertion>
@@ -2297,6 +2325,9 @@
</section>
<section id="5.2.3" title="Assignability of raw and parameterized types">
+ <assertion id="a">
+ <text>A parameterized bean type is considered assignable to a raw required type if the raw types are identical and all type parameters of the bean type are either unbounded type variables or |java.lang.Object|.</text>
+ </assertion>
<group>
<text>A parameterized bean type is considered assignable to a parameterized required type if they have identical raw type and for each parameter: the required type parameter and the bean type parameter are actual types with identical raw type, and, if the type is parameterized, the bean type parameter is assignable to the required type parameter according to these rules, or the required type parameter is a wildcard, the bean type parameter is an actual type and the actual type is assignable to the upper bound, if any, of the wildcard and assignable from the lower bound, if any, of the wildcard, or the required type parameter is a wildcard, the bean type parameter is a type variable and the upper bound of the type variable is assignable to or assignable from the upper bound, if any, of the wildcard and assignable from the lower bound, if any, of the wildcard, or the required type parameter is an actual type, the bean type parameter is a type variable and the actual typ!
e is as- signable to the upper bound, if any, of the type variable, or the required type parameter and the bean type parameter are both type variables and the upper bound of the required type parameter is assignable to the upper bound, if any, of the bean type parameter.</text>
@@ -2353,7 +2384,7 @@
</group>
<assertion id="aa">
- <text>If an injection point of primitive type resolves to a bean that may have null values, such as a producer method with a nonprimitive return type or a producer field with a non-primitive type, the container automatically detects the problem and treats it as a deployment problem, as defined in Section 12.4 "Problems detected automatically by the container".</text>
+ <text>If an injection point of primitive type resolves to a bean that may have null values, such as a producer method with a nonprimitive return type or a producer field with a non-primitive type, the container automatically detects the problem and treats it as a deployment problem.</text>
</assertion>
<assertion id="ba">
@@ -2363,7 +2394,7 @@
<section id="5.2.5" title="Qualifier annotations with members">
<assertion id="a" testable="false">
- <text>Qualifier types with members are supported</text>
+ <text>Qualifier types may have annotation members.</text>
<note>A statement of intent</note>
</assertion>
@@ -2372,7 +2403,7 @@
</assertion>
<assertion id="c" testable="false">
- <text>Array-valued or annotation-valued members of a qualifier type must be annotated |@NonBinding| in a portable application. If an array-valued or annotation-valued member of a qualifier is not annotated |@NonBinding|, non-portable behavior results.</text>
+ <text>Array-valued or annotation-valued members of a qualifier type should be annotated |@NonBinding| in a portable application. If an array-valued or annotation-valued member of a qualifier is not annotated |@NonBinding|, non-portable behavior results.</text>
</assertion>
</section>
@@ -2406,11 +2437,11 @@
<section id="5.3.1" title="Ambiguous EL names">
<assertion id="ca">
- <text>An ambiguous EL name exists in an EL expression when there are multiple beans which match the given EL name. When an ambiguous EL name exists, the container attempts to resolve the ambiguity. If any of the beans are alternatives, the container eliminates all beans that are not alternatives. If there is exactly one bean remaining, the container will select this bean, and the ambiguous EL name is called resolvable.</text>
+ <text>An ambiguous EL name exists in an EL expression when an EL name resolves to multiple beans. When an ambiguous EL name exists, the container attempts to resolve the ambiguity. If any of the beans are alternatives, the container eliminates all beans that are not alternatives. If there is exactly one bean remaining, the container will select this bean, and the ambiguous EL name is called resolvable.</text>
</assertion>
<group>
- <text>All unresolvable ambiguous EL names are detected by the container when the application is initialized. Suppose two beans are both accessible to classes in a certain war, according to the class loading requirements of the Java EE platform and Java Servlet specifications. If each bean is either not an alternative, or is a selected alternative of the war, and either the two beans have the same EL name and the name is not resolvable, or the EL name of one bean is of the form |x.y|, where |y| is a valid bean EL name, and |x| is the EL name of the other bean, the container automatically detects the problem and treats it as a deployment problem.</text>
+ <text>All unresolvable ambiguous EL names are detected by the container when the application is initialized. Suppose two beans are both accessible to classes in a certain war, and either the two beans have the same EL name and the name is not resolvable, or the EL name of one bean is of the form |x.y|, where |y| is a valid bean EL name, and |x| is the EL name of the other bean, the container automatically detects the problem and treats it as a deployment problem.</text>
<assertion id="da">
<text>Test with two beans with the same EL name.</text>
@@ -2423,22 +2454,26 @@
</section>
<section id="5.4" title="Client proxies">
- <assertion id="a" testable="false">
- <text>Client proxies are never required for a bean whose scope is a pseudo-scope such as |@Dependent|</text>
+ <assertion id="b">
+ <text>A contextual reference to a bean with a normal scope, as defined in Section 6.3, “Normal scopes and pseudo-scopes”, is not a direct reference to a contextual instance of the bean (the object returned by |Contextual.create()|). Instead, the contextual reference is a client proxy object.</text>
</assertion>
- <assertion id="b">
- <text>A contextual reference to a bean with a normal scope, as defined in Section 6.3, “Normal scopes and pseudo-scopes”, is not a direct reference to a contextual instaContextual.create()textual reference is a client proxy object.</text>
+ <assertion id="a" testable="false">
+ <text>Client proxies are never required for a bean whose scope is a pseudo-scope such as |@Dependent|.</text>
</assertion>
<assertion id="c" implied="true">
<text>Client proxies are serializable</text>
- <note>For "client proxies are may be passivated, even when the bean itself may not be. Therefore the container must use a client proxy whenever a bean with normal scope is injected into a bean with a passivating scope" to hold true the client proxy must be serializable</note>
+ <note>For the statement "Client proxies may be passivated, even when the bean itself may not be. Therefore the container must use a client proxy whenever a bean with normal scope is injected into a bean with a passivating scope" to hold true the client proxy must be serializable.</note>
</assertion>
<assertion id="d">
<text>The container must guarantee that when any valid injected reference to a bean of normal scope is invoked, the invocation is always processed by the current instance of the injected bean.</text>
</assertion>
+
+ <assertion id="e">
+ <text>Client proxies may be shared between multiple injection points.</text>
+ </assertion>
</section>
<section id="5.4.1" title="Unproxyable bean types">
@@ -2540,7 +2575,7 @@
<section id="5.5.1" title="Injection using the bean constructor">
<assertion id="a">
- <text>When the container instantiates a managed bean with a constructor annotated |@Inject|, the container calls this constructor, passing an injectable reference to each parameter. If there is no constructor annotated |@Inject|, the container calls the constructor with no parameters.</text>
+ <text>When the container instantiates a managed bean or session bean with a constructor annotated |@Inject|, the container calls this constructor, passing an injectable reference to each parameter. If there is no constructor annotated |@Inject|, the container calls the constructor with no parameters.</text>
</assertion>
</section>
@@ -2616,7 +2651,7 @@
</group>
<group>
- <text>The container must ensure that: Initializer methods declared by a class X in the type hierarchy of the bean are called after all injected fields declared by X or by superclasses of X have been initialized, and after all Java EE component environment resource dependencies declared by X or by superclasses of X have been injected. Any @PostConstruct callback declared by a class X in the type hierarchy of the bean is called after all initializer meth- ods declared by X or by superclasses of X have been called, after all injected fields declared by X or by superclasses of X have been initialized, and after all Java EE component environment resource dependencies declared by X or by superclasses of X have been injected. Any servlet init() method is called after all initializer methods have been called, all injected fields have been initialized and all Java EE component environment resource dependencies have been injected.</text>
+ <text>The container must ensure that: Initializer methods declared by a class X in the type hierarchy of the bean are called after all injected fields declared by X or by superclasses of X have been initialized, and after all Java EE component environment resource dependencies declared by X or by superclasses of X have been injected. Any |@PostConstruct| callback declared by a class X in the type hierarchy of the bean is called after all initializer meth- ods declared by X or by superclasses of X have been called, after all injected fields declared by X or by superclasses of X have been initialized, and after all Java EE component environment resource dependencies declared by X or by superclasses of X have been injected. Any servlet |init()| method is called after all initializer methods have been called, all injected fields have been initialized and all Java EE component environment resource dependencies have been injected.</text>
<assertion id="ba">
<text>Test session bean initializer methods called after injected field of X</text>
</assertion>
@@ -2676,17 +2711,17 @@
<section id="5.5.3" title="Destruction of dependent objects">
<assertion id="a">
- <text>When the container destroys an instance of a bean or of any Java EE component class supporting injection, the container destroys all dependent objects, as defined in Section 6.4.2, "Dependent object destruction", after the |@PreDestroy| callback completes and after the servlet |destroy()| method is called.</text>
+ <text>When the container destroys an instance of a bean or of any Java EE component class supporting injection, the container destroys all dependent objects, as defined in Section 6.4.2, "Destruction of objects with scope @Dependent", after the |@PreDestroy| callback completes and after the servlet |destroy()| method is called.</text>
</assertion>
</section>
- <section id="5.5.4" title="Invocation of producer or disposal methods">
+ <section id="5.5.4" title="Invocation of producer or disposer methods">
<assertion id="a">
<text>When the container calls a producer method, if the method is static, the container must invoke the method.</text>
</assertion>
<assertion id="b">
- <text>When the container calls a disposal method, if the method is static, the container must invoke the method.</text>
+ <text>When the container calls a disposer method, if the method is static, the container must invoke the method.</text>
</assertion>
<assertion id="c">
@@ -2694,11 +2729,11 @@
</assertion>
<assertion id="d">
- <text>When the container calls a disposal method, if the method is non-static the container must obtain a contextual instance of the most specialized bean, as defined by Section 6.5.2 "Contextual instance of a bean", then invoke the method upon this instance.</text>
+ <text>When the container calls a disposer method, if the method is non-static the container must obtain a contextual instance of the most specialized bean, as defined by Section 6.5.2 "Contextual instance of a bean", then invoke the method upon this instance.</text>
</assertion>
<assertion id="e">
- <text>The container passes an injectable reference to each injected method parameter. The container is also responsible for destroying dependent objects created during this invocation, as defined in Section 6.4.3 "Dependent object destruction".</text>
+ <text>The container passes an injectable reference to each injected method parameter. The container is also responsible for destroying dependent objects created during this invocation, as defined in Section 6.4.2, "Destruction of objects with scope @Dependent".</text>
</assertion>
</section>
@@ -2708,7 +2743,7 @@
</assertion>
<assertion id="b">
- <text>When the container accesses the value of a producer field, if the producer field is non-static, the container must obtain a contextual instance of the most specialized bean, as defined by Section 6.5.2 "Contextual instance of a bean", then access the field value of this instance.</text>
+ <text>When the container accesses the value of a producer field, if the producer field is non-static, the container must obtain a contextual instance of the bean which declares the producer field, as defined by Section 6.5.2 "Contextual instance of a bean", then access the field value of this instance.</text>
</assertion>
</section>
@@ -2726,7 +2761,7 @@
</assertion>
<assertion id="d">
- <text>The container is also responsible for destroying dependent objects created during this invocation, as defined in Section 6.4.2, "Dependent object destruction".</text>
+ <text>The container is also responsible for destroying dependent objects created during this invocation, as defined in Section 6.4.2, "Destruction of objects with scope @Dependent".</text>
</assertion>
</section>
@@ -2800,11 +2835,15 @@
<assertion id="da">
<text>The |@Any| qualifier may be used to allow the application to specify qualifiers dynamically.</text>
</assertion>
+
+ <assertion id="e">
+ <text>The |@New| qualifier may be used, allowing the application to obtain a |@New| qualified bean, as defined in Section 3.12, "@New qualified beans".</text>
+ </assertion>
</section>
<section id="5.6.1" title="The Instance interface">
<assertion id="aa">
- <text>The |Instance| interface provides a method for obtaining instances of beans with a specified combination of required type and qualifiers, and inherites the ability to iterate beans with that combination of required type and qualifiers from |java.lang.Iterable|.</text>
+ <text>The |Instance| interface provides a method for obtaining instances of beans with a specified combination of required type and qualifiers, and inherits the ability to iterate beans with that combination of required type and qualifiers from |java.lang.Iterable|.</text>
</assertion>
<assertion id="ab">
@@ -2823,13 +2862,8 @@
<text>If an instance of an annotation that is not a qualifier type is passed to |select()|, an |IllegalArgumentException| is thrown.</text>
</assertion>
- <assertion id="ea" testable="false">
- <text>If an instance of javax.enterprise.inject.New is passed to select(), non-portable behavior results. Portable applications should not pass qualifiers of type @New to select().</text>
- <note>Describes non-portable behavior</note>
- </assertion>
-
<assertion id="fa">
- <text>The |get()| method must identify a bean that matches the required type and required qualifiers and is accessible to the class into which the parent |Instance| was injected, according to the rules of typesafe resolution, as defined in Section 5.3, "Typesafe resolution" and resolving ambiguities according to Section 5.3.1, "Unsatisfied and ambiguous dependencies".</text>
+ <text>The |get()| method must identify a bean that has the required type and required qualifiers and is eligible for injection into the class into which the parent |Instance| was injected, according to the rules of typesafe resolution, as defined in Section 5.2, "Typesafe resolution", resolving ambiguities according to Section 5.2.1, "Unsatisfied and ambiguous dependencies".</text>
</assertion>
<assertion id="fba">
@@ -2845,7 +2879,7 @@
</assertion>
<assertion id="ja">
- <text>The |iterator()| method must identify the set of beans that match the required type and required qualifiers and are accessible to the class into which the parent |Instance| was injected, according to the rules of typesafe resolution, as defined in Section 5.3, "Typesafe resolution".</text>
+ <text>The |iterator()| method must identify the set of beans that have the required type and required qualifiers and are eligible for injection into the class into which the parent |Instance| was injected, according to the rules of typesafe resolution, as defined in Section 5.2, "Typesafe resolution".</text>
</assertion>
<assertion id="ka">
@@ -2853,11 +2887,11 @@
</assertion>
<assertion id="l">
- <text>The method |isUnsatisfied()| returns true if there is no bean that matches the required type and qualifiers, or false otherwise.</text>
+ <text>The method |isUnsatisfied()| returns |true| if there is no bean that has the required type and qualifiers and is eligible for injection into the class into which the parent |Instance| was injected, or |false| otherwise.</text>
</assertion>
<assertion id="m">
- <text>The method |isAmbiguous()| returns true if there is more than one bean that matches the required type and qualifiers, or false otherwise.</text>
+ <text>The method |isAmbiguous()| returns |true| if there is more than one bean that has the required type and qualifiers and is eligible for injection into the class into which the parent |Instance| was injected, or |false| otherwise.</text>
</assertion>
</section>
@@ -2888,7 +2922,13 @@
</section>
<section id="5.6.3" title="Using AnnotationLiteral and TypeLiteral">
-
+ <assertion id="a" implied="true">
+ <text>Test |javax.enterprise.util.AnnotationLiteral| when using |Instance.select()| to specify qualifiers.</text>
+ </assertion>
+
+ <assertion id="b" implied="true">
+ <text>Test |javax.enterprise.util.TypeLiteral| when specifying a parameterized type with actual type parameters when calling |Instance.select()|.</text>
+ </assertion>
</section>
<section id="6" title="Scopes and contexts">
@@ -4085,7 +4125,7 @@
</assertion>
<assertion id="ma">
- <text>When the |destroy()| method is called, and if there is a disposal method for this producer method, the container must invoke the disposer method as defined by Section 5.6.6, "Invocation of producer or disposal methods", passing the instance given to |destroy()| to the disposed parameter.</text>
+ <text>When the |destroy()| method is called, and if there is a disposer method for this producer method, the container must invoke the disposer method as defined by Section 5.6.6, "Invocation of producer or disposer methods", passing the instance given to |destroy()| to the disposed parameter.</text>
</assertion>
<assertion id="r">
@@ -4267,7 +4307,7 @@
</assertion>
<group>
- <text>A decorator must have exactly one delegate injection point. If a decorator has more than one delegate injection point, or does not have a delegate injection point, the container automatically detects the problem and treats it as a definition error, as defined in Section 12.4, "Problems detected automatically by the container".</text>
+ <text>A decorator must have exactly one delegate injection point. If a decorator has more than one delegate injection point, or does not have a delegate injection point, the container automatically detects the problem and treats it as a definition error.</text>
<assertion id="ca">
<text>Test with more than one delegate injection point.</text>
@@ -4518,11 +4558,11 @@
</assertion>
<assertion id="c">
- <text>All interceptors declared using |@Interceptor| must specify at least one interceptor binding. If an interceptor declared using |@Interceptor| does not declare any interceptor binding, the container automatically detects the problem and treats it as a definition error, as defined in Section 12.4, "Problems detected automatically by the container".</text>
+ <text>All interceptors declared using |@Interceptor| must specify at least one interceptor binding. If an interceptor declared using |@Interceptor| does not declare any interceptor binding, the container automatically detects the problem and treats it as a definition error.</text>
</assertion>
<assertion id="d">
- <text>An interceptor for lifecycle callbacks may only declare interceptor binding types that are defined as |@Target(TYPE)|. If an interceptor for lifecycle callbacks declares an interceptor binding type that is defined |@Target({TYPE, METHOD})|, the container automatically detects the problem and treats it as a definition error, as defined in Section 12.4, "Problems detected automatically by the container".</text>
+ <text>An interceptor for lifecycle callbacks may only declare interceptor binding types that are defined as |@Target(TYPE)|. If an interceptor for lifecycle callbacks declares an interceptor binding type that is defined |@Target({TYPE, METHOD})|, the container automatically detects the problem and treats it as a definition error.</text>
</assertion>
</section>
@@ -6382,7 +6422,7 @@
<section id="12.3" title="Bean discovery">
<assertion id="a" testable="false">
- <text>The container automatically discovers managed beans (according to the rules of Section 3.2.1, "Which Java classes are managed beans?") and session beans in bean deployment archives and searches the bean classes for producer methods, producer fields, disposal methods and observer methods.</text>
+ <text>The container automatically discovers managed beans (according to the rules of Section 3.2.1, "Which Java classes are managed beans?") and session beans in bean deployment archives and searches the bean classes for producer methods, producer fields, disposer methods and observer methods.</text>
<note>Statement of intent</note>
</assertion>
16 years, 5 months