From weld-commits at lists.jboss.org Tue Nov 10 01:29:17 2009
Content-Type: multipart/mixed; boundary="===============2187895246077787424=="
MIME-Version: 1.0
From: weld-commits at lists.jboss.org
To: weld-commits at lists.jboss.org
Subject: [weld-commits] Weld SVN: r4944 - doc/trunk/reference/en-US.
Date: Tue, 10 Nov 2009 01:29:16 -0500
Message-ID: <200911100629.nAA6TG87027681@svn01.web.mwc.hst.phx2.redhat.com>
--===============2187895246077787424==
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: quoted-printable
Author: gavin.king(a)jboss.com
Date: 2009-11-10 01:29:16 -0500 (Tue, 10 Nov 2009)
New Revision: 4944
Modified:
doc/trunk/reference/en-US/injection.xml
doc/trunk/reference/en-US/specialization.xml
Log:
fallout from reorg
Modified: doc/trunk/reference/en-US/injection.xml
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- doc/trunk/reference/en-US/injection.xml 2009-11-10 05:59:22 UTC (rev 49=
43)
+++ doc/trunk/reference/en-US/injection.xml 2009-11-10 06:29:16 UTC (rev 49=
44)
@@ -315,14 +315,51 @@
=
+}]]>
=
=
+ =
+
+ Alternatives
+ =
+ Alternatives are beans whose implementation is specific to a p=
articular client module or deployment
+ scenario. This alternative defines a mock implementation of both @Synchronous PaymentProcessor
+ and @Asynchronous PaymentProcessor, all in one:=
para>
+ =
+
+ =
+
+ By default, @Alternative beans are disabled. W=
e need to enable an
+ alternative in the beans.xml descriptor of a b=
ean archive to make it available for
+ instantiation and injection. This activation only applies to the =
beans in that archive.
+
=
+
+
+ org.mycompany.mock.MockPaymentProcessor
+
+]]>
+ =
+
+ When an ambiguous dependency exists at an injection point, the co=
ntainer attempts to resolve the ambiguity
+ by looking for an enabled alternative among the beans that could =
be injected. If there is exactly one
+ enabled alternative, that's the bean that will be injected.
+
+ =
+
+
- Fixing unsatisfied dependencies
+ Fixing unsatisfied and ambiguous dependencies
=
The typesafe resolution algorithm fails when, after considering t=
he qualifier annotations on all beans that
Modified: doc/trunk/reference/en-US/specialization.xml
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- doc/trunk/reference/en-US/specialization.xml 2009-11-10 05:59:22 UTC (r=
ev 4943)
+++ doc/trunk/reference/en-US/specialization.xml 2009-11-10 06:29:16 UTC (r=
ev 4944)
@@ -47,68 +47,53 @@
alternatives and then show the guarantees that specialization adds.
=
-
- Alternatives
+
+ Using alternative stereotypes
=
CDI lets you override the implementation of =
a bean type at deployment time using an
- alternative. For example, the following bean provides an implemen=
tation of the
- PaymentProcessor bean type in the default envi=
ronment:
+ alternative. For example, the following bean provides a default i=
mplementation of the =
+ PaymentProcessor interface:
=
-
=
- But in our staging environment, we override that implementation o=
f PaymentProcessor with a
- different bean:
+ But in our staging environment, we don't really want to submit pa=
yments to the external system, so we override =
+ that implementation of PaymentProcessor with a=
different bean:
=
-
=
or
=
-
=
- By default, @Alternative beans are disabled. W=
e need to enable the
- alternative—effectively replacing the bean implementation w=
ithout the @Alternative
- annotation—in the beans.xml descriptor o=
f a bean archive by specifying the bean
- class (or the class that contains the alternative producer method=
or field). This activation only applies =
- to the beans in that archive.
+ We've already seen how we can enable this alternative by listing =
its class in the beans.xml
+ descriptor.
=
-
-
- org.mycompany.myapp.StagingCreditCardProcessor
-
-]]>
-
- Of course, if the goal is to enable all the alternatives for the =
staging environment, it would make much more
- sense to make @Staging an @Alternativ=
e stereotype and annotate the
- staging beans with this stereotype instead. You'll see how this l=
evel of indirection pays off. First, we create
- the stereotype:
+ But suppose we have many alternatives in the staging environment.=
It would be much more convenient to be able
+ to enable them all at once. So let's make @Staging an @Alternative stereotype =
+ and annotate the staging beans with this stereotype instead. You'=
ll see how this level of indirection pays off. =
+ First, we create the stereotype:
=
-
@@ -117,14 +102,14 @@
Then we replace the @Alternative annotation on=
our bean with @Staging:
=
-
=
- Finally, we activate the @Staging stereotype i=
n the beans.xml descriptor:
+ Finally, we activate the @Staging stereotype i=
n the beans.xml descriptor:
=
]]>
=
- Now, no matter how many staging beans we have, they will all be e=
nabled at once. Does that mean the default
- implementation is disabled? Well, not exactly. If the default imp=
lementation has a qualifier, for instance
- @LargeTransaction, and the alternative does no=
t, you could still inject the default
- implementation.
+ Now, no matter how many staging beans we have, they will all be e=
nabled at once. =
+ =
+
+ =
+
+ A minor problem with alternatives
+ =
+
+ When we enable an alternative, does that mean the default impleme=
ntation is disabled? Well, not exactly. If the =
+ default implementation has a qualifier, for instance @La=
rgeTransaction, and the alternative =
+ does not, you could still inject the default implementation.
+
=
-
+
=
- So we haven't completely replaced the default implementation in t=
his deployment of the system. The only
- way one bean can completely override a second bean at all injecti=
on points is if it implements all the bean
- types and declares all the qualifiers of the second bean. However=
, if the second bean declares a producer
- method or observer method, then even this is not enough to ensure=
that the second bean is never called! We need
- something extra.
+ So we haven't completely replaced the default implementation in t=
his deployment of the system. The only way one =
+ bean can completely override a second bean at all injection point=
s is if it implements all the bean types and =
+ declares all the qualifiers of the second bean. However, if the s=
econd bean declares a producer method or =
+ observer method, then even this is not enough to ensure that the =
second bean is never called! We need something =
+ extra.
=
@@ -160,6 +153,7 @@
these traps. Specialization is a way of informing the system of y=
our intent to completely replace and disable
an implementation of a bean.
+ =
=
--===============2187895246077787424==--