}
public void inject(InjectionContainer container)
{
String error1 = error;
ManagedEntityManagerFactory factory = null;
try
{
factory = PersistenceUnitHandler.getManagedEntityManagerFactory(
container, unitName);
}
catch (NameNotFoundException e)
{
error1 += " " + e.getMessage();
}
if (factory == null)
{
throw new RuntimeException(error1);
}
if (type == PersistenceContextType.EXTENDED)
{
if (!(container instanceof StatefulContainer))
throw new RuntimeException("It is illegal to inject an EXTENDED PC into something other than a SFSB");
container.getInjectors().add(0, new ExtendedPersistenceContextInjector(factory));
Object extendedPc;
if (injectionType == null
|| injectionType.getName().equals(EntityManager.class.getName()))
{
extendedPc = new ExtendedEntityManager(factory.getKernelName());
}
else
{
ExtendedSessionInvocationHandler handler = new ExtendedSessionInvocationHandler(factory.getKernelName());
extendedPc = Proxy.newProxyInstance(
Session.class.getClassLoader(), //use the Hibernate classloader so the proxy has the same scope as Hibernate
SESS_PROXY_INTERFACES,
handler
);