Skip to content

Commit

Permalink
new tip
Browse files Browse the repository at this point in the history
  • Loading branch information
Gavin King committed Nov 16, 2009
1 parent 7a20343 commit b55bd8f
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
4 changes: 2 additions & 2 deletions reference/en-US/beans.xml
Expand Up @@ -250,11 +250,11 @@ public class CreditCardPaymentProcessor
<!--
<tip>
<para>
If you're expectng more than one bean to satisfy the contract, you can inject an <literal>Instance</literal>,
If you're expecting more than one bean to satisfy the contract, you can inject an <literal>Instance</literal>,
object which let's you iterate over all the beans which satisfy the contract. For example, we can iterate
over all our implementations of <literal>PaymentProcessor</literal> using:
</para>
<programlisting>@Inject void init(@Any Instance&lt;PaymentProcessor&gt; paymentProcessorInstance) {
<programlisting role="JAVA">@Inject void init(@Any Instance&lt;PaymentProcessor&gt; paymentProcessorInstance) {
for (PaymentProcessor pp: paymentProcessorInstance) { ... }
}</programlisting>
</tip>
Expand Down
19 changes: 19 additions & 0 deletions reference/en-US/injection.xml
Expand Up @@ -261,6 +261,25 @@ PaymentProcessor getPaymentProcessor(@Synchronous PaymentProcessor syncPaymentPr
may be multiple alterative implementations of <literal>@Asynchronous PaymentProcessor</literal>!
</para>

</section>

<section>
<title>The built-in qualifiers <literal>@Default</literal> and <literal>@Any</literal></title>

<para>Whenever a bean or injection point does not explicitly declare a qualifier, the container assumes the
qualifier <literal>@Default</literal>. From time to time, you'll need to decare an injection point without
specifying a qualifier. There's a qualifier for that too. All beans have the qualifier <literal>@Any</literal>.</para>

<tip>
<para>This is especially useful if you want to iterate over all beans with a certain bean type. For example:</para>
<programlisting role="JAVA"><![CDATA[@Inject
void initServices(@Any Instance<Service> services) {
for (Service service: services) {
service.init();
}
}]]></programlisting>
</tip>

</section>

<section>
Expand Down
2 changes: 1 addition & 1 deletion reference/en-US/scopescontexts.xml
Expand Up @@ -37,7 +37,7 @@
which just doesn't map naturally to the model used in CDI. Therefore, we recommend against treating entities
as CDI beans. You're certainly going to run into problems if you try to give an entity a scope other than
the default scope <literal>@Dependent</literal>. The client proxy will get in the way if you try to pass
an injected instance to the JPA |EntityManager|.
an injected instance to the JPA <literal>EntityManager</literal>.
</para>
</tip>

Expand Down

0 comments on commit b55bd8f

Please sign in to comment.