Module org.eclipse.persistence.jpa
Class PersistenceUnitProcessor
java.lang.Object
org.eclipse.persistence.internal.jpa.deployment.PersistenceUnitProcessor
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
Modifier and TypeClassDescriptionstatic enum
Passed to processORMetadata method to indicate processing mode. -
Field Summary
Modifier and TypeFieldDescriptionstatic ArchiveFactory
Cache the ArchiveFactory used to derive Archives. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic String
buildClassNameFromEntryString
(String classEntryString) Entries in a zip file are directory entries using slashes to separate them.buildClassSet
(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 String
buildPersistenceUnitName
(URL url, String puName) Build the unique persistence name by concatenating the decoded URL with the persistence unit name.static URL
computePURootURL
(URL pxmlURL, String descriptorLocation) Determine the URL path to the persistence unitSearch the classpath for persistence archives.findPersistenceArchives
(ClassLoader loader) Search the classpath for persistence archives.findPersistenceArchives
(ClassLoader loader, String descriptorPath) Return a list of Archives representing the root of the persistence descriptor.findPersistenceArchives
(ClassLoader loader, String descriptorPath, List<URL> jarFileUrls, Map properties) Return a list of Archives representing the root of the persistence descriptor.static ArchiveFactory
getArchiveFactory
(ClassLoader loader) static ArchiveFactory
getArchiveFactory
(ClassLoader loader, Map properties) getClassNamesFromURL
(URL url, ClassLoader loader, Map properties) static MetadataAnnotation
getConverterAnnotation
(MetadataClass candidateClass) Return if a given class is annotated with @Embeddable.static MetadataAnnotation
getEmbeddableAnnotation
(MetadataClass candidateClass) Return if a given class is annotated with @Embeddable.static MetadataAnnotation
getEntityAnnotation
(MetadataClass candidateClass) Return if a given class is annotated with @Entity.static MetadataAnnotation
getMappedSuperclassAnnotation
(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 MetadataAnnotation
getStaticMetamodelAnnotation
(MetadataClass candidateClass) Return the @StaticMetamodel annotation on the given class.static boolean
isConverter
(MetadataClass candidateClass) Return if a given class is annotated with @Converter.static boolean
isEmbeddable
(MetadataClass candidateClass) Return if a given class is annotated with @Embeddable.static boolean
isEntity
(MetadataClass candidateClass) Return if a given class is annotated with @Entity.static boolean
isMappedSuperclass
(MetadataClass candidateClass) Return if a given class is annotated with @MappedSuperclass.static boolean
isStaticMetamodelClass
(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 void
processORMetadata
(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 void
setArchiveFactory
(ArchiveFactory factory)
-
Field Details
-
ARCHIVE_FACTORY
Cache the ArchiveFactory used to derive Archives. This allows applications to set the ArchiveFactory
-
-
Constructor Details
-
PersistenceUnitProcessor
protected PersistenceUnitProcessor()Default constructor.
-
-
Method Details
-
buildClassNameFromEntryString
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
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 fordescriptorLocation
viaClassloader.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)IOException
URISyntaxException
-
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
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 ofArchive
representing 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
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
-
getArchiveFactory
-
getClassNamesFromURL
-
getConverterAnnotation
Return if a given class is annotated with @Embeddable. -
getEmbeddableAnnotation
Return if a given class is annotated with @Embeddable. -
getEntityAnnotation
Return if a given class is annotated with @Entity. -
getPersistenceUnits
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
Return if a given class is annotated with @Entity. -
getStaticMetamodelAnnotation
Return the @StaticMetamodel annotation on the given class. -
isConverter
Return if a given class is annotated with @Converter. -
isEmbeddable
Return if a given class is annotated with @Embeddable. -
isEntity
Return if a given class is annotated with @Entity. -
isStaticMetamodelClass
Return if a given class is annotated with @StaticMetamodel. -
isMappedSuperclass
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
-
buildPersistenceUnitName
Build the unique persistence name by concatenating the decoded URL with the persistence unit name. A decoded URL is required while persisting on a multi-bytes OS.- Returns:
- String
-