Weld SVN: r4837 - doc/trunk/reference/en-US.
by weld-commits@lists.jboss.org
Author: gavin.king(a)jboss.com
Date: 2009-11-09 02:50:48 -0500 (Mon, 09 Nov 2009)
New Revision: 4837
Modified:
doc/trunk/reference/en-US/injection.xml
Log:
minor revs
Modified: doc/trunk/reference/en-US/injection.xml
===================================================================
--- doc/trunk/reference/en-US/injection.xml 2009-11-09 07:50:27 UTC (rev 4836)
+++ doc/trunk/reference/en-US/injection.xml 2009-11-09 07:50:48 UTC (rev 4837)
@@ -5,7 +5,7 @@
<para>
One of the most significant features of CDI, certainly the most recognized, is dependency injection; but not just
- dependency injection—<emphasis>type-safe</emphasis> dependency injection. In this chapter, you'll learn how
+ dependency injection—<emphasis>typesafe</emphasis> dependency injection. In this chapter, you'll learn how
CDI is able to leverage the Java type system and annotations into a dependency injection strategy that is both
strongly typed and keeps the bean implementation hidden from its clients.
</para>
15 years
Weld SVN: r4836 - doc/trunk/reference/en-US.
by weld-commits@lists.jboss.org
Author: gavin.king(a)jboss.com
Date: 2009-11-09 02:50:27 -0500 (Mon, 09 Nov 2009)
New Revision: 4836
Modified:
doc/trunk/reference/en-US/injection.xml
Log:
minor revs
Modified: doc/trunk/reference/en-US/injection.xml
===================================================================
--- doc/trunk/reference/en-US/injection.xml 2009-11-09 07:50:18 UTC (rev 4835)
+++ doc/trunk/reference/en-US/injection.xml 2009-11-09 07:50:27 UTC (rev 4836)
@@ -5,16 +5,16 @@
<para>
One of the most significant features of CDI, certainly the most recognized, is dependency injection; but not just
- dependency injection, <emphasis>type-safe</emphasis> dependency injection. In this chapter, you'll learn how CDI
- is able to leverage the Java type system and annotations to build a dependency injection strategy that is both
- strongly typed and keeps the implementation hidden from the client.
+ dependency injection—<emphasis>type-safe</emphasis> dependency injection. In this chapter, you'll learn how
+ CDI is able to leverage the Java type system and annotations into a dependency injection strategy that is both
+ strongly typed and keeps the bean implementation hidden from its clients.
</para>
<section>
<title>Where you can <literal>@Inject</literal></title>
<para>
- Injections are declared using the JSR-330 annotation, <literal>@Inject</literal>, along with an optional set of
+ 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:
</para>
@@ -600,7 +600,8 @@
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 {
+ <programlisting role="JAVA"><![CDATA[public @Named("cart") @SessionScoped
+class ShoppingCart implements Serializable {
...
}]]></programlisting>
<programlisting role="JAVA"><![CDATA[public @Produces @Named("items") List<Item> getItems() { ... }]]></programlisting>
15 years
Weld SVN: r4835 - doc/trunk/reference/en-US.
by weld-commits@lists.jboss.org
Author: gavin.king(a)jboss.com
Date: 2009-11-09 02:50:18 -0500 (Mon, 09 Nov 2009)
New Revision: 4835
Modified:
doc/trunk/reference/en-US/intro.xml
Log:
minor revs
Modified: doc/trunk/reference/en-US/intro.xml
===================================================================
--- doc/trunk/reference/en-US/intro.xml 2009-11-09 07:49:40 UTC (rev 4834)
+++ doc/trunk/reference/en-US/intro.xml 2009-11-09 07:50:18 UTC (rev 4835)
@@ -20,7 +20,7 @@
<para>
Prior to Java EE 6, there was no clear definition of the term "bean" in the Java EE platform. Of course,
we've been calling Java classes used in web and enterprise applications "beans" for years. There were even a
- couple of different kinds of things called "beans" in EE specifications, including EJB session beans and JSF
+ couple of different kinds of things called "beans" in EE specifications, including EJB beans and JSF
managed beans. Meanwhile, other third-party frameworks such as Spring and Seam introduced their own ideas of
what it meant to be a "bean". What we've been missing is a common definition.
</para>
@@ -30,7 +30,7 @@
defined as container-managed objects with minimal programming restrictions, otherwise known by the acronym
POJO (Plain Old Java Object). They support a small set of basic services, such as resource injection, lifecycle
callbacks and interceptors. Companion specifications, such as EJB and CDI, build on this basic model. But,
- <emphasis>at last</emphasis>, there is a uniform concept of a bean and a lightweight component model that's
+ <emphasis>at last</emphasis>, there's a uniform concept of a bean and a lightweight component model that's
aligned across the Java EE platform.
</para>
@@ -119,8 +119,8 @@
<para>
As you've guessed, the <literal>@Inject</literal> annotation has something to do with dependency injection!
<literal>@Inject</literal> may be applied to a constructor or method of a bean, and tells the container to
- call that constructor or method when instantiating the bean. The container will inject other beans it finds
- into the parameters of the constructor or method.
+ call that constructor or method when instantiating the bean. The container will inject other beans into the
+ parameters of the constructor or method.
</para>
<para>
@@ -329,7 +329,9 @@
have multiple bean types. For example, the following bean has four bean types:
</para>
- <programlisting role="JAVA"><![CDATA[public class BookShop extends Business implements Shop<Book> {
+ <programlisting role="JAVA"><![CDATA[public class BookShop
+ extends Business
+ implements Shop<Book> {
...
}]]></programlisting>
@@ -346,8 +348,10 @@
</para>
<programlisting role="JAVA"><![CDATA[@Stateful
-public class BookShopBean extends Business implements BookShop, Auditable {
- ...
+public class BookShopBean
+ extends Business
+ implements BookShop, Auditable {
+ ...
}]]></programlisting>
<note>
@@ -365,7 +369,9 @@
</para>
<programlisting role="JAVA"><![CDATA[(a)Typed(Shop.class)
-public class BookShop extends Business implements Shop<Book> {
+public class BookShop
+ extends Business
+ implements Shop<Book> {
...
}]]></programlisting>
@@ -485,8 +491,8 @@
For example, any web application may have <emphasis>session scoped</emphasis> bean:
</para>
- <programlisting role="JAVA"><![CDATA[@SessionScoped
-public class ShoppingCart { ... }]]></programlisting>
+ <programlisting role="JAVA"><![CDATA[public @SessionScoped
+class ShoppingCart implements Serializable { ... }]]></programlisting>
<para>An instance of a session-scoped bean is bound to a user session
and is shared by all requests that execute in the context of that session.</para>
@@ -501,8 +507,8 @@
<para>
If a scope is not explicitly specified, then the bean belongs to a special scope called the
- <emphasis>dependent pseudo-scope</emphasis>. Beans with this scope live to serve the bean into which they
- are injected, which means their lifecycle is bound to the lifecycle of that object.
+ <emphasis>dependent pseudo-scope</emphasis>. Beans with this scope live to serve the object into which they
+ were injected, which means their lifecycle is bound to the lifecycle of that object.
</para>
<para>We'll talk more about scopes in <xref linkend="scopescontexts"/>.</para>
@@ -521,8 +527,8 @@
The EL name is specified using the <literal>@Named</literal> annotation, as shown here:
</para>
- <programlisting role="JAVA"><![CDATA[@SessionScoped @Named("cart")
-public class ShoppingCart { ... }]]></programlisting>
+ <programlisting role="JAVA"><![CDATA[public @SessionScoped @Named("cart")
+class ShoppingCart implements Serializable { ... }]]></programlisting>
<para>Now we can easily use the bean in any JSF or JSP page:</para>
@@ -543,8 +549,8 @@
value of the <literal>@Named</literal> annotation:
</para>
- <programlisting role="JAVA"><![CDATA[@SessionScoped @Named
-public class ShoppingCart { ... }]]></programlisting>
+ <programlisting role="JAVA"><![CDATA[public @SessionScoped @Named
+class ShoppingCart implements Serializable { ... }]]></programlisting>
<para>
The name defaults to the unqualified class name, decapitalized; in this case,
@@ -566,8 +572,8 @@
annotating the bean class with the <literal>@Alternative</literal> annotation.
</para>
- <programlisting role="JAVA"><![CDATA[@Alternative
-public class MockPaymentProcessor extends PaymentProcessorImpl { ... }]]></programlisting>
+ <programlisting role="JAVA"><![CDATA[public @Alternative
+class MockPaymentProcessor extends PaymentProcessorImpl { ... }]]></programlisting>
<para>
We normally annotate a bean <literal>@Alternative</literal> only when there is some other
@@ -622,16 +628,16 @@
The interceptor that implements transaction management declares this annotation:
</para>
- <programlisting role="JAVA"><![CDATA[@Transactional @Interceptor
-public class TransactionInterceptor { ... }]]></programlisting>
+ <programlisting role="JAVA"><![CDATA[public @Transactional @Interceptor
+class TransactionInterceptor { ... }]]></programlisting>
<para>
- We you can apply the interceptor to a bean by annotating to the bean class with the same interceptor
+ We can apply the interceptor to a bean by annotating to the bean class with the same interceptor
binding type:
</para>
- <programlisting role="JAVA"><![CDATA[@SessionScoped @Transactional
-public class ShoppingCart { ... }]]></programlisting>
+ <programlisting role="JAVA"><![CDATA[public @SessionScoped @Transactional
+class ShoppingCart implements Serializable { ... }]]></programlisting>
<para>
Now there's no direct dependency between the two implementations (bean and interceptor). Activation of
@@ -654,8 +660,8 @@
<title>What kinds of classes are beans?</title>
<para>
- We've already seen that JavaBeans and EJB session beans can be (CDI) beans. Is that the whole story? Let's
- start from what we know, and go from there.
+ We've already seen that JavaBeans and EJB session beans can be (CDI) beans. Is that the whole story?
+ Actually, it's just the beginning.
</para>
<section>
@@ -664,7 +670,7 @@
<para>
A managed bean is a Java class. The basic lifecycle and semantics of a managed bean are defined by the
Managed Beans specification. You can explicitly declare a managed bean by annotating the bean class
- <literal>@ManagedBean</literal>, but in CDI you don't need to. According to the specification the CDI
+ <literal>@ManagedBean</literal>, but in CDI you don't need to. According to the specification, the CDI
container treats any class that satisfies the following conditions as a managed bean:
</para>
@@ -810,8 +816,8 @@
</para>
<para>
- On the other hand, don't be scared to use session beans just because you've heard your friends say that
- they're "heavyweight". It's nothing more than supersitition to think that something is "heavier" just
+ On the other hand, don't be scared to use session beans just because you've heard your friends say
+ they're "heavyweight". It's nothing more than superstition to think that something is "heavier" just
because it's hosted natively within the Java EE container, instead of by a proprietary bean container
or dependency injection framework that runs as an additional layer of obfuscation. And as a general
principle, you should be skeptical of folks who use vaguely defined terminology like "heavyweight".
@@ -826,14 +832,14 @@
Not everything that needs to be injected can be boiled down to a bean class instantiated by the container
using <literal>new</literal>. There are plenty of cases where we need additional control. What if we need
to decide at runtime which implementation of a type to instantiate and inject? What if we need to inject an
- object that is obtained by querying a service or transaction resource, for example by executing a JPA query?
+ object that is obtained by querying a service or transactional resource, for example by executing a JPA query?
</para>
<para>
A <emphasis>producer method</emphasis> is a method that acts as a source of bean instances, meaning the
method declaration itself describes the bean and the container invokes the method to obtain an instance of
the bean when no instance exists in the specified context. A producer method lets the application take full
- control of the instantiation process.
+ control of the bean instantiation process.
</para>
<para>
@@ -951,11 +957,11 @@
<para>
Naturally, there is now a slight mismatch with the new style of dependency injection in CDI. Most notably,
- component environment injection relies on a string-based name to qualify an ambiguous type, and there is no
- real consistency as to the nature of that name (sometimes a JNDI name, other times from an XML descriptor
- or even a default name). Producer fields turned out to be an elegant adaptor to reduce all this complexity
- to a common model and get component environment resources to participate in the CDI system just like any
- other kind of bean.
+ component environment injection relies on string-based names to qualify ambiguous types, and there is no
+ real consistency as to the nature of the names (sometimes a JNDI name, other times an identifier from an
+ XML descriptor, or even a default name). Producer fields turned out to be an elegant adaptor to reduce all
+ this complexity to a common model and get component environment resources to participate in the CDI system
+ just like any other kind of bean.
</para>
<para>
15 years
Weld SVN: r4834 - doc/trunk/reference/en-US.
by weld-commits@lists.jboss.org
Author: gavin.king(a)jboss.com
Date: 2009-11-09 02:49:40 -0500 (Mon, 09 Nov 2009)
New Revision: 4834
Modified:
doc/trunk/reference/en-US/part1.xml
Log:
minor revs
Modified: doc/trunk/reference/en-US/part1.xml
===================================================================
--- doc/trunk/reference/en-US/part1.xml 2009-11-09 07:49:15 UTC (rev 4833)
+++ doc/trunk/reference/en-US/part1.xml 2009-11-09 07:49:40 UTC (rev 4834)
@@ -14,8 +14,8 @@
<para>
The <ulink src="http://jcp.org/en/jsr/detail?id=299">JSR-299</ulink> specification (CDI) defines a set of
complementary services that help improve the structure of application code. CDI layers an enhanced lifecycle
- and interaction model over existing Java component types, including managed beans (JavaBeans) and Enterprise
- Java Beans. The CDI services provide:
+ and interaction model over existing Java component types, including managed beans and Enterprise Java Beans.
+ The CDI services provide:
</para>
<itemizedlist>
@@ -126,7 +126,7 @@
</listitem>
<listitem>
<para>
- How can I define alternative an implementation, so that the implementation can vary
+ How can I define an alternative implementation, so that the implementation can vary
at deployment time?
</para>
</listitem>
@@ -151,7 +151,7 @@
</para>
<para>
- Events, interceptors and decorators enhance the <emphasis>loose-coupling</emphasis> inherent in this model:
+ Events, interceptors and decorators enhance the loose-coupling inherent in this model:
</para>
<itemizedlist>
@@ -174,8 +174,8 @@
<emphasis>typesafe</emphasis> way. CDI never relies on string-based identifiers to determine how collaborating
objects fit together. (XML is rarely used, reserved only to activate alternatives and define ordering at
deployment time). Instead, CDI uses the typing information that is already available in the Java object model,
- then extends it with a new typing pattern, called <emphasis>qualifier annotations</emphasis>, to wire together
- beans, their dependencies, their interceptors and decorators, and their event consumers.
+ then extends it using a new programming pattern, called <emphasis>qualifier annotations</emphasis>, to wire
+ together beans, their dependencies, their interceptors and decorators, and their event consumers.
</para>
<para>
15 years
Weld SVN: r4833 - doc/trunk/reference/en-US.
by weld-commits@lists.jboss.org
Author: gavin.king(a)jboss.com
Date: 2009-11-09 02:49:15 -0500 (Mon, 09 Nov 2009)
New Revision: 4833
Modified:
doc/trunk/reference/en-US/producermethods.xml
Log:
@sessionscoped implements serializable
Modified: doc/trunk/reference/en-US/producermethods.xml
===================================================================
--- doc/trunk/reference/en-US/producermethods.xml 2009-11-09 07:49:05 UTC (rev 4832)
+++ doc/trunk/reference/en-US/producermethods.xml 2009-11-09 07:49:15 UTC (rev 4833)
@@ -59,7 +59,7 @@
</para>
<programlisting role="JAVA"><![CDATA[@SessionScoped
-public class Preferences {
+public class Preferences implements Serializable {
private PaymentStrategyType paymentStrategy;
...
@Produces @Preferred
15 years
Weld SVN: r4832 - doc/trunk/reference/en-US.
by weld-commits@lists.jboss.org
Author: gavin.king(a)jboss.com
Date: 2009-11-09 02:49:05 -0500 (Mon, 09 Nov 2009)
New Revision: 4832
Modified:
doc/trunk/reference/en-US/example.xml
Log:
@sessionscoped implements serializable
Modified: doc/trunk/reference/en-US/example.xml
===================================================================
--- doc/trunk/reference/en-US/example.xml 2009-11-09 07:48:56 UTC (rev 4831)
+++ doc/trunk/reference/en-US/example.xml 2009-11-09 07:49:05 UTC (rev 4832)
@@ -39,7 +39,7 @@
</para>
<programlisting role="JAVA"><![CDATA[@SessionScoped @Named
-public class Login {
+public class Login implements Serializable {
@Inject Credentials credentials;
@Inject @UserDatabase EntityManager userDatabase;
15 years
Weld SVN: r4831 - doc/trunk/reference/en-US.
by weld-commits@lists.jboss.org
Author: gavin.king(a)jboss.com
Date: 2009-11-09 02:48:56 -0500 (Mon, 09 Nov 2009)
New Revision: 4831
Modified:
doc/trunk/reference/en-US/ee.xml
Log:
@sessionscoped implements serializable
Modified: doc/trunk/reference/en-US/ee.xml
===================================================================
--- doc/trunk/reference/en-US/ee.xml 2009-11-09 04:52:50 UTC (rev 4830)
+++ doc/trunk/reference/en-US/ee.xml 2009-11-09 07:48:56 UTC (rev 4831)
@@ -26,7 +26,7 @@
}]]></programlisting>
<programlisting role="JAVA"><![CDATA[@SessionScoped
-public class Login {
+public class Login implements Serializable {
@Inject Credentials credentials;
@PersistenceContext EntityManager userDatabase;
...
15 years
Weld SVN: r4830 - extensions/trunk/servlet/int/src/main/java/org/jboss/weld/environment/servlet/jsf.
by weld-commits@lists.jboss.org
Author: dan.j.allen
Date: 2009-11-08 23:52:50 -0500 (Sun, 08 Nov 2009)
New Revision: 4830
Modified:
extensions/trunk/servlet/int/src/main/java/org/jboss/weld/environment/servlet/jsf/WeldApplication.java
Log:
note
Modified: extensions/trunk/servlet/int/src/main/java/org/jboss/weld/environment/servlet/jsf/WeldApplication.java
===================================================================
--- extensions/trunk/servlet/int/src/main/java/org/jboss/weld/environment/servlet/jsf/WeldApplication.java 2009-11-09 04:51:55 UTC (rev 4829)
+++ extensions/trunk/servlet/int/src/main/java/org/jboss/weld/environment/servlet/jsf/WeldApplication.java 2009-11-09 04:52:50 UTC (rev 4830)
@@ -38,7 +38,7 @@
* The BeanManager may not have been initialized at the time JSF is initializing. Therefore,
* we stick in a ForwardingELResolver that delegates to the BeanManager ELResolver, which will
* be plugged in when it's available. If the ELResolver is invoked before the BeanManager
- * is available, an IllegalStateException is thrown (is this the desired behavior?)
+ * is available, the resolver will perform no action (and thus produce no result).
*/
private static class LazyBeanManagerIntegrationELResolver extends ForwardingELResolver
{
15 years
Weld SVN: r4829 - in extensions/trunk/servlet/int/src/main/java/org/jboss/weld/environment/servlet: util and 1 other directory.
by weld-commits@lists.jboss.org
Author: dan.j.allen
Date: 2009-11-08 23:51:55 -0500 (Sun, 08 Nov 2009)
New Revision: 4829
Added:
extensions/trunk/servlet/int/src/main/java/org/jboss/weld/environment/servlet/util/TransparentELResolver.java
Modified:
extensions/trunk/servlet/int/src/main/java/org/jboss/weld/environment/servlet/jsf/WeldApplication.java
Log:
use transparent ELResolver rather than throwing exception if ForwardingELResolver
is consulted before the BeanManager is ready
this is necessary since it could be used when loading eager JSF managed beans
Modified: extensions/trunk/servlet/int/src/main/java/org/jboss/weld/environment/servlet/jsf/WeldApplication.java
===================================================================
--- extensions/trunk/servlet/int/src/main/java/org/jboss/weld/environment/servlet/jsf/WeldApplication.java 2009-11-09 03:59:12 UTC (rev 4828)
+++ extensions/trunk/servlet/int/src/main/java/org/jboss/weld/environment/servlet/jsf/WeldApplication.java 2009-11-09 04:51:55 UTC (rev 4829)
@@ -26,6 +26,7 @@
import org.jboss.weld.environment.servlet.util.ForwardingELResolver;
import org.jboss.weld.environment.servlet.util.Reflections;
+import org.jboss.weld.environment.servlet.util.TransparentELResolver;
/**
* @author Pete Muir
@@ -41,8 +42,12 @@
*/
private static class LazyBeanManagerIntegrationELResolver extends ForwardingELResolver
{
- private ELResolver delegate = null;
+ private ELResolver delegate;
+ public LazyBeanManagerIntegrationELResolver() {
+ delegate = new TransparentELResolver();
+ }
+
public void beanManagerReady(BeanManager beanManager)
{
this.delegate = beanManager.getELResolver();
@@ -51,9 +56,6 @@
@Override
protected ELResolver delegate()
{
- if (delegate == null) {
- throw new IllegalStateException("Attempt to use JSR-299 ELResolver before BeanManager initialized.");
- }
return delegate;
}
}
Added: extensions/trunk/servlet/int/src/main/java/org/jboss/weld/environment/servlet/util/TransparentELResolver.java
===================================================================
--- extensions/trunk/servlet/int/src/main/java/org/jboss/weld/environment/servlet/util/TransparentELResolver.java (rev 0)
+++ extensions/trunk/servlet/int/src/main/java/org/jboss/weld/environment/servlet/util/TransparentELResolver.java 2009-11-09 04:51:55 UTC (rev 4829)
@@ -0,0 +1,53 @@
+package org.jboss.weld.environment.servlet.util;
+
+import java.beans.FeatureDescriptor;
+import java.util.Iterator;
+
+import javax.el.ELContext;
+import javax.el.ELResolver;
+
+/**
+ * An ELResolver that behaves as though it is invisible, meaning it's
+ * indempontent to the chain and the next ELResolver in the line will be
+ * consulted.
+ *
+ * @author Dan Allen
+ */
+public class TransparentELResolver extends ELResolver
+{
+ @Override
+ public Class<?> getCommonPropertyType(ELContext arg0, Object arg1)
+ {
+ return null;
+ }
+
+ @Override
+ public Iterator<FeatureDescriptor> getFeatureDescriptors(ELContext arg0, Object arg1)
+ {
+ return null;
+ }
+
+ @Override
+ public Class<?> getType(ELContext arg0, Object arg1, Object arg2)
+ {
+ return null;
+ }
+
+ @Override
+ public Object getValue(ELContext arg0, Object arg1, Object arg2)
+ {
+ return null;
+ }
+
+ @Override
+ public boolean isReadOnly(ELContext arg0, Object arg1, Object arg2)
+ {
+ return false;
+ }
+
+ @Override
+ public void setValue(ELContext arg0, Object arg1, Object arg2, Object arg3)
+ {
+ }
+
+}
15 years
Weld SVN: r4828 - extensions/trunk/servlet/int/src/main/java/org/jboss/weld/environment/servlet/jsf.
by weld-commits@lists.jboss.org
Author: dan.j.allen
Date: 2009-11-08 22:59:12 -0500 (Sun, 08 Nov 2009)
New Revision: 4828
Modified:
extensions/trunk/servlet/int/src/main/java/org/jboss/weld/environment/servlet/jsf/WeldApplication.java
Log:
note
Modified: extensions/trunk/servlet/int/src/main/java/org/jboss/weld/environment/servlet/jsf/WeldApplication.java
===================================================================
--- extensions/trunk/servlet/int/src/main/java/org/jboss/weld/environment/servlet/jsf/WeldApplication.java 2009-11-09 03:56:44 UTC (rev 4827)
+++ extensions/trunk/servlet/int/src/main/java/org/jboss/weld/environment/servlet/jsf/WeldApplication.java 2009-11-09 03:59:12 UTC (rev 4828)
@@ -35,7 +35,7 @@
{
/**
* The BeanManager may not have been initialized at the time JSF is initializing. Therefore,
- * we stick in an ELResolver that delegates to the BeanManager ELResolver, which will
+ * we stick in a ForwardingELResolver that delegates to the BeanManager ELResolver, which will
* be plugged in when it's available. If the ELResolver is invoked before the BeanManager
* is available, an IllegalStateException is thrown (is this the desired behavior?)
*/
15 years