X-Git-Url: http://wamblee.org/gitweb/?a=blobdiff_plain;f=support%2Fcdi%2Fsrc%2Fmain%2Fjava%2Forg%2Fwamblee%2Fcdi%2FCdiInjectorFactory.java;h=de13ef54df162641c6552350a1508e25cef209ce;hb=5e96c198e399c3cd0f22f534eb1166876dcd8284;hp=2237648b0b5b58f91521976886558970eec643a5;hpb=234106bc9380153b79e9753b88861756b2637167;p=utils 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..de13ef54 100644 --- a/support/cdi/src/main/java/org/wamblee/cdi/CdiInjectorFactory.java +++ b/support/cdi/src/main/java/org/wamblee/cdi/CdiInjectorFactory.java @@ -23,8 +23,7 @@ import org.wamblee.inject.Injector; import org.wamblee.inject.InjectorFactory; /** - * Factory that creates CDI injectors. In case no beanmanager is found then - * injectors will do nothing. This class may be subclassed for testing to + * Factory that creates CDI injectors. This class may be subclassed for testing to * override the injectors that are returned. * * @author Erik Brakkee @@ -35,9 +34,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 +48,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); }