| See https://github.com/WASdev/standards.jsr352.jbatch/issues/50 for an explanation; in short, our whole approach to store the entity manager factory in the job context is invalid in the reference implementation for JSR-352, so we should rework it. I think our best course of action would be to:
- rely on injection in order to retrieve the EntityManagerFactoryRegistry instead of requiring users to override JobContextSetupListener. We would have, whenever we need to retrieve the entity manager factory, a property like `@Inject private EntityManagerFactoryRegistry emfRegistry`, plus the two batch properties `entityManagerFactoryScope` and `entityManagerFactoryReference`.
- move the code currently in JobContextSetupListener to a static utility class, and reuse it wherever we know that the job context may not be set up yet (i.e. when the job starts and when a partition starts).
This implies one major change: remove support for `ActiveSessionFactoryRegistry` (useful in Java SE applications), because if we need injection anyway, there's no reason for such a hack. |