Skip to content

Commit

Permalink
add PUI.getAllManagedClassNames and PP.getClassTransformer
Browse files Browse the repository at this point in the history
see issue jakartaee#650

Signed-off-by: Gavin King <[email protected]>
  • Loading branch information
gavinking committed Sep 20, 2024
1 parent 1aac75c commit 0f9b0ab
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 3 deletions.
33 changes: 33 additions & 0 deletions api/src/main/java/jakarta/persistence/spi/PersistenceProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
*/

// Contributors:
// Gavin King - 4.0
// Gavin King - 3.2
// Linda DeMichiel - 2.1
// Linda DeMichiel - 2.0
Expand Down Expand Up @@ -138,5 +139,37 @@ public interface PersistenceProvider {
* @since 2.0
*/
ProviderUtil getProviderUtil();

/**
* Obtain a transformer supplied by the provider that is called
* for every new class definition or class redefinition that gets
* loaded by the loader returned by the
* {@link PersistenceUnitInfo#getClassLoader} method. The
* transformer has no effect on the result returned by the
* {@link PersistenceUnitInfo#getNewTempClassLoader} method.
* Classes are only transformed once within the same classloading
* scope, regardless of how many persistence units they may be
* a part of.
* <p>The given instance of {@link PersistenceUnitInfo} may
* return {@code null} when any one the accessor methods
* {@link PersistenceUnitInfo#getClassLoader()},
* {@link PersistenceUnitInfo#getJtaDataSource()}, or
* {@link PersistenceUnitInfo#getNonJtaDataSource()} is called
* by an implementation of this method.
* <p>If the container calls this method before invoking
* {@link #createContainerEntityManagerFactory} to create the
* {@link EntityManagerFactory}, then the transformer returned
* by this method is used instead of any transformer registered
* via {@link PersistenceUnitInfo#addTransformer}. The container
* is not required to call this method.
* @return provider-supplied transformer that the
* container invokes at class-(re)definition time
* @param info metadata for use by the persistence provider
* @param map a Map of integration-level properties for use
* by the persistence provider, which will not usually contain
* a {@code ValidatorFactory} or {@code BeanManager}.
* @since 4.0
*/
ClassTransformer getClassTransformer(PersistenceUnitInfo info, Map<?, ?> map);
}

22 changes: 19 additions & 3 deletions api/src/main/java/jakarta/persistence/spi/PersistenceUnitInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
*/

// Contributors:
// Gavin King - 4.0
// Lukas Jungmann - 3.2
// Linda DeMichiel - 2.1
// Linda DeMichiel - 2.0
Expand All @@ -19,6 +20,7 @@

import javax.sql.DataSource;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.net.URL;
import jakarta.persistence.SharedCacheMode;
Expand Down Expand Up @@ -147,14 +149,25 @@ public interface PersistenceUnitInfo {
/**
* Returns the list of the names of the classes that the
* persistence provider must add to its set of managed
* classes. Each name corresponds to a named {@code class} element in the
* {@code persistence.xml} file.
* classes. Each name corresponds to a named {@code class}
* element in the {@code persistence.xml} file.
* @return the list of the names of the classes that the
* persistence provider must add to its set of managed
* classes
*/
List<String> getManagedClassNames();

/**
* Returns the list of names of all managed classes in
* the persistence unit, whether named explicitly in the
* {@code persistence.xml} file, or discovered by the
* container via scanning.
* @return the list of names of all managed classes in
* the persistence unit
* @since 4.0
*/
List<String> getAllManagedClassNames();

/**
* Returns whether classes in the root of the persistence unit
* that have not been explicitly listed are to be included in the
Expand Down Expand Up @@ -225,7 +238,10 @@ public interface PersistenceUnitInfo {
* Classes are only transformed once within the same classloading
* scope, regardless of how many persistence units they may be
* a part of.
* @param transformer provider-supplied transformer that the
* <p>If the container previously called
* {@link PersistenceProvider#getClassTransformer} with this
* {@code PersistenceUnitInfo}, then this method has no effect.
* @param transformer provider-supplied transformer that the
* container invokes at class-(re)definition time
*/
void addTransformer(ClassTransformer transformer);
Expand Down

0 comments on commit 0f9b0ab

Please sign in to comment.