- * Constructs the factory with the default injector factory obtained from
- * {@link InjectorBuilder#getInjector()}.
- * @param aEntityManager Contextual entity manager 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);
+ addBinding(em);
+ return this;
+ }
+
+ /**
+ * Adds another custom injection binding.
+ *
+ * @param aBinding
+ * Injection binding to use.
+ * @return the factoryto allow chaining.
+ */
+ public JavaEETestInjectorFactory addBinding(Binding aBinding) {
+ bindings.add(aBinding);
+ return this;
+ }
+
+ /**
+ * Constructs the factory with the default injector factory obtained from
+ * {@link InjectorBuilder#getInjector()}.