Module org.eclipse.persistence.jpa
Class PersistenceUnitProcessor
- java.lang.Object
-
- org.eclipse.persistence.internal.jpa.deployment.PersistenceUnitProcessor
-
public class PersistenceUnitProcessor extends Object
INTERNAL: Utility Class that deals with persistence archives for EJB 3.0 Provides functions like searching for persistence archives, processing persistence.xml and searching for Entities in a Persistence archive
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classPersistenceUnitProcessor.ModePassed to processORMetadata method to indicate processing mode.
-
Field Summary
Fields Modifier and Type Field Description static ArchiveFactoryARCHIVE_FACTORYCache the ArchiveFactory used to derive Archives.
-
Constructor Summary
Constructors Modifier Constructor Description protectedPersistenceUnitProcessor()Default constructor.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static StringbuildClassNameFromEntryString(String classEntryString)Entries in a zip file are directory entries using slashes to separate them.static Set<String>buildClassSet(jakarta.persistence.spi.PersistenceUnitInfo persistenceUnitInfo, Map properties)Build a set that contains all the class names at a URL.static Collection<MetadataClass>buildEntityList(MetadataProcessor processor, ClassLoader loader)Create a list of the entities that will be deployed.static StringbuildPersistenceUnitName(URL url, String puName)Build the unique persistence name by concatenating the decoded URL with the persistence unit name.static URLcomputePURootURL(URL pxmlURL, String descriptorLocation)Determine the URL path to the persistence unitstatic Set<Archive>findPersistenceArchives()Search the classpath for persistence archives.static Set<Archive>findPersistenceArchives(ClassLoader loader)Search the classpath for persistence archives.static Set<Archive>findPersistenceArchives(ClassLoader loader, String descriptorPath)Return a list of Archives representing the root of the persistence descriptor.static Set<Archive>findPersistenceArchives(ClassLoader loader, String descriptorPath, List<URL> jarFileUrls, Map properties)Return a list of Archives representing the root of the persistence descriptor.static ArchiveFactorygetArchiveFactory(ClassLoader loader)static ArchiveFactorygetArchiveFactory(ClassLoader loader, Map properties)static Set<String>getClassNamesFromURL(URL url, ClassLoader loader, Map properties)static MetadataAnnotationgetConverterAnnotation(MetadataClass candidateClass)Return if a given class is annotated with @Embeddable.static MetadataAnnotationgetEmbeddableAnnotation(MetadataClass candidateClass)Return if a given class is annotated with @Embeddable.static MetadataAnnotationgetEntityAnnotation(MetadataClass candidateClass)Return if a given class is annotated with @Entity.static MetadataAnnotationgetMappedSuperclassAnnotation(MetadataClass candidateClass)Return if a given class is annotated with @Entity.static Set<SEPersistenceUnitInfo>getPersistenceUnits(ClassLoader loader, Map m, List<URL> jarFileUrls)static List<SEPersistenceUnitInfo>getPersistenceUnits(Archive archive, ClassLoader loader)Get a list of persistence units from the file or directory at the given url.static MetadataAnnotationgetStaticMetamodelAnnotation(MetadataClass candidateClass)Return the @StaticMetamodel annotation on the given class.static booleanisConverter(MetadataClass candidateClass)Return if a given class is annotated with @Converter.static booleanisEmbeddable(MetadataClass candidateClass)Return if a given class is annotated with @Embeddable.static booleanisEntity(MetadataClass candidateClass)Return if a given class is annotated with @Entity.static booleanisMappedSuperclass(MetadataClass candidateClass)Return if a given class is annotated with @MappedSuperclass.static booleanisStaticMetamodelClass(MetadataClass candidateClass)Return if a given class is annotated with @StaticMetamodel.static Class<?>loadClass(String className, ClassLoader loader, boolean throwExceptionIfNotFound, MetadataProject project)Load the given class name with the given class loader.static voidprocessORMetadata(MetadataProcessor processor, boolean throwExceptionOnFail, PersistenceUnitProcessor.Mode mode)Process the Object/relational metadata from XML and annotationsstatic List<SEPersistenceUnitInfo>processPersistenceArchive(Archive archive, ClassLoader loader)Go through the jar file for this PersistenceUnitProcessor and process any XML provided in it.static voidsetArchiveFactory(ArchiveFactory factory)
-
-
-
Field Detail
-
ARCHIVE_FACTORY
public static ArchiveFactory ARCHIVE_FACTORY
Cache the ArchiveFactory used to derive Archives. This allows applications to set the ArchiveFactory
-
-
Method Detail
-
buildClassNameFromEntryString
public static String buildClassNameFromEntryString(String classEntryString)
Entries in a zip file are directory entries using slashes to separate them. Build a class name using '.' instead of slash and removing the '.class' extension.
-
buildClassSet
public static Set<String> buildClassSet(jakarta.persistence.spi.PersistenceUnitInfo persistenceUnitInfo, Map properties)
Build a set that contains all the class names at a URL.- Returns:
- a Set of class name strings
-
buildEntityList
public static Collection<MetadataClass> buildEntityList(MetadataProcessor processor, ClassLoader loader)
Create a list of the entities that will be deployed. This list is built from the information provided in the PersistenceUnitInfo argument. The list contains Classes specified in the PersistenceUnitInfo's class list and also files that are annotated with @Entity and @Embeddable in the jar files provided in the persistence info. This list of classes will used to build a deployment project and to decide what classes to weave.
-
computePURootURL
public static URL computePURootURL(URL pxmlURL, String descriptorLocation) throws IOException, URISyntaxException
Determine the URL path to the persistence unit- Parameters:
pxmlURL- - URL of a resource belonging to the PU (obtained fordescriptorLocationviaClassloader.getResource(String)).descriptorLocation- - the name of the resource.- Returns:
- The URL of the PU root containing the resource.
- Throws:
ValidationException- if the resolved root doesn't conform to the JPA specification (8.2)IOExceptionURISyntaxException
-
findPersistenceArchives
public static Set<Archive> findPersistenceArchives()
Search the classpath for persistence archives. A persistence archive is defined as any part of the class path that contains a META-INF directory with a persistence.xml file in it. Return a list of the URLs of those files. Use the current thread's context classloader to get the classpath. We assume it is a URL class loader.
-
findPersistenceArchives
public static Set<Archive> findPersistenceArchives(ClassLoader loader)
Search the classpath for persistence archives. A persistence archive is defined as any part of the class path that contains a META-INF directory with a persistence.xml file in it. Return a list ofArchiverepresenting the root of those files. It is the caller's responsibility to close all the archives.- Parameters:
loader- the class loader to get the class path from
-
findPersistenceArchives
public static Set<Archive> findPersistenceArchives(ClassLoader loader, String descriptorPath)
Return a list of Archives representing the root of the persistence descriptor. It is the caller's responsibility to close all the archives.- Parameters:
loader- the class loader to get the class path from
-
findPersistenceArchives
public static Set<Archive> findPersistenceArchives(ClassLoader loader, String descriptorPath, List<URL> jarFileUrls, Map properties)
Return a list of Archives representing the root of the persistence descriptor. It is the caller's responsibility to close all the archives.- Parameters:
loader- the class loader to get the class path from
-
getPersistenceUnits
public static Set<SEPersistenceUnitInfo> getPersistenceUnits(ClassLoader loader, Map m, List<URL> jarFileUrls)
-
getArchiveFactory
public static ArchiveFactory getArchiveFactory(ClassLoader loader)
-
getArchiveFactory
public static ArchiveFactory getArchiveFactory(ClassLoader loader, Map properties)
-
getClassNamesFromURL
public static Set<String> getClassNamesFromURL(URL url, ClassLoader loader, Map properties)
-
getConverterAnnotation
public static MetadataAnnotation getConverterAnnotation(MetadataClass candidateClass)
Return if a given class is annotated with @Embeddable.
-
getEmbeddableAnnotation
public static MetadataAnnotation getEmbeddableAnnotation(MetadataClass candidateClass)
Return if a given class is annotated with @Embeddable.
-
getEntityAnnotation
public static MetadataAnnotation getEntityAnnotation(MetadataClass candidateClass)
Return if a given class is annotated with @Entity.
-
getPersistenceUnits
public static List<SEPersistenceUnitInfo> getPersistenceUnits(Archive archive, ClassLoader loader)
Get a list of persistence units from the file or directory at the given url. PersistenceUnits are built based on the presence of a persistence descriptor *- Parameters:
archive- The url of a jar file or directory to check
-
getMappedSuperclassAnnotation
public static MetadataAnnotation getMappedSuperclassAnnotation(MetadataClass candidateClass)
Return if a given class is annotated with @Entity.
-
getStaticMetamodelAnnotation
public static MetadataAnnotation getStaticMetamodelAnnotation(MetadataClass candidateClass)
Return the @StaticMetamodel annotation on the given class.
-
isConverter
public static boolean isConverter(MetadataClass candidateClass)
Return if a given class is annotated with @Converter.
-
isEmbeddable
public static boolean isEmbeddable(MetadataClass candidateClass)
Return if a given class is annotated with @Embeddable.
-
isEntity
public static boolean isEntity(MetadataClass candidateClass)
Return if a given class is annotated with @Entity.
-
isStaticMetamodelClass
public static boolean isStaticMetamodelClass(MetadataClass candidateClass)
Return if a given class is annotated with @StaticMetamodel.
-
isMappedSuperclass
public static boolean isMappedSuperclass(MetadataClass candidateClass)
Return if a given class is annotated with @MappedSuperclass.
-
loadClass
public static Class<?> loadClass(String className, ClassLoader loader, boolean throwExceptionIfNotFound, MetadataProject project)
Load the given class name with the given class loader.
-
processORMetadata
public static void processORMetadata(MetadataProcessor processor, boolean throwExceptionOnFail, PersistenceUnitProcessor.Mode mode)
Process the Object/relational metadata from XML and annotations
-
processPersistenceArchive
public static List<SEPersistenceUnitInfo> processPersistenceArchive(Archive archive, ClassLoader loader)
Go through the jar file for this PersistenceUnitProcessor and process any XML provided in it.
-
setArchiveFactory
public static void setArchiveFactory(ArchiveFactory factory)
-
-