/* * Copyright 2005-2010 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.wamblee.test.inject; import javax.persistence.EntityManager; import org.wamblee.inject.Injector; import org.wamblee.inject.InjectorFactory; import org.wamblee.inject.InjectorBuilder; 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 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)
.
*