}
// Needs to bind object
// Persistence context
EZBPersistenceUnitManager persistenceUnitManager = this.injectionHolder.getPersistenceUnitManager();
for (IENCBinding<IJavaxPersistenceContext> binding : this.encBindingHolder.getPersistenceContextBindings()) {
String encName = binding.getName();
String unitName = binding.getValue().getUnitName();
PersistenceContextType type = binding.getValue().getType();
EntityManager em = persistenceUnitManager.getEntityManager(unitName, type);
try {
createSubcontexts(envCtx, encName);
envCtx.rebind(encName, em);
if (this.logger.isDebugEnabled()) {
this.logger.debug("Adding persistence-context 'java:comp/env/" + encName + "'");
}
} catch (NamingException e) {
this.logger.error("Unable to bind persistence-context in ENC", e);
}
}
// Persistence unit
for (IENCBinding<IJavaxPersistenceUnit> binding : this.encBindingHolder.getPersistenceUnitBindings()) {
String encName = binding.getName();
String unitName = binding.getValue().getUnitName();
EntityManagerFactory emf = persistenceUnitManager.getEntityManagerFactory(unitName);
try {
createSubcontexts(envCtx, encName);
envCtx.rebind(encName, emf);
if (this.logger.isDebugEnabled()) {