Author: pete.muir(a)jboss.org
Date: 2010-02-17 09:10:43 -0500 (Wed, 17 Feb 2010)
New Revision: 5864
Modified:
core/trunk/impl/src/main/java/org/jboss/weld/bean/AbstractBean.java
core/trunk/impl/src/main/java/org/jboss/weld/bean/AbstractClassBean.java
core/trunk/impl/src/main/java/org/jboss/weld/bean/AbstractProducerBean.java
core/trunk/impl/src/main/java/org/jboss/weld/bean/DisposalMethod.java
core/trunk/impl/src/main/java/org/jboss/weld/bean/ManagedBean.java
core/trunk/impl/src/main/java/org/jboss/weld/bean/RIBean.java
core/trunk/impl/src/main/java/org/jboss/weld/bean/SessionBean.java
core/trunk/impl/src/main/java/org/jboss/weld/bean/builtin/AbstractBuiltInBean.java
core/trunk/impl/src/main/java/org/jboss/weld/bootstrap/BeanDeployment.java
core/trunk/impl/src/main/java/org/jboss/weld/introspector/ForwardingWeldAnnotated.java
core/trunk/impl/src/main/java/org/jboss/weld/introspector/WeldAnnotated.java
core/trunk/impl/src/main/java/org/jboss/weld/introspector/jlr/WeldClassImpl.java
core/trunk/impl/src/main/java/org/jboss/weld/introspector/jlr/WeldConstructorImpl.java
core/trunk/impl/src/main/java/org/jboss/weld/introspector/jlr/WeldFieldImpl.java
core/trunk/impl/src/main/java/org/jboss/weld/introspector/jlr/WeldMethodImpl.java
core/trunk/impl/src/main/java/org/jboss/weld/introspector/jlr/WeldParameterImpl.java
core/trunk/impl/src/main/java/org/jboss/weld/logging/messages/BeanMessage.java
core/trunk/impl/src/main/java/org/jboss/weld/util/Beans.java
core/trunk/impl/src/main/resources/org/jboss/weld/messages/bean_en.properties
Log:
minor cleanup and WELD-443
Modified: core/trunk/impl/src/main/java/org/jboss/weld/bean/AbstractBean.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bean/AbstractBean.java 2010-02-17
14:09:04 UTC (rev 5863)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bean/AbstractBean.java 2010-02-17
14:10:43 UTC (rev 5864)
@@ -130,6 +130,14 @@
}
}
+ @Override
+ public void initializeAfterBeanDiscovery()
+ {
+ checkType();
+ }
+
+ protected abstract void checkType();
+
protected void addInjectionPoint(WeldInjectionPoint<?, ?> injectionPoint)
{
if (injectionPoint.isAnnotationPresent(Delegate.class))
Modified: core/trunk/impl/src/main/java/org/jboss/weld/bean/AbstractClassBean.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bean/AbstractClassBean.java 2010-02-17
14:09:04 UTC (rev 5863)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bean/AbstractClassBean.java 2010-02-17
14:10:43 UTC (rev 5864)
@@ -183,20 +183,14 @@
@Override
public void initializeAfterBeanDiscovery()
{
- super.initializeAfterBeanDiscovery();
initDecorators();
if (hasDecorators())
{
initProxyClassForDecoratedBean();
}
+ super.initializeAfterBeanDiscovery();
}
- @Override
- public void checkType()
- {
-
- }
-
public void initDecorators()
{
this.decorators = getBeanManager().resolveDecorators(getTypes(), getQualifiers());
Modified: core/trunk/impl/src/main/java/org/jboss/weld/bean/AbstractProducerBean.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bean/AbstractProducerBean.java 2010-02-17
14:09:04 UTC (rev 5863)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bean/AbstractProducerBean.java 2010-02-17
14:10:43 UTC (rev 5864)
@@ -288,6 +288,12 @@
}
}
}
+
+ @Override
+ protected void checkType()
+ {
+
+ }
protected boolean isTypeSerializable(final Class<?> clazz)
{
Modified: core/trunk/impl/src/main/java/org/jboss/weld/bean/DisposalMethod.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bean/DisposalMethod.java 2010-02-17
14:09:04 UTC (rev 5863)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bean/DisposalMethod.java 2010-02-17
14:10:43 UTC (rev 5864)
@@ -226,6 +226,12 @@
}
}
}
+
+ @Override
+ protected void checkType()
+ {
+
+ }
@Override
public Class<T> getType()
Modified: core/trunk/impl/src/main/java/org/jboss/weld/bean/ManagedBean.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bean/ManagedBean.java 2010-02-17 14:09:04
UTC (rev 5863)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bean/ManagedBean.java 2010-02-17 14:10:43
UTC (rev 5864)
@@ -377,7 +377,6 @@
@Override
public void initializeAfterBeanDiscovery()
{
- super.initializeAfterBeanDiscovery();
if (this.passivationCapableBean && this.hasDecorators())
{
for (Decorator<?> decorator : this.getDecorators())
@@ -411,6 +410,7 @@
}
}
}
+ super.initializeAfterBeanDiscovery();
}
private void initPassivationCapable()
@@ -454,7 +454,7 @@
* Validates the type
*/
@Override
- public void checkType()
+ protected void checkType()
{
if (getWeldAnnotated().isAnonymousClass() || (getWeldAnnotated().isMemberClass()
&& !getWeldAnnotated().isStatic()))
{
Modified: core/trunk/impl/src/main/java/org/jboss/weld/bean/RIBean.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bean/RIBean.java 2010-02-17 14:09:04 UTC
(rev 5863)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bean/RIBean.java 2010-02-17 14:10:43 UTC
(rev 5864)
@@ -71,16 +71,8 @@
*
* @param environment
*/
- public void initializeAfterBeanDiscovery()
- {
- // no-op by default
- }
-
- public void checkType()
- {
-
- }
-
+ public abstract void initializeAfterBeanDiscovery();
+
public abstract boolean isSpecializing();
public boolean isDependent()
Modified: core/trunk/impl/src/main/java/org/jboss/weld/bean/SessionBean.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bean/SessionBean.java 2010-02-17 14:09:04
UTC (rev 5863)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bean/SessionBean.java 2010-02-17 14:10:43
UTC (rev 5864)
@@ -21,6 +21,7 @@
import static org.jboss.weld.logging.messages.BeanMessage.EJB_CANNOT_BE_DECORATOR;
import static org.jboss.weld.logging.messages.BeanMessage.EJB_CANNOT_BE_INTERCEPTOR;
import static org.jboss.weld.logging.messages.BeanMessage.EJB_NOT_FOUND;
+import static
org.jboss.weld.logging.messages.BeanMessage.GENERIC_SESSION_BEAN_MUST_BE_DEPENDENT;
import static
org.jboss.weld.logging.messages.BeanMessage.MESSAGE_DRIVEN_BEANS_CANNOT_BE_MANAGED;
import static
org.jboss.weld.logging.messages.BeanMessage.OBSERVER_METHOD_MUST_BE_STATIC_OR_BUSINESS;
import static
org.jboss.weld.logging.messages.BeanMessage.PROXY_INSTANTIATION_BEAN_ACCESS_FAILED;
@@ -42,6 +43,7 @@
import javax.decorator.Decorator;
import javax.enterprise.context.ApplicationScoped;
+import javax.enterprise.context.Dependent;
import javax.enterprise.context.spi.CreationalContext;
import javax.enterprise.event.Observes;
import javax.enterprise.inject.Typed;
@@ -342,6 +344,15 @@
}
@Override
+ protected void checkType()
+ {
+ if (!getScope().equals(Dependent.class) && getWeldAnnotated().isGeneric())
+ {
+ throw new DefinitionException(GENERIC_SESSION_BEAN_MUST_BE_DEPENDENT, this);
+ }
+ }
+
+ @Override
public boolean isPassivationCapableBean()
{
return getEjbDescriptor().isStateful();
Modified:
core/trunk/impl/src/main/java/org/jboss/weld/bean/builtin/AbstractBuiltInBean.java
===================================================================
---
core/trunk/impl/src/main/java/org/jboss/weld/bean/builtin/AbstractBuiltInBean.java 2010-02-17
14:09:04 UTC (rev 5863)
+++
core/trunk/impl/src/main/java/org/jboss/weld/bean/builtin/AbstractBuiltInBean.java 2010-02-17
14:10:43 UTC (rev 5864)
@@ -47,6 +47,11 @@
// No-op
}
+ @Override
+ public void initializeAfterBeanDiscovery()
+ {
+ // No-op
+ }
public Set<Annotation> getQualifiers()
{
Modified: core/trunk/impl/src/main/java/org/jboss/weld/bootstrap/BeanDeployment.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bootstrap/BeanDeployment.java 2010-02-17
14:09:04 UTC (rev 5863)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bootstrap/BeanDeployment.java 2010-02-17
14:10:43 UTC (rev 5864)
@@ -18,9 +18,9 @@
import static org.jboss.weld.logging.Category.BOOTSTRAP;
import static org.jboss.weld.logging.LoggerFactory.loggerFactory;
+import static org.jboss.weld.logging.messages.BootstrapMessage.ENABLED_ALTERNATIVES;
import static org.jboss.weld.logging.messages.BootstrapMessage.ENABLED_DECORATORS;
import static org.jboss.weld.logging.messages.BootstrapMessage.ENABLED_INTERCEPTORS;
-import static org.jboss.weld.logging.messages.BootstrapMessage.ENABLED_ALTERNATIVES;
import java.util.List;
@@ -165,7 +165,6 @@
if (bean instanceof RIBean<?>)
{
((RIBean<?>) bean).initializeAfterBeanDiscovery();
- ((RIBean<?>) bean).checkType();
}
}
}
Modified:
core/trunk/impl/src/main/java/org/jboss/weld/introspector/ForwardingWeldAnnotated.java
===================================================================
---
core/trunk/impl/src/main/java/org/jboss/weld/introspector/ForwardingWeldAnnotated.java 2010-02-17
14:09:04 UTC (rev 5863)
+++
core/trunk/impl/src/main/java/org/jboss/weld/introspector/ForwardingWeldAnnotated.java 2010-02-17
14:10:43 UTC (rev 5864)
@@ -72,6 +72,11 @@
{
return delegate().isStatic();
}
+
+ public boolean isGeneric()
+ {
+ return delegate().isGeneric();
+ }
public boolean isProxyable()
{
Modified: core/trunk/impl/src/main/java/org/jboss/weld/introspector/WeldAnnotated.java
===================================================================
---
core/trunk/impl/src/main/java/org/jboss/weld/introspector/WeldAnnotated.java 2010-02-17
14:09:04 UTC (rev 5863)
+++
core/trunk/impl/src/main/java/org/jboss/weld/introspector/WeldAnnotated.java 2010-02-17
14:10:43 UTC (rev 5864)
@@ -119,6 +119,8 @@
* @return True if static, false otherwise
*/
public boolean isStatic();
+
+ public boolean isGeneric();
/**
* Indicates if this AnnotatedItem represents a final element
Modified:
core/trunk/impl/src/main/java/org/jboss/weld/introspector/jlr/WeldClassImpl.java
===================================================================
---
core/trunk/impl/src/main/java/org/jboss/weld/introspector/jlr/WeldClassImpl.java 2010-02-17
14:09:04 UTC (rev 5863)
+++
core/trunk/impl/src/main/java/org/jboss/weld/introspector/jlr/WeldClassImpl.java 2010-02-17
14:10:43 UTC (rev 5864)
@@ -600,6 +600,11 @@
{
return Modifier.isFinal(getJavaClass().getModifiers());
}
+
+ public boolean isGeneric()
+ {
+ return getJavaClass().getTypeParameters().length > 0;
+ }
/**
* Gets the name of the type
Modified:
core/trunk/impl/src/main/java/org/jboss/weld/introspector/jlr/WeldConstructorImpl.java
===================================================================
---
core/trunk/impl/src/main/java/org/jboss/weld/introspector/jlr/WeldConstructorImpl.java 2010-02-17
14:09:04 UTC (rev 5863)
+++
core/trunk/impl/src/main/java/org/jboss/weld/introspector/jlr/WeldConstructorImpl.java 2010-02-17
14:10:43 UTC (rev 5864)
@@ -295,5 +295,10 @@
{
return Collections.unmodifiableList((List) parameters);
}
+
+ public boolean isGeneric()
+ {
+ return getJavaMember().getTypeParameters().length > 0;
+ }
}
Modified:
core/trunk/impl/src/main/java/org/jboss/weld/introspector/jlr/WeldFieldImpl.java
===================================================================
---
core/trunk/impl/src/main/java/org/jboss/weld/introspector/jlr/WeldFieldImpl.java 2010-02-17
14:09:04 UTC (rev 5863)
+++
core/trunk/impl/src/main/java/org/jboss/weld/introspector/jlr/WeldFieldImpl.java 2010-02-17
14:10:43 UTC (rev 5864)
@@ -134,5 +134,10 @@
{
return new StringBuilder().append("field
").append(getDeclaringType().getName()).append(".").append(field.getName()).toString();
}
+
+ public boolean isGeneric()
+ {
+ return false;
+ }
}
Modified:
core/trunk/impl/src/main/java/org/jboss/weld/introspector/jlr/WeldMethodImpl.java
===================================================================
---
core/trunk/impl/src/main/java/org/jboss/weld/introspector/jlr/WeldMethodImpl.java 2010-02-17
14:09:04 UTC (rev 5863)
+++
core/trunk/impl/src/main/java/org/jboss/weld/introspector/jlr/WeldMethodImpl.java 2010-02-17
14:10:43 UTC (rev 5864)
@@ -228,5 +228,10 @@
{
return Collections.unmodifiableList((List) parameters);
}
+
+ public boolean isGeneric()
+ {
+ return getJavaMember().getTypeParameters().length > 0;
+ }
}
Modified:
core/trunk/impl/src/main/java/org/jboss/weld/introspector/jlr/WeldParameterImpl.java
===================================================================
---
core/trunk/impl/src/main/java/org/jboss/weld/introspector/jlr/WeldParameterImpl.java 2010-02-17
14:09:04 UTC (rev 5863)
+++
core/trunk/impl/src/main/java/org/jboss/weld/introspector/jlr/WeldParameterImpl.java 2010-02-17
14:10:43 UTC (rev 5864)
@@ -109,6 +109,11 @@
return false;
}
+ public boolean isGeneric()
+ {
+ return false;
+ }
+
public Package getPackage()
{
return declaringMember.getPackage();
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 2010-02-17
14:09:04 UTC (rev 5863)
+++
core/trunk/impl/src/main/java/org/jboss/weld/logging/messages/BeanMessage.java 2010-02-17
14:10:43 UTC (rev 5864)
@@ -128,6 +128,7 @@
@MessageId("000091") IP_NOT_CONSTRUCTOR_OR_METHOD,
@MessageId("000092") PARAM_NOT_IN_PARAM_LIST,
@MessageId("000093") CANNOT_READ_OBJECT,
- @MessageId("000094") INJECTED_FIELD_CANNOT_BE_PRODUCER;
+ @MessageId("000094") INJECTED_FIELD_CANNOT_BE_PRODUCER,
+ @MessageId("000095") GENERIC_SESSION_BEAN_MUST_BE_DEPENDENT;
}
Modified: core/trunk/impl/src/main/java/org/jboss/weld/util/Beans.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/util/Beans.java 2010-02-17 14:09:04 UTC
(rev 5863)
+++ core/trunk/impl/src/main/java/org/jboss/weld/util/Beans.java 2010-02-17 14:10:43 UTC
(rev 5864)
@@ -408,7 +408,7 @@
{
throw new DefinitionException(INITIALIZER_CANNOT_BE_OBSERVER, method,
type);
}
- else if (method.getJavaMember().getTypeParameters().length > 0)
+ else if (method.isGeneric())
{
throw new DefinitionException(INITIALIZER_METHOD_IS_GENERIC, method,
type);
}
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 2010-02-17
14:09:04 UTC (rev 5863)
+++
core/trunk/impl/src/main/resources/org/jboss/weld/messages/bean_en.properties 2010-02-17
14:10:43 UTC (rev 5864)
@@ -93,3 +93,4 @@
PARAM_NOT_IN_PARAM_LIST=Parameter position {0} is not in the parameter list: {1}
CANNOT_READ_OBJECT=Cannot read object
INJECTED_FIELD_CANNOT_BE_PRODUCER=Injected field {0} cannot be annotated @Produces on
{1}
+GENERIC_SESSION_BEAN_MUST_BE_DEPENDENT=Session bean with generic class {0} must be
@Depedent scope