@Override public ResourceReference<EntityManager> createResource() { final TransactionScopedEntityManager result = new TransactionScopedEntityManager(scopedPuName, new HashMap<>(), entityManagerFactory, context.synchronization(), transactionSynchronizationRegistry, transactionManager); return new SimpleResourceReference<EntityManager>(result); } }
@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, transactionSynchronizationRegistry, transactionManager)))); }
@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, transactionSynchronizationRegistry, transactionManager)))); }
@Override public EntityManager resolvePersistenceContext(InjectionPoint injectionPoint) { //TODO: cache this stuff final PersistenceContext context = injectionPoint.getAnnotated().getAnnotation(PersistenceContext.class); if (context == null) { throw WeldMessages.MESSAGES.annotationNotFound(PersistenceContext.class, injectionPoint.getMember()); } final String scopedPuName = getScopedPUName(deploymentUnit, context.unitName()); final ServiceName persistenceUnitServiceName = PersistenceUnitServiceImpl.getPUServiceName(scopedPuName); final ServiceController<?> serviceController = serviceRegistry.getRequiredService(persistenceUnitServiceName); //now we have the service controller, as this method is only called at runtime the service should //always be up PersistenceUnitServiceImpl persistenceUnitService = (PersistenceUnitServiceImpl) serviceController.getValue(); return new TransactionScopedEntityManager(scopedPuName, new HashMap<Object, Object>(), persistenceUnitService.getEntityManagerFactory()); }
TransactionManager transactionManager = ContextTransactionManager.getInstance(); if (type.equals(PersistenceContextType.TRANSACTION)) { entityManager = new TransactionScopedEntityManager(unitName, properties, emf, synchronizationType, tsr, transactionManager); if (ROOT_LOGGER.isDebugEnabled()) ROOT_LOGGER.debugf("created new TransactionScopedEntityManager for unit name=%s", unitName);
TransactionManager transactionManager = (TransactionManager) serviceRegistry.getRequiredService(TransactionManagerService.SERVICE_NAME).getValue(); if (type.equals(PersistenceContextType.TRANSACTION)) { entityManager = new TransactionScopedEntityManager(unitName, properties, emf, synchronizationType, tsr, transactionManager); if (ROOT_LOGGER.isDebugEnabled()) ROOT_LOGGER.debugf("created new TransactionScopedEntityManager for unit name=%s", unitName);