Skip to content

Commit

Permalink
WELD-497
Browse files Browse the repository at this point in the history
  • Loading branch information
pmuir committed May 27, 2010
1 parent 7933d9b commit 7e7cd8c
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
Expand Up @@ -60,5 +60,9 @@ public enum BeanManagerMessage
@MessageId("001320") INJECTION_ON_NON_CONTEXTUAL,
@MessageId("001321") MISSING_BEAN_CONSTRUCTOR_FOUND,
@MessageId("001322") ERROR_INVOKING_POST_CONSTRUCT,
@MessageId("001323") ERROR_INVOKING_PRE_DESTROY;
@MessageId("001323") ERROR_INVOKING_PRE_DESTROY,
@MessageId("001324") NULL_BEAN_ARGUMENT,
@MessageId("001324") NULL_BEAN_TYPE_ARGUMENT,
@MessageId("001324") NULL_CREATIONAL_CONTEXT_ARGUMENT
;
}
15 changes: 15 additions & 0 deletions impl/src/main/java/org/jboss/weld/manager/BeanManagerImpl.java
Expand Up @@ -23,6 +23,9 @@
import static org.jboss.weld.logging.messages.BeanManagerMessage.NOT_INTERCEPTOR_BINDING_TYPE;
import static org.jboss.weld.logging.messages.BeanManagerMessage.NOT_STEREOTYPE;
import static org.jboss.weld.logging.messages.BeanManagerMessage.NO_DECORATOR_TYPES;
import static org.jboss.weld.logging.messages.BeanManagerMessage.NULL_BEAN_ARGUMENT;
import static org.jboss.weld.logging.messages.BeanManagerMessage.NULL_BEAN_TYPE_ARGUMENT;
import static org.jboss.weld.logging.messages.BeanManagerMessage.NULL_CREATIONAL_CONTEXT_ARGUMENT;
import static org.jboss.weld.logging.messages.BeanManagerMessage.SPECIFIED_TYPE_NOT_BEAN_TYPE;
import static org.jboss.weld.logging.messages.BeanManagerMessage.TOO_MANY_ACTIVITIES;
import static org.jboss.weld.logging.messages.BeanManagerMessage.UNPROXYABLE_RESOLUTION;
Expand Down Expand Up @@ -727,6 +730,18 @@ else if (bean instanceof RIBean<?>)

public Object getReference(Bean<?> bean, Type beanType, CreationalContext<?> creationalContext)
{
if (bean == null)
{
throw new ForbiddenArgumentException(NULL_BEAN_ARGUMENT);
}
if (beanType == null)
{
throw new ForbiddenArgumentException(NULL_BEAN_TYPE_ARGUMENT);
}
if (creationalContext == null)
{
throw new ForbiddenArgumentException(NULL_CREATIONAL_CONTEXT_ARGUMENT);
}
if (!Reflections.isAssignableFrom(bean.getTypes(), beanType))
{
throw new ForbiddenArgumentException(SPECIFIED_TYPE_NOT_BEAN_TYPE, beanType, bean );
Expand Down
Expand Up @@ -22,3 +22,6 @@ INJECTION_ON_NON_CONTEXTUAL=Cannot inject into a non-contextual type: {0}
MISSING_BEAN_CONSTRUCTOR_FOUND=Bean constructor was not found before but appears to be found now
ERROR_INVOKING_POST_CONSTRUCT=Error invoking post construct method {0}
ERROR_INVOKING_PRE_DESTROY=Error invoking pre-destroy method {0}
NULL_BEAN_ARGUMENT=Argument bean must not be null
NULL_BEAN_TYPE_ARGUMENT=Argument beanType must not be null
NULL_CREATIONAL_CONTEXT_ARGUMENT=Argument creationalContext must not be null

0 comments on commit 7e7cd8c

Please sign in to comment.