JSR-352: Rework how the retrieval of the EntityManagerFactory works

Description

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.

Activity

Fixed

Details

Assignee

Reporter

Components

Fix versions

Priority

Created April 20, 2017 at 6:21 PM
Updated December 3, 2024 at 11:53 AM
Resolved May 2, 2017 at 8:22 AM