From: Erik Brakkee Date: Thu, 15 Jul 2010 13:48:52 +0000 (+0000) Subject: (no commit message) X-Git-Tag: wamblee-utils-0.7~332 X-Git-Url: http://wamblee.org/gitweb/?a=commitdiff_plain;h=1440f7475e4a7d3ae9e6e756b3a58572a57e9521;p=utils --- diff --git a/support/cdi/src/main/java/org/wamblee/cdi/CdiInjector.java b/support/cdi/src/main/java/org/wamblee/cdi/CdiInjector.java index b0ce9071..ccf716c9 100644 --- a/support/cdi/src/main/java/org/wamblee/cdi/CdiInjector.java +++ b/support/cdi/src/main/java/org/wamblee/cdi/CdiInjector.java @@ -56,7 +56,7 @@ public class CdiInjector implements Injector { public void inject(Object aComponent) { if (aComponent != null) { if (!clazz.isInstance(aComponent)) { - throw new RuntimeException("Object '" + aComponent + + throw new IllegalArgumentException("Object '" + aComponent + "' is of type " + aComponent.getClass().getName() + " but expected " + clazz.getName()); } diff --git a/support/cdi/src/main/java/org/wamblee/cdi/CdiInjectorFactory.java b/support/cdi/src/main/java/org/wamblee/cdi/CdiInjectorFactory.java index 2237648b..c41f2d98 100644 --- a/support/cdi/src/main/java/org/wamblee/cdi/CdiInjectorFactory.java +++ b/support/cdi/src/main/java/org/wamblee/cdi/CdiInjectorFactory.java @@ -35,9 +35,11 @@ public class CdiInjectorFactory implements InjectorFactory { .getLogger(CdiInjectorFactory.class.getName()); private BeanManager beanManager; - + /** - * Constructs the factory using the default bean manager. + * Constructs the factory using a default bean manager. + * + * @throws IllegalArgumentException If bean manager is null. */ public CdiInjectorFactory() { this(BeanManagerLookup.lookup()); @@ -47,22 +49,17 @@ public class CdiInjectorFactory implements InjectorFactory { * Constructs the factory using an explicit bean manager. * * @param aBeanManager + * @throws IllegalArgumentException If bean manager is null. */ public CdiInjectorFactory(BeanManager aBeanManager) { + if ( aBeanManager == null ) { + throw new IllegalArgumentException("Bean manager is null"); + } beanManager = aBeanManager; } @Override public Injector create(Class aClass) { - if (beanManager == null) { - // Typically for unit test. - return new Injector() { - @Override - public void inject(Object aComponent) { - // Empty. - } - }; - } return new CdiInjector(beanManager, aClass); }