}
else {
bindingInfo = ContextNames.bindInfoFor(jndiName);
}
JPA_LOGGER.tracef("binding the transaction scoped entity manager to jndi name '%s'", bindingInfo.getAbsoluteJndiName());
final BinderService binderService = new BinderService(bindingInfo.getBindName());
serviceTarget.addService(bindingInfo.getBinderServiceName(), binderService)
.addDependency(bindingInfo.getParentContextServiceName(), ServiceBasedNamingStore.class, binderService.getNamingStoreInjector())
.addDependency(puServiceName, PersistenceUnitServiceImpl.class, new Injector<PersistenceUnitServiceImpl>() {
@Override
public void inject(final PersistenceUnitServiceImpl value) throws
InjectionException {
binderService.getManagedObjectInjector().inject(new ValueManagedReferenceFactory(
new ImmediateValue<Object>(
new TransactionScopedEntityManager(
pu.getScopedPersistenceUnitName(),
Collections.emptyMap(),
value.getEntityManagerFactory(),
SynchronizationType.SYNCHRONIZED))));
}
@Override
public void uninject() {
binderService.getNamingStoreInjector().uninject();
}
}).install();
}
}