users@jpa-spec.java.net

[jpa-spec users] [jsr338-experts] difficulty in ensuring PersistenceUnitInfo.addTransformer(ClassTransformer transformer) happens before application classes are loaded...

From: Scott Marlow <smarlow_at_redhat.com>
Date: Fri, 06 Jul 2012 10:30:25 -0400

Does anyone else want to see improvements in how
PersistenceProvider.createContainerEntityManagerFactory() is expected to
allow PersistenceUnitInfo.addTransformer(ClassTransformer transformer)
to register class transformers before application classes are loaded?

As more EE application server implementations look to deploy
applications in parallel (making full use of all CPU cores), ensuring
that the PersistenceProvider.createContainerEntityManagerFactory() is
called before any application classes are loaded, having a separate way
to invoke the PersistenceUnitInfo.addTransformer becomes more important.
  Then it doesn't matter if
PersistenceProvider.createContainerEntityManagerFactory() is invoked
after application classes have been loaded (as long as the
addTransformer() happened early enough).

For example, if I want to also use datasources during
createContainerEntityManagerFactory(), I will need
@DataSourceDefinitions to already be scanned and deployed.

I have some ideas in mind but maybe you have something better. So, my
two questions are:

1. Do you agree that this should be addressed in the JPA 2.1 specification?

2. How can we separate the registration of the class transformers from
the provider.createContainerEntityManagerFactory()?

Scott