Weld SVN: r5069 - doc/trunk/reference/en-US.
by weld-commits@lists.jboss.org
Author: gavin.king(a)jboss.com
Date: 2009-11-15 20:38:56 -0500 (Sun, 15 Nov 2009)
New Revision: 5069
Modified:
doc/trunk/reference/en-US/scopescontexts.xml
Log:
tips
Modified: doc/trunk/reference/en-US/scopescontexts.xml
===================================================================
--- doc/trunk/reference/en-US/scopescontexts.xml 2009-11-16 01:38:29 UTC (rev 5068)
+++ doc/trunk/reference/en-US/scopescontexts.xml 2009-11-16 01:38:56 UTC (rev 5069)
@@ -31,6 +31,16 @@
session, and automatically destroyed when the session ends.
</para>
+ <tip>
+ <para>
+ JPA entities aren't a great fit for this model. Entities have their whole own lifecycle and identity model
+ 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|.
+ </para>
+ </tip>
+
<note>
<para>
There's actually no way to remove a bean from a context until the entire context is destroyed.
@@ -372,6 +382,22 @@
</para>
<para>
+ If a Unified EL expression refers to a dependent bean by EL name, an instance of the bean is instantiated
+ every time the expression is evaluated. The instance is not reused during any other expression evaluation.
+ </para>
+
+ <tip>
+ <para>
+ If you need to access a bean directly by EL name in a JSF page, you probably need to give it a scope other
+ than <literal>@Dependent</literal>. Otherwise, any value that gets set to the bean by a JSF input will be
+ lost immediately. That's why CDI features the <literal>@Model</literal> stereotype; it lets you give a bean
+ a name, and set its scope to <literal>@RequestScoped</literal> in one stroke. If you need to access a bean
+ that really <emphasis>has</emphasis> to have the scope <literal>@Dependent</literal> from a JSF page,
+ inject it into a different bean, and expose it to EL via a getter method.
+ </para>
+ </tip>
+
+ <para>
Beans with scope <literal>@Dependent</literal> don't need a proxy object. The client holds a direct reference
to its instance.
</para>
14 years, 7 months
Weld SVN: r5068 - doc/trunk/reference/en-US.
by weld-commits@lists.jboss.org
Author: gavin.king(a)jboss.com
Date: 2009-11-15 20:38:29 -0500 (Sun, 15 Nov 2009)
New Revision: 5068
Modified:
doc/trunk/reference/en-US/injection.xml
Log:
ws
Modified: doc/trunk/reference/en-US/injection.xml
===================================================================
--- doc/trunk/reference/en-US/injection.xml 2009-11-16 00:52:46 UTC (rev 5067)
+++ doc/trunk/reference/en-US/injection.xml 2009-11-16 01:38:29 UTC (rev 5068)
@@ -474,7 +474,7 @@
the current context. The client proxy also allows beans bound to contexts such as the session context to be
serialized to disk without recursively serializing other injected beans.
</para>
-
+
<para>
Unfortunately, due to limitations of the Java language, some Java types cannot be proxied by the container.
If an injection point declared with one of these types resolves to a bean with any scope other than
14 years, 7 months
Weld SVN: r5067 - doc/trunk/reference/en-US.
by weld-commits@lists.jboss.org
Author: gavin.king(a)jboss.com
Date: 2009-11-15 19:52:46 -0500 (Sun, 15 Nov 2009)
New Revision: 5067
Modified:
doc/trunk/reference/en-US/ee.xml
Log:
note
Modified: doc/trunk/reference/en-US/ee.xml
===================================================================
--- doc/trunk/reference/en-US/ee.xml 2009-11-16 00:41:32 UTC (rev 5066)
+++ doc/trunk/reference/en-US/ee.xml 2009-11-16 00:52:46 UTC (rev 5067)
@@ -41,6 +41,18 @@
</listitem>
</itemizedlist>
+ <note>
+ <para>
+ The CDI specification does not require the servlet context objects, <literal>HttpServletRequest</literal>,
+ <literal>HttpSession</literal> and <literal>ServletContext</literal> to be exposed as injectable beans. If
+ you really want to be able to inject these objects, it's easy to create a portable extension to expose them
+ as beans. However, we recommend that direct access to these objects be limited to servlets, servlet filters
+ and servlet event listeners, where they may be obtained in the usual way as defined by the Java Servlets spec.
+ The <literal>FacesContext</literal> is also not injectable. You can get at it by calling
+ <literal>FacesContext.getCurrentInstance()</literal>.
+ </para>
+ </note>
+
</section>
<section>
14 years, 7 months
Weld SVN: r5066 - doc/trunk/reference/en-US.
by weld-commits@lists.jboss.org
Author: gavin.king(a)jboss.com
Date: 2009-11-15 19:41:32 -0500 (Sun, 15 Nov 2009)
New Revision: 5066
Modified:
doc/trunk/reference/en-US/example.xml
Log:
constraints
Modified: doc/trunk/reference/en-US/example.xml
===================================================================
--- doc/trunk/reference/en-US/example.xml 2009-11-16 00:32:40 UTC (rev 5065)
+++ doc/trunk/reference/en-US/example.xml 2009-11-16 00:41:32 UTC (rev 5066)
@@ -5,7 +5,8 @@
<para>
Let's illustrate these ideas with a full example. We're going to implement user login/logout for an application
- that uses JSF. First, we'll define a request-scoped bean to hold the username and password entered during login:
+ that uses JSF. First, we'll define a request-scoped bean to hold the username and password entered during login,
+ with constraints defined using annotations from the Bean Validation specification:
</para>
<programlisting role="JAVA"><![CDATA[@Named @RequestScoped
@@ -13,9 +14,11 @@
private String username;
private String password;
+ @NotNull @Length(min=3, max=25)
public String getUsername() { return username; }
public void setUsername(String username) { this.username = username; }
+ @NotNull @Length(min=6, max=20)
public String getPassword() { return password; }
public void setPassword(String password) { this.password = password; }
}]]></programlisting>
@@ -36,19 +39,17 @@
</h:form>]]></programlisting>
<para>
- Users are represented by a JPA entity, with constraints defined using annotations defined by the Bean Validation
- specification:
+ Users are represented by a JPA entity:
</para>
<programlisting role="JAVA"><![CDATA[@Entity
public class User {
- private @NotNull @Length(max=25) @Id String username;
+ private @NotNull @Length(min=3, max=25) @Id String username;
private @NotNull @Length(min=6, max=20) String password;
public String getUsername() { return username; }
public void setUsername(String username) { this.username = username; }
public String setPassword(String password) { this.password = password; }
-
}]]></programlisting>
<para>
14 years, 7 months
Weld SVN: r5065 - doc/trunk/reference/en-US.
by weld-commits@lists.jboss.org
Author: gavin.king(a)jboss.com
Date: 2009-11-15 19:32:40 -0500 (Sun, 15 Nov 2009)
New Revision: 5065
Modified:
doc/trunk/reference/en-US/example.xml
Log:
validation
Modified: doc/trunk/reference/en-US/example.xml
===================================================================
--- doc/trunk/reference/en-US/example.xml 2009-11-16 00:21:07 UTC (rev 5064)
+++ doc/trunk/reference/en-US/example.xml 2009-11-16 00:32:40 UTC (rev 5065)
@@ -24,23 +24,26 @@
<programlisting role="JAVA"><![CDATA[<h:form>
<h:panelGrid columns="2" rendered="#{!login.loggedIn}">
- <h:outputLabel for="username">Username:</h:outputLabel>
- <h:inputText id="username" value="#{credentials.username}"/>
- <h:outputLabel for="password">Password:</h:outputLabel>
- <h:inputText id="password" value="#{credentials.password}"/>
+ <f:validateBean>
+ <h:outputLabel for="username">Username:</h:outputLabel>
+ <h:inputText id="username" value="#{credentials.username}"/>
+ <h:outputLabel for="password">Password:</h:outputLabel>
+ <h:inputText id="password" value="#{credentials.password}"/>
+ </f:validateBean>
</h:panelGrid>
<h:commandButton value="Login" action="#{login.login}" rendered="#{!login.loggedIn}"/>
<h:commandButton value="Logout" action="#{login.logout}" rendered="#{login.loggedIn}"/>
</h:form>]]></programlisting>
<para>
- Users are represented by a JPA entity:
+ Users are represented by a JPA entity, with constraints defined using annotations defined by the Bean Validation
+ specification:
</para>
<programlisting role="JAVA"><![CDATA[@Entity
public class User {
- private @Id String username;
- private String password;
+ private @NotNull @Length(max=25) @Id String username;
+ private @NotNull @Length(min=6, max=20) String password;
public String getUsername() { return username; }
public void setUsername(String username) { this.username = username; }
14 years, 7 months
Weld SVN: r5064 - doc/trunk/reference/en-US.
by weld-commits@lists.jboss.org
Author: gavin.king(a)jboss.com
Date: 2009-11-15 19:21:07 -0500 (Sun, 15 Nov 2009)
New Revision: 5064
Modified:
doc/trunk/reference/en-US/producermethods.xml
Log:
move
Modified: doc/trunk/reference/en-US/producermethods.xml
===================================================================
--- doc/trunk/reference/en-US/producermethods.xml 2009-11-16 00:18:47 UTC (rev 5063)
+++ doc/trunk/reference/en-US/producermethods.xml 2009-11-16 00:21:07 UTC (rev 5064)
@@ -93,16 +93,6 @@
object for each user session.
</para>
- <note>
- <para>
- The producer method does <emphasis>not</emphasis> inherit the scope of the bean that declares the
- method. There are two different beans here: the producer method, and the bean which declares it. The
- scope of the producer method determines how often the method will be called, and the lifecycle of the
- objects returned by the method. The scope of the bean that declares the producer method determines the
- lifecycle of the object upon which the producer method is invoked.
- </para>
- </note>
-
<para>
To change this behavior, we can add a <literal>@SessionScoped</literal> annotation to the method.
</para>
@@ -117,6 +107,16 @@
the session context. The producer method won't be called again in the same session.
</para>
+ <note>
+ <para>
+ A producer method does <emphasis>not</emphasis> inherit the scope of the bean that declares the
+ method. There are two different beans here: the producer method, and the bean which declares it. The
+ scope of the producer method determines how often the method will be called, and the lifecycle of the
+ objects returned by the method. The scope of the bean that declares the producer method determines the
+ lifecycle of the object upon which the producer method is invoked.
+ </para>
+ </note>
+
</section>
<section>
14 years, 7 months
Weld SVN: r5063 - doc/trunk/reference/en-US.
by weld-commits@lists.jboss.org
Author: gavin.king(a)jboss.com
Date: 2009-11-15 19:18:47 -0500 (Sun, 15 Nov 2009)
New Revision: 5063
Modified:
doc/trunk/reference/en-US/example.xml
Log:
missing from example
Modified: doc/trunk/reference/en-US/example.xml
===================================================================
--- doc/trunk/reference/en-US/example.xml 2009-11-15 23:52:05 UTC (rev 5062)
+++ doc/trunk/reference/en-US/example.xml 2009-11-16 00:18:47 UTC (rev 5063)
@@ -34,6 +34,26 @@
</h:form>]]></programlisting>
<para>
+ Users are represented by a JPA entity:
+ </para>
+
+ <programlisting role="JAVA"><![CDATA[@Entity
+public class User {
+ private @Id String username;
+ private String password;
+
+ public String getUsername() { return username; }
+ public void setUsername(String username) { this.username = username; }
+ public String setPassword(String password) { this.password = password; }
+
+}]]></programlisting>
+
+ <para>
+ (Note that we're also going to need a <literal>persistence.xml</literal> file to configure the JPA persistence
+ unit containing <literal>User</literal>.)
+ </para>
+
+ <para>
The actual work is done by a session-scoped bean that maintains information about the currently logged-in user
and exposes the <literal>User</literal> entity to other beans:
</para>
@@ -91,8 +111,9 @@
We need an adaptor bean to expose our typesafe <literal>EntityManager</literal>:
</para>
- <programlisting role="JAVA"><![CDATA[public class UserDatabaseProducer {
- @Produces @UserDatabase @PersistenceContext EntityManager userDatabase;
+ <programlisting role="JAVA"><![CDATA[class UserDatabaseProducer {
+ @Produces @UserDatabase @PersistenceContext
+ static EntityManager userDatabase;
}]]></programlisting>
<para>Now <literal>DocumentEditor</literal>, or any other bean, can easily inject the current user:</para>
14 years, 7 months
Weld SVN: r5062 - doc/trunk/reference/en-US.
by weld-commits@lists.jboss.org
Author: gavin.king(a)jboss.com
Date: 2009-11-15 18:52:05 -0500 (Sun, 15 Nov 2009)
New Revision: 5062
Modified:
doc/trunk/reference/en-US/producermethods.xml
Log:
helpful note
Modified: doc/trunk/reference/en-US/producermethods.xml
===================================================================
--- doc/trunk/reference/en-US/producermethods.xml 2009-11-15 16:55:53 UTC (rev 5061)
+++ doc/trunk/reference/en-US/producermethods.xml 2009-11-15 23:52:05 UTC (rev 5062)
@@ -92,6 +92,16 @@
same producer method. Thus, there could be multiple instances of the <literal>PaymentStrategy</literal>
object for each user session.
</para>
+
+ <note>
+ <para>
+ The producer method does <emphasis>not</emphasis> inherit the scope of the bean that declares the
+ method. There are two different beans here: the producer method, and the bean which declares it. The
+ scope of the producer method determines how often the method will be called, and the lifecycle of the
+ objects returned by the method. The scope of the bean that declares the producer method determines the
+ lifecycle of the object upon which the producer method is invoked.
+ </para>
+ </note>
<para>
To change this behavior, we can add a <literal>@SessionScoped</literal> annotation to the method.
14 years, 7 months
Weld SVN: r5061 - in core/trunk/impl/src/main: java/org/jboss/weld/context and 7 other directories.
by weld-commits@lists.jboss.org
Author: dallen6
Date: 2009-11-15 11:55:53 -0500 (Sun, 15 Nov 2009)
New Revision: 5061
Added:
core/trunk/impl/src/main/java/org/jboss/weld/logging/messages/ElMessage.java
core/trunk/impl/src/main/resources/org/jboss/weld/messages/el_en.properties
Modified:
core/trunk/impl/src/main/java/org/jboss/weld/InvalidOperationException.java
core/trunk/impl/src/main/java/org/jboss/weld/context/AbstractMapContext.java
core/trunk/impl/src/main/java/org/jboss/weld/context/beanstore/NamingScheme.java
core/trunk/impl/src/main/java/org/jboss/weld/conversation/ConversationImpl.java
core/trunk/impl/src/main/java/org/jboss/weld/ejb/EjbDescriptors.java
core/trunk/impl/src/main/java/org/jboss/weld/el/AbstractWeldELResolver.java
core/trunk/impl/src/main/java/org/jboss/weld/el/WeldExpressionFactory.java
core/trunk/impl/src/main/java/org/jboss/weld/event/EventImpl.java
core/trunk/impl/src/main/java/org/jboss/weld/event/ObserverMethodImpl.java
core/trunk/impl/src/main/java/org/jboss/weld/logging/messages/BeanMessage.java
core/trunk/impl/src/main/java/org/jboss/weld/logging/messages/ContextMessage.java
core/trunk/impl/src/main/java/org/jboss/weld/logging/messages/ConversationMessage.java
core/trunk/impl/src/main/java/org/jboss/weld/logging/messages/EventMessage.java
core/trunk/impl/src/main/resources/org/jboss/weld/messages/bean_en.properties
core/trunk/impl/src/main/resources/org/jboss/weld/messages/context_en.properties
core/trunk/impl/src/main/resources/org/jboss/weld/messages/conversation_en.properties
core/trunk/impl/src/main/resources/org/jboss/weld/messages/event_en.properties
Log:
Addition exception conversion to localized messages
Modified: core/trunk/impl/src/main/java/org/jboss/weld/InvalidOperationException.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/InvalidOperationException.java 2009-11-15 06:30:44 UTC (rev 5060)
+++ core/trunk/impl/src/main/java/org/jboss/weld/InvalidOperationException.java 2009-11-15 16:55:53 UTC (rev 5061)
@@ -35,6 +35,11 @@
// Exception messages
private static final IMessageConveyor messageConveyer = loggerFactory().getMessageConveyor();
+ public InvalidOperationException()
+ {
+ super();
+ }
+
public <E extends Enum<?>> InvalidOperationException(E key, Object... args)
{
super(messageConveyer.getMessage(key, args));
Modified: core/trunk/impl/src/main/java/org/jboss/weld/context/AbstractMapContext.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/context/AbstractMapContext.java 2009-11-15 06:30:44 UTC (rev 5060)
+++ core/trunk/impl/src/main/java/org/jboss/weld/context/AbstractMapContext.java 2009-11-15 16:55:53 UTC (rev 5061)
@@ -19,7 +19,9 @@
import static org.jboss.weld.logging.Category.CONTEXT;
import static org.jboss.weld.logging.LoggerFactory.loggerFactory;
import static org.jboss.weld.logging.messages.ContextMessage.CONTEXTUAL_INSTANCE_REMOVED;
+import static org.jboss.weld.logging.messages.ContextMessage.CONTEXTUAL_IS_NULL;
import static org.jboss.weld.logging.messages.ContextMessage.CONTEXT_CLEARED;
+import static org.jboss.weld.logging.messages.ContextMessage.NO_BEAN_STORE_AVAILABLE;
import java.lang.annotation.Annotation;
import java.util.concurrent.locks.ReentrantLock;
@@ -29,9 +31,11 @@
import javax.enterprise.context.spi.CreationalContext;
import org.jboss.weld.Container;
-import org.jboss.weld.serialization.spi.ContextualStore;
+import org.jboss.weld.ForbiddenArgumentException;
+import org.jboss.weld.ForbiddenStateException;
import org.jboss.weld.context.api.BeanStore;
import org.jboss.weld.context.api.ContextualInstance;
+import org.jboss.weld.serialization.spi.ContextualStore;
import org.slf4j.cal10n.LocLogger;
/**
@@ -83,7 +87,7 @@
}
if (contextual == null)
{
- throw new IllegalArgumentException("Must provide a contextual to get");
+ throw new ForbiddenArgumentException(CONTEXTUAL_IS_NULL);
}
String id = getId(contextual);
ContextualInstance<T> beanInstance = getBeanStore().get(id);
@@ -136,7 +140,7 @@
{
if (getBeanStore() == null)
{
- throw new IllegalStateException("No bean store available for " + toString());
+ throw new ForbiddenStateException(NO_BEAN_STORE_AVAILABLE, this);
}
ContextualInstance<T> beanInstance = getBeanStore().get(id);
beanInstance.getContextual().destroy(beanInstance.getInstance(), beanInstance.getCreationalContext());
@@ -152,7 +156,7 @@
log.trace(CONTEXT_CLEARED, this);
if (getBeanStore() == null)
{
- throw new IllegalStateException("No bean store available for " + toString());
+ throw new ForbiddenStateException(NO_BEAN_STORE_AVAILABLE, this);
}
for (String id : getBeanStore().getContextualIds())
{
Modified: core/trunk/impl/src/main/java/org/jboss/weld/context/beanstore/NamingScheme.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/context/beanstore/NamingScheme.java 2009-11-15 06:30:44 UTC (rev 5060)
+++ core/trunk/impl/src/main/java/org/jboss/weld/context/beanstore/NamingScheme.java 2009-11-15 16:55:53 UTC (rev 5061)
@@ -16,8 +16,12 @@
*/
package org.jboss.weld.context.beanstore;
+import static org.jboss.weld.logging.messages.ContextMessage.DELIMITER_IN_PREFIX;
+import org.jboss.weld.ForbiddenArgumentException;
+
+
/**
* Simple prefix-based implementation of a BeanStore naming scheme
*
@@ -26,16 +30,16 @@
public class NamingScheme
{
public String prefix;
- public String delimeter;
+ public String delimiter;
- public NamingScheme(String prefix, String delimeter)
+ public NamingScheme(String prefix, String delimiter)
{
- if (prefix.indexOf(delimeter) >= 0)
+ if (prefix.indexOf(delimiter) >= 0)
{
- throw new IllegalArgumentException("The delimiter '" + delimeter + "' shouldn't be in the prefix '" + prefix + "'");
+ throw new ForbiddenArgumentException(DELIMITER_IN_PREFIX, delimiter, prefix);
}
this.prefix = prefix;
- this.delimeter = delimeter;
+ this.delimiter = delimiter;
}
public boolean acceptKey(String key)
@@ -45,11 +49,11 @@
public String getId(String key)
{
- return new StringBuilder().append(key.substring(prefix.length() + delimeter.length())).toString();
+ return new StringBuilder().append(key.substring(prefix.length() + delimiter.length())).toString();
}
public String getKey(String id)
{
- return new StringBuilder().append(prefix).append(delimeter).append(id).toString();
+ return new StringBuilder().append(prefix).append(delimiter).append(id).toString();
}
}
Modified: core/trunk/impl/src/main/java/org/jboss/weld/conversation/ConversationImpl.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/conversation/ConversationImpl.java 2009-11-15 06:30:44 UTC (rev 5060)
+++ core/trunk/impl/src/main/java/org/jboss/weld/conversation/ConversationImpl.java 2009-11-15 16:55:53 UTC (rev 5061)
@@ -18,7 +18,9 @@
import static org.jboss.weld.logging.Category.CONVERSATION;
import static org.jboss.weld.logging.LoggerFactory.loggerFactory;
+import static org.jboss.weld.logging.messages.ConversationMessage.BEGIN_CALLED_ON_LONG_RUNNING_CONVERSATION;
import static org.jboss.weld.logging.messages.ConversationMessage.DEMOTED_LRC;
+import static org.jboss.weld.logging.messages.ConversationMessage.END_CALLED_ON_TRANSIENT_CONVERSATION;
import static org.jboss.weld.logging.messages.ConversationMessage.PROMOTED_TRANSIENT;
import static org.jboss.weld.logging.messages.ConversationMessage.SWITCHED_CONVERSATION;
@@ -30,6 +32,7 @@
import javax.inject.Inject;
import javax.inject.Named;
+import org.jboss.weld.ForbiddenStateException;
import org.slf4j.cal10n.LocLogger;
/**
@@ -97,7 +100,7 @@
{
if (!isTransient())
{
- throw new IllegalStateException("Attempt to call begin() on a long-running conversation");
+ throw new ForbiddenStateException(BEGIN_CALLED_ON_LONG_RUNNING_CONVERSATION);
}
log.debug(PROMOTED_TRANSIENT, id);
this._transient = false;
@@ -121,7 +124,7 @@
{
if (isTransient())
{
- throw new IllegalStateException("Attempt to call end() on a transient conversation");
+ throw new ForbiddenStateException(END_CALLED_ON_TRANSIENT_CONVERSATION);
}
log.debug(DEMOTED_LRC, id);
this._transient = true;
Modified: core/trunk/impl/src/main/java/org/jboss/weld/ejb/EjbDescriptors.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/ejb/EjbDescriptors.java 2009-11-15 06:30:44 UTC (rev 5060)
+++ core/trunk/impl/src/main/java/org/jboss/weld/ejb/EjbDescriptors.java 2009-11-15 16:55:53 UTC (rev 5061)
@@ -16,6 +16,8 @@
*/
package org.jboss.weld.ejb;
+import static org.jboss.weld.logging.messages.BeanMessage.TOO_MANY_EJBS_FOR_CLASS;
+
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
@@ -23,6 +25,8 @@
import java.util.Map;
import java.util.Set;
+import org.jboss.weld.ForbiddenStateException;
+import org.jboss.weld.InvalidOperationException;
import org.jboss.weld.bootstrap.api.Service;
import org.jboss.weld.ejb.spi.EjbDescriptor;
@@ -48,25 +52,25 @@
@Override
public <T> void add(EjbDescriptor<T> ejbDescriptor)
{
- throw new UnsupportedOperationException();
+ throw new InvalidOperationException();
}
@Override
public void addAll(Iterable<EjbDescriptor<?>> ejbDescriptors)
{
- throw new UnsupportedOperationException();
+ throw new InvalidOperationException();
}
@Override
public void cleanup()
{
- throw new UnsupportedOperationException();
+ throw new InvalidOperationException();
}
@Override
public void clear()
{
- throw new UnsupportedOperationException();
+ throw new InvalidOperationException();
}
@@ -142,7 +146,7 @@
Set<String> ejbs = ejbByClass.get(beanClass);
if (ejbs.size() > 0)
{
- throw new IllegalStateException("Unable to determine EJB for " + beanClass + ", multiple EJBs with that class " + ejbs);
+ throw new ForbiddenStateException(TOO_MANY_EJBS_FOR_CLASS, beanClass, ejbs);
}
else if (ejbs.size() == 0)
{
Modified: core/trunk/impl/src/main/java/org/jboss/weld/el/AbstractWeldELResolver.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/el/AbstractWeldELResolver.java 2009-11-15 06:30:44 UTC (rev 5060)
+++ core/trunk/impl/src/main/java/org/jboss/weld/el/AbstractWeldELResolver.java 2009-11-15 16:55:53 UTC (rev 5061)
@@ -17,6 +17,7 @@
package org.jboss.weld.el;
import static org.jboss.weld.el.ELCreationalContextStack.getCreationalContextStore;
+import static org.jboss.weld.logging.messages.ElMessage.RESOLUTION_ERROR;
import java.beans.FeatureDescriptor;
import java.util.Iterator;
@@ -27,6 +28,7 @@
import javax.enterprise.inject.spi.Bean;
import org.jboss.weld.BeanManagerImpl;
+import org.jboss.weld.WeldException;
/**
* An EL-resolver against the named beans
@@ -117,7 +119,7 @@
}
catch (Exception e)
{
- throw new RuntimeException("Error resolving property " + propertyString + " against base " + base, e);
+ throw new WeldException(RESOLUTION_ERROR, e, propertyString, base);
}
if (value != null)
{
Modified: core/trunk/impl/src/main/java/org/jboss/weld/el/WeldExpressionFactory.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/el/WeldExpressionFactory.java 2009-11-15 06:30:44 UTC (rev 5060)
+++ core/trunk/impl/src/main/java/org/jboss/weld/el/WeldExpressionFactory.java 2009-11-15 16:55:53 UTC (rev 5061)
@@ -16,11 +16,14 @@
*/
package org.jboss.weld.el;
+import static org.jboss.weld.logging.messages.ElMessage.NULL_EXPRESSION_FACTORY;
+
import javax.el.ELContext;
import javax.el.ExpressionFactory;
import javax.el.MethodExpression;
import javax.el.ValueExpression;
+import org.jboss.weld.ForbiddenArgumentException;
import org.jboss.weld.util.el.ForwardingExpressionFactory;
/**
@@ -36,7 +39,7 @@
{
if (expressionFactory == null)
{
- throw new IllegalArgumentException("Cannot pass null expressionFactory");
+ throw new ForbiddenArgumentException(NULL_EXPRESSION_FACTORY);
}
this.delegate = expressionFactory;
}
Modified: core/trunk/impl/src/main/java/org/jboss/weld/event/EventImpl.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/event/EventImpl.java 2009-11-15 06:30:44 UTC (rev 5060)
+++ core/trunk/impl/src/main/java/org/jboss/weld/event/EventImpl.java 2009-11-15 16:55:53 UTC (rev 5061)
@@ -16,9 +16,9 @@
*/
package org.jboss.weld.event;
+import static org.jboss.weld.logging.messages.EventMessage.PROXY_REQUIRED;
import static org.jboss.weld.util.Reflections.EMPTY_ANNOTATIONS;
-import java.io.InvalidObjectException;
import java.io.ObjectInputStream;
import java.io.ObjectStreamException;
import java.io.Serializable;
@@ -33,6 +33,7 @@
import javax.enterprise.util.TypeLiteral;
import org.jboss.weld.BeanManagerImpl;
+import org.jboss.weld.InvalidObjectException;
import org.jboss.weld.bean.builtin.AbstractFacade;
import org.jboss.weld.literal.DefaultLiteral;
import org.jboss.weld.util.Beans;
@@ -123,7 +124,7 @@
private void readObject(ObjectInputStream stream) throws InvalidObjectException
{
- throw new InvalidObjectException("Proxy required");
+ throw new InvalidObjectException(PROXY_REQUIRED);
}
private static class SerializationProxy extends AbstractFacadeSerializationProxy
Modified: core/trunk/impl/src/main/java/org/jboss/weld/event/ObserverMethodImpl.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/event/ObserverMethodImpl.java 2009-11-15 06:30:44 UTC (rev 5060)
+++ core/trunk/impl/src/main/java/org/jboss/weld/event/ObserverMethodImpl.java 2009-11-15 16:55:53 UTC (rev 5061)
@@ -16,6 +16,12 @@
*/
package org.jboss.weld.event;
+import static org.jboss.weld.logging.messages.EventMessage.INVALID_DISPOSES_PARAMETER;
+import static org.jboss.weld.logging.messages.EventMessage.INVALID_INITIALIZER;
+import static org.jboss.weld.logging.messages.EventMessage.INVALID_PRODUCER;
+import static org.jboss.weld.logging.messages.EventMessage.INVALID_SCOPED_CONDITIONAL_OBSERVER;
+import static org.jboss.weld.logging.messages.EventMessage.MULTIPLE_EVENT_PARAMETERS;
+
import java.lang.annotation.Annotation;
import java.lang.reflect.Type;
import java.util.HashSet;
@@ -44,7 +50,6 @@
import org.jboss.weld.injection.WeldInjectionPoint;
import org.jboss.weld.introspector.WeldMethod;
import org.jboss.weld.introspector.WeldParameter;
-import org.jboss.weld.literal.AnyLiteral;
import org.jboss.weld.util.Beans;
/**
@@ -66,8 +71,6 @@
public static final String ID_SEPARATOR = "-";
- private static final Annotation ANY = new AnyLiteral();
-
private final Set<Annotation> bindings;
private final Type eventType;
protected BeanManagerImpl manager;
@@ -123,27 +126,27 @@
List<WeldParameter<?, X>> eventObjects = this.observerMethod.getAnnotatedParameters(Observes.class);
if (this.notifyType.equals(Reception.IF_EXISTS) && declaringBean.getScope().equals(Dependent.class))
{
- throw new DefinitionException(this + " is invalid because it is a conditional observer method, and is declared by a @Dependent scoped bean");
+ throw new DefinitionException(INVALID_SCOPED_CONDITIONAL_OBSERVER, this);
}
if (eventObjects.size() > 1)
{
- throw new DefinitionException(this + " is invalid because it contains more than event parameter annotated @Observes");
+ throw new DefinitionException(MULTIPLE_EVENT_PARAMETERS, this);
}
// Check for parameters annotated with @Disposes
List<WeldParameter<?, X>> disposeParams = this.observerMethod.getAnnotatedParameters(Disposes.class);
if (disposeParams.size() > 0)
{
- throw new DefinitionException(this + " cannot have any parameters annotated with @Disposes");
+ throw new DefinitionException(INVALID_DISPOSES_PARAMETER, this);
}
// Check annotations on the method to make sure this is not a producer
// method, initializer method, or destructor method.
if (this.observerMethod.isAnnotationPresent(Produces.class))
{
- throw new DefinitionException(this + " cannot be annotated with @Produces");
+ throw new DefinitionException(INVALID_PRODUCER, this);
}
if (this.observerMethod.isAnnotationPresent(Inject.class))
{
- throw new DefinitionException(this + " cannot be annotated with @Initializer");
+ throw new DefinitionException(INVALID_INITIALIZER, this);
}
}
Modified: core/trunk/impl/src/main/java/org/jboss/weld/logging/messages/BeanMessage.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/logging/messages/BeanMessage.java 2009-11-15 06:30:44 UTC (rev 5060)
+++ core/trunk/impl/src/main/java/org/jboss/weld/logging/messages/BeanMessage.java 2009-11-15 16:55:53 UTC (rev 5061)
@@ -106,6 +106,7 @@
@MessageId("000085") CANNOT_DESTROY_NULL_BEAN,
@MessageId("000086") CANNOT_DESTROY_ENTERPRISE_BEAN_NOT_CREATED,
@MessageId("000087") MESSAGE_DRIVEN_BEANS_CANNOT_BE_MANAGED,
- @MessageId("000088") OBSERVER_METHOD_MUST_BE_STATIC_OR_BUSINESS;
+ @MessageId("000088") OBSERVER_METHOD_MUST_BE_STATIC_OR_BUSINESS,
+ @MessageId("000089") TOO_MANY_EJBS_FOR_CLASS;
}
Modified: core/trunk/impl/src/main/java/org/jboss/weld/logging/messages/ContextMessage.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/logging/messages/ContextMessage.java 2009-11-15 06:30:44 UTC (rev 5060)
+++ core/trunk/impl/src/main/java/org/jboss/weld/logging/messages/ContextMessage.java 2009-11-15 16:55:53 UTC (rev 5061)
@@ -28,6 +28,9 @@
@MessageId("000207") REQUEST_ENDED,
@MessageId("000208") APPLICATION_STARTED,
@MessageId("000209") APPLICATION_ENDED,
- @MessageId("000210") DEPENDENT_INSTANCE_ATTACHED;
+ @MessageId("000210") DEPENDENT_INSTANCE_ATTACHED,
+ @MessageId("000211") DELIMITER_IN_PREFIX,
+ @MessageId("000212") CONTEXTUAL_IS_NULL,
+ @MessageId("000213") NO_BEAN_STORE_AVAILABLE;
}
Modified: core/trunk/impl/src/main/java/org/jboss/weld/logging/messages/ConversationMessage.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/logging/messages/ConversationMessage.java 2009-11-15 06:30:44 UTC (rev 5060)
+++ core/trunk/impl/src/main/java/org/jboss/weld/logging/messages/ConversationMessage.java 2009-11-15 16:55:53 UTC (rev 5061)
@@ -38,6 +38,8 @@
@MessageId("000316") ILLEGAL_CONVERSATION_UNLOCK_ATTEMPT,
@MessageId("000317") PROMOTED_TRANSIENT,
@MessageId("000318") DEMOTED_LRC,
- @MessageId("000319") SWITCHED_CONVERSATION;
-
+ @MessageId("000319") SWITCHED_CONVERSATION,
+ @MessageId("000214") BEGIN_CALLED_ON_LONG_RUNNING_CONVERSATION,
+ @MessageId("000215") END_CALLED_ON_TRANSIENT_CONVERSATION;
+
}
Added: core/trunk/impl/src/main/java/org/jboss/weld/logging/messages/ElMessage.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/logging/messages/ElMessage.java (rev 0)
+++ core/trunk/impl/src/main/java/org/jboss/weld/logging/messages/ElMessage.java 2009-11-15 16:55:53 UTC (rev 5061)
@@ -0,0 +1,42 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat, Inc. and/or its affiliates, 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.weld.logging.messages;
+
+import org.jboss.weld.logging.MessageId;
+
+import ch.qos.cal10n.BaseName;
+import ch.qos.cal10n.Locale;
+import ch.qos.cal10n.LocaleData;
+
+@BaseName("org.jboss.weld.messages.el")
+@LocaleData({
+ @Locale("en")
+})
+/**
+ * Log messages for EL resolution.
+ *
+ * Message IDs: 001000 - 001099
+ *
+ * @author David Allen
+ *
+ */
+public enum ElMessage
+{
+ @MessageId("001000") RESOLUTION_ERROR,
+ @MessageId("001001") NULL_EXPRESSION_FACTORY;
+}
Property changes on: core/trunk/impl/src/main/java/org/jboss/weld/logging/messages/ElMessage.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: core/trunk/impl/src/main/java/org/jboss/weld/logging/messages/EventMessage.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/logging/messages/EventMessage.java 2009-11-15 06:30:44 UTC (rev 5060)
+++ core/trunk/impl/src/main/java/org/jboss/weld/logging/messages/EventMessage.java 2009-11-15 16:55:53 UTC (rev 5061)
@@ -20,6 +20,12 @@
@MessageId("000400") ASYNC_FIRE,
@MessageId("000401") ASYNC_OBSERVER_FAILURE,
- @MessageId("000402") ASYNC_TX_FIRE;
+ @MessageId("000402") ASYNC_TX_FIRE,
+ @MessageId("000403") PROXY_REQUIRED,
+ @MessageId("000404") INVALID_SCOPED_CONDITIONAL_OBSERVER,
+ @MessageId("000405") MULTIPLE_EVENT_PARAMETERS,
+ @MessageId("000406") INVALID_DISPOSES_PARAMETER,
+ @MessageId("000407") INVALID_PRODUCER,
+ @MessageId("000408") INVALID_INITIALIZER;
}
Modified: core/trunk/impl/src/main/resources/org/jboss/weld/messages/bean_en.properties
===================================================================
--- core/trunk/impl/src/main/resources/org/jboss/weld/messages/bean_en.properties 2009-11-15 06:30:44 UTC (rev 5060)
+++ core/trunk/impl/src/main/resources/org/jboss/weld/messages/bean_en.properties 2009-11-15 16:55:53 UTC (rev 5061)
@@ -87,3 +87,4 @@
CANNOT_DESTROY_ENTERPRISE_BEAN_NOT_CREATED=Cannot destroy session bean instance not created by the container\: {0}
MESSAGE_DRIVEN_BEANS_CANNOT_BE_MANAGED=Message driven beans cannot be Managed Beans\: {0}
OBSERVER_METHOD_MUST_BE_STATIC_OR_BUSINESS=Observer method must be static or business method\: {0} on {1}
+TOO_MANY_EJBS_FOR_CLASS=Unable to determine EJB for {0}, multiple EJBs with that class\: {1}
Modified: core/trunk/impl/src/main/resources/org/jboss/weld/messages/context_en.properties
===================================================================
--- core/trunk/impl/src/main/resources/org/jboss/weld/messages/context_en.properties 2009-11-15 06:30:44 UTC (rev 5060)
+++ core/trunk/impl/src/main/resources/org/jboss/weld/messages/context_en.properties 2009-11-15 16:55:53 UTC (rev 5061)
@@ -8,4 +8,7 @@
REQUEST_ENDED=Ending request {0}
APPLICATION_STARTED=Starting application {0}
APPLICATION_ENDED=Ending application {0}
-DEPENDENT_INSTANCE_ATTACHED=Attached dependent instance {0} to {1}
\ No newline at end of file
+DEPENDENT_INSTANCE_ATTACHED=Attached dependent instance {0} to {1}
+DELIMITER_IN_PREFIX=The delimiter \\"{0}\\" should not be in the prefix \\"{1}\\"
+CONTEXTUAL_IS_NULL=No contextual specified to retrieve (null)
+NO_BEAN_STORE_AVAILABLE=No bean store available for {0}
Modified: core/trunk/impl/src/main/resources/org/jboss/weld/messages/conversation_en.properties
===================================================================
--- core/trunk/impl/src/main/resources/org/jboss/weld/messages/conversation_en.properties 2009-11-15 06:30:44 UTC (rev 5060)
+++ core/trunk/impl/src/main/resources/org/jboss/weld/messages/conversation_en.properties 2009-11-15 16:55:53 UTC (rev 5061)
@@ -18,4 +18,5 @@
PROMOTED_TRANSIENT=Promoted conversation {0} to long-running
DEMOTED_LRC=Returned long-running conversation {0} to transient
SWITCHED_CONVERSATION=Switched conversation from {0} to {1}
-
\ No newline at end of file
+BEGIN_CALLED_ON_LONG_RUNNING_CONVERSATION=Attempt to call begin() on a long-running conversation
+END_CALLED_ON_TRANSIENT_CONVERSATION=Attempt to call end() on a transient conversation
Added: core/trunk/impl/src/main/resources/org/jboss/weld/messages/el_en.properties
===================================================================
--- core/trunk/impl/src/main/resources/org/jboss/weld/messages/el_en.properties (rev 0)
+++ core/trunk/impl/src/main/resources/org/jboss/weld/messages/el_en.properties 2009-11-15 16:55:53 UTC (rev 5061)
@@ -0,0 +1,2 @@
+RESOLUTION_ERROR=Error resolving property {0} against base {1}
+NULL_EXPRESSION_FACTORY=Cannot pass null expressionFactory
Property changes on: core/trunk/impl/src/main/resources/org/jboss/weld/messages/el_en.properties
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: core/trunk/impl/src/main/resources/org/jboss/weld/messages/event_en.properties
===================================================================
--- core/trunk/impl/src/main/resources/org/jboss/weld/messages/event_en.properties 2009-11-15 06:30:44 UTC (rev 5060)
+++ core/trunk/impl/src/main/resources/org/jboss/weld/messages/event_en.properties 2009-11-15 16:55:53 UTC (rev 5061)
@@ -1,3 +1,9 @@
ASYNC_FIRE=Sending event {0} directly to observer {1}
ASYNC_TX_FIRE=Sending event {0} asynchronously to transactional observer {1}
-ASYNC_OBSERVER_FAILURE=Failure while notifying an observer of event {0}
\ No newline at end of file
+ASYNC_OBSERVER_FAILURE=Failure while notifying an observer of event {0}
+PROXY_REQUIRED=Proxy required
+INVALID_SCOPED_CONDITIONAL_OBSERVER={0} is invalid because it is a conditional observer method and is declared by a @Dependent scoped bean
+MULTIPLE_EVENT_PARAMETERS={0} is invalid because it contains more than one event parameter annotated @Observes
+INVALID_DISPOSES_PARAMETER={0} cannot have any parameters annotated with @Disposes
+INVALID_PRODUCER={0} cannot be annotated with @Produces
+INVALID_INITIALIZER={0} cannot be annotated with @Initializer
14 years, 7 months
Weld SVN: r5060 - doc/trunk/reference/en-US.
by weld-commits@lists.jboss.org
Author: peteroyle
Date: 2009-11-15 01:30:44 -0500 (Sun, 15 Nov 2009)
New Revision: 5060
Modified:
doc/trunk/reference/en-US/weldexamples.xml
Log:
Removed unnecessary implemntation of serializable for ApplicationScoped beans
Modified: doc/trunk/reference/en-US/weldexamples.xml
===================================================================
--- doc/trunk/reference/en-US/weldexamples.xml 2009-11-15 06:30:31 UTC (rev 5059)
+++ doc/trunk/reference/en-US/weldexamples.xml 2009-11-15 06:30:44 UTC (rev 5060)
@@ -750,7 +750,7 @@
<area id="reset" coords="73" />
</areaspec>
<programlisting role="JAVA"><![CDATA[@ApplicationScoped
-public class Game implements Serializable
+public class Game
{
public static final int MAX_NUM_GUESSES = 10;
14 years, 7 months