Skip to content

Commit

Permalink
WELD-426, WELD-428, WELD-431
Browse files Browse the repository at this point in the history
  • Loading branch information
pmuir committed Feb 17, 2010
1 parent 464b582 commit 8d92a31
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
16 changes: 12 additions & 4 deletions impl/src/main/java/org/jboss/weld/bean/AbstractProducerBean.java
Expand Up @@ -26,8 +26,9 @@
import static org.jboss.weld.logging.messages.BeanMessage.NULL_NOT_ALLOWED_FROM_PRODUCER;
import static org.jboss.weld.logging.messages.BeanMessage.ONLY_ONE_SCOPE_ALLOWED;
import static org.jboss.weld.logging.messages.BeanMessage.PRODUCER_CAST_ERROR;
import static org.jboss.weld.logging.messages.BeanMessage.PRODUCER_METHOD_WITH_TYPE_VARIABLE_RETURN_TYPE_MUST_BE_DEPENDENT;
import static org.jboss.weld.logging.messages.BeanMessage.PRODUCER_METHOD_WITH_WILDCARD_RETURN_TYPE_MUST_BE_DEPENDENT;
import static org.jboss.weld.logging.messages.BeanMessage.RETURN_TYPE_MUST_BE_CONCRETE;
import static org.jboss.weld.logging.messages.BeanMessage.TYPE_PARAMETER_MUST_BE_CONCRETE;
import static org.jboss.weld.logging.messages.BeanMessage.USING_DEFAULT_SCOPE;
import static org.jboss.weld.logging.messages.BeanMessage.USING_SCOPE;

Expand Down Expand Up @@ -172,11 +173,18 @@ protected void checkProducerReturnType()
{
throw new DefinitionException(RETURN_TYPE_MUST_BE_CONCRETE, getWeldAnnotated().getBaseType());
}
for (Type type : getWeldAnnotated().getActualTypeArguments())
else if (getWeldAnnotated().isParameterizedType())
{
if (!(type instanceof Class<?>))
for (Type type : getWeldAnnotated().getActualTypeArguments())
{
throw new DefinitionException(TYPE_PARAMETER_MUST_BE_CONCRETE, this.getWeldAnnotated());
if (!Dependent.class.equals(getScope()) && type instanceof TypeVariable<?>)
{
throw new DefinitionException(PRODUCER_METHOD_WITH_TYPE_VARIABLE_RETURN_TYPE_MUST_BE_DEPENDENT, getWeldAnnotated());
}
else if (type instanceof WildcardType)
{
throw new DefinitionException(PRODUCER_METHOD_WITH_WILDCARD_RETURN_TYPE_MUST_BE_DEPENDENT, getWeldAnnotated());
}
}
}
}
Expand Down
Expand Up @@ -130,6 +130,8 @@ public enum BeanMessage
@MessageId("000093") CANNOT_READ_OBJECT,
@MessageId("000094") INJECTED_FIELD_CANNOT_BE_PRODUCER,
@MessageId("000095") GENERIC_SESSION_BEAN_MUST_BE_DEPENDENT,
@MessageId("000096") PRODUCER_FIELD_ON_SESSION_BEAN_MUST_BE_STATIC;
@MessageId("000096") PRODUCER_FIELD_ON_SESSION_BEAN_MUST_BE_STATIC,
@MessageId("000097") PRODUCER_METHOD_WITH_TYPE_VARIABLE_RETURN_TYPE_MUST_BE_DEPENDENT,
@MessageId("000098") PRODUCER_METHOD_WITH_WILDCARD_RETURN_TYPE_MUST_BE_DEPENDENT;

}
Expand Up @@ -94,4 +94,6 @@ 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
PRODUCER_FIELD_ON_SESSION_BEAN_MUST_BE_STATIC=Producer fields on session beans must be static. Field {0} declared on {1}
PRODUCER_FIELD_ON_SESSION_BEAN_MUST_BE_STATIC=Producer fields on session beans must be static. Field {0} declared on {1}
PRODUCER_METHOD_WITH_TYPE_VARIABLE_RETURN_TYPE_MUST_BE_DEPENDENT=A producer method with a parameterized return type with a type variable must be declared @Dependent scoped. Method {0}
PRODUCER_METHOD_WITH_WILDCARD_RETURN_TYPE_MUST_BE_DEPENDENT=A producer method with a parameterized return type with a wildcard must be declared @Dependent scoped. Method {0}

0 comments on commit 8d92a31

Please sign in to comment.