X-Git-Url: http://wamblee.org/gitweb/?a=blobdiff_plain;f=test%2Fenterprise%2Fsrc%2Fmain%2Fjava%2Forg%2Fwamblee%2Ftest%2Finject%2FJavaEETestInjectorFactory.java;h=f5814981064a369c26929b034732c976c233f13f;hb=83898516d61bfcd1f4e3a3ea79bb56f3877f4900;hp=fdfb84a782ba71993d92788075515677590274ce;hpb=a1ab1a2e44c95cc10ad4c4d15420b49e3744d93b;p=utils diff --git a/test/enterprise/src/main/java/org/wamblee/test/inject/JavaEETestInjectorFactory.java b/test/enterprise/src/main/java/org/wamblee/test/inject/JavaEETestInjectorFactory.java index fdfb84a7..f5814981 100644 --- a/test/enterprise/src/main/java/org/wamblee/test/inject/JavaEETestInjectorFactory.java +++ b/test/enterprise/src/main/java/org/wamblee/test/inject/JavaEETestInjectorFactory.java @@ -28,65 +28,76 @@ import org.wamblee.test.persistence.JpaBuilder; /** *

- * The test injector factory provides dependency injection of a contextual entity manager - * using the support/inject mini framework. It supports dependency injection of fields - * annoted with @PersistenceContext. It only supports one persistence context - * at the moment. This injector can be easily used together with {@link JpaBuilder#getContextualEntityManager()} - * for obtaining an entity manager in unit test. + * The test injector factory provides dependency injection of a contextual + * entity manager using the support/inject mini framework. It supports + * dependency injection of fields annoted with + * @PersistenceContext. It only supports one persistence + * context at the moment. This injector can be easily used together with + * {@link JpaBuilder#getContextualEntityManager()} for obtaining an entity + * manager in unit test. *

* *

- * The reason it is needed is because standard injection mechanisms (such as weld CDI) do not support - * entity manager injection in a Java SE environment out of the box. + * The reason it is needed is because standard injection mechanisms (such as + * weld CDI) do not support entity manager injection in a Java SE environment + * out of the box. *

- * + * *

- * To use it, construct the factory using one of the available constructors and set - * InjectorBuilder.setInjectorFactory(InjectorFactory). + * To use it, construct the factory using one of the available constructors and + * set InjectorBuilder.setInjectorFactory(InjectorFactory). *

* * @author Erik Brakkee - * + * */ public class JavaEETestInjectorFactory implements InjectorFactory { private List bindings; private InjectorFactory delegate; - + /** - * Constructs the factory. - * @param aInjectorFactory Injector factory to delegate to. + * Constructs the factory. + * + * @param aInjectorFactory + * Injector factory to delegate to. */ public JavaEETestInjectorFactory(InjectorFactory aInjectorFactory) { - bindings = new ArrayList(); + bindings = new ArrayList(); delegate = aInjectorFactory; } /** - * Adds default entity manager binding. Any field annotated with @PersistenceContext and of type - * entity manager will get injected. - * @param aEntityManager Entitymanager object to inject. + * Adds default entity manager binding. Any field annotated with @PersistenceContext + * and of type entity manager will get injected. + * + * @param aEntityManager + * Entitymanager object to inject. * @return Factory to allow chaining. */ - public JavaEETestInjectorFactory addEntityManagerBinding(EntityManager aEntityManager) { - Binding em = new Binding(EntityManager.class, PersistenceContext.class, aEntityManager); + public JavaEETestInjectorFactory addEntityManagerBinding( + EntityManager aEntityManager) { + Binding em = new Binding(EntityManager.class, PersistenceContext.class, + aEntityManager); addBinding(em); return this; } - + /** - * Adds another custom injection binding. - * @param aBinding Injection binding to use. + * Adds another custom injection binding. + * + * @param aBinding + * Injection binding to use. * @return the factoryto allow chaining. */ - public JavaEETestInjectorFactory addBinding(Binding aBinding) { + public JavaEETestInjectorFactory addBinding(Binding aBinding) { bindings.add(aBinding); - return this; + return this; } /** - * Constructs the factory with the default injector factory obtained from - * {@link InjectorBuilder#getInjector()}. + * Constructs the factory with the default injector factory obtained from + * {@link InjectorBuilder#getInjector()}. */ public JavaEETestInjectorFactory() { this(getDefaultInjectorFactory()); @@ -99,7 +110,6 @@ public class JavaEETestInjectorFactory implements InjectorFactory { @Override public Injector create(Class aClass) { - return new JavaEETestInjector(aClass, bindings, delegate - .create(aClass)); + return new JavaEETestInjector(aClass, bindings, delegate.create(aClass)); } }