X-Git-Url: http://wamblee.org/gitweb/?a=blobdiff_plain;f=support%2Fcdi%2Fsrc%2Fmain%2Fjava%2Forg%2Fwamblee%2Fcdi%2FCdiInjectorFactory.java;h=a4e575aa7f8b7bee581808a737948df1dc6e7d6b;hb=f6eb1a70ec5bb7a65a018dd5756b110bbd3aebb9;hp=74d1a669227a8b3d393504813cec02007939cd2d;hpb=b497fef281fd42b4b2cd2153d2e8790a80558d50;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 74d1a669..a4e575aa 100644 --- a/support/cdi/src/main/java/org/wamblee/cdi/CdiInjectorFactory.java +++ b/support/cdi/src/main/java/org/wamblee/cdi/CdiInjectorFactory.java @@ -19,10 +19,12 @@ import java.util.logging.Logger; import javax.enterprise.inject.spi.BeanManager; +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 - * override the injectors that are returned. + * Factory that creates CDI injectors. This class may be subclassed for testing + * to override the injectors that are returned. * * @author Erik Brakkee */ @@ -34,7 +36,10 @@ public class CdiInjectorFactory implements InjectorFactory { 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()); @@ -44,22 +49,18 @@ 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); }