Skip to content

Commit

Permalink
minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Gavin King committed Nov 3, 2009
1 parent ecb3d45 commit 664adf7
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions reference/en-US/intro.xml
Expand Up @@ -38,17 +38,17 @@
With very few exceptions, almost every concrete Java class that has a constructor with no parameters (or a
constructor designated with the annotation <literal>@Inject</literal>) is a bean. This includes every
JavaBean and every EJB session bean. If you've already got some JavaBeans or session beans lying around,
they're already beans&mdash;you won't need any additional special metadata. There's just little one thing you
they're already beans&#8212;you won't need any additional special metadata. There's just little one thing you
need to do before you can start injecting them into stuff: you need to put them in an archive (a jar, or a
Java EE module such as a war or EJB jar) that contains a special marker file: <literal>META-INF/beans.xml</literal>.
</para>

<para>
The JavaBeans and EJBs you've been writing every day, up until now, have not been able to take advantage
of the new services defined by the CDI specification. But you'll be able to use every one of them with
CDI&mdash;allowing the container to create and destroy instances of your beans and associate them with a
CDI&#8212;allowing the container to create and destroy instances of your beans and associate them with a
designed context, injecting them into other beans, using them in EL expressions, specializing them with
qualifier annotations, even adding interceptors and decorators to them&mdash;without modifying your
qualifier annotations, even adding interceptors and decorators to them&#8212;without modifying your
existing code. At most, you'll need to add some annotations.
</para>

Expand Down Expand Up @@ -541,23 +541,25 @@ public class ShoppingCart { ... }]]></programlisting>
<para>
We've already seen how qualifiers let us choose between multiple implementations of an interface at
development time. But sometimes we have an interface whose implementation varies dependending upon
the deployment environment. For example, you may want to use a mock implementation in a testing
the deployment environment. For example, we may want to use a mock implementation in a testing
environment. An <emphasis>alternative</emphasis> may be declared by annotating the bean class or
producer method or field with the <literal>@Alternative</literal> annotation.
</para>

<programlisting role="JAVA"><![CDATA[@Alternative
public class MockPaymentProcessor extends PaymentProcessorImpl { ... }]]></programlisting>

<para>
You can choose between alternatives at deployment time by selecting an alternative using the CDI
deployment descriptor <literal>META-INF/beans.xml</literal> of the jar or Java EE module that
uses it.
We normally annotate a bean <literal>@Alternative</literal> only when there is some other
implementation of some interface it implements. We can choose between alternatives at deployment time
by <emphasis>selecting</emphasis> an alternative using the CDI deployment descriptor
<literal>META-INF/beans.xml</literal> of the jar or Java EE module that uses it. Different modules
can specify that they use different alternatives.
</para>

<para>
Details on how to enable alternative beans, and how you can use them to specialize (override) beans and
producer methods is covered in <xref linkend="3"/>.
Details on how to enable alternative beans, and how you can use them to specialize (override) beans
and producer methods is covered in <xref linkend="3"/>.
</para>

</section>
Expand Down Expand Up @@ -619,7 +621,7 @@ public class ShoppingCart { ... }]]></programlisting>
</section>

<section>
<title>What kinds of classes can be beans?</title>
<title>What kinds of classes are beans?</title>

<para>
We've already seen that JavaBeans and EJBs can be (CDI) beans. Is that the whole story? Let's start from what
Expand Down

0 comments on commit 664adf7

Please sign in to comment.