Class PersistenceUnitProcessor


  • public class PersistenceUnitProcessor
    extends java.lang.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
    • Field Detail

      • ARCHIVE_FACTORY

        public static ArchiveFactory ARCHIVE_FACTORY
        Cache the ArchiveFactory used to derive Archives. This allows applications to set the ArchiveFactory
    • Constructor Detail

      • PersistenceUnitProcessor

        public PersistenceUnitProcessor()
    • Method Detail

      • buildClassNameFromEntryString

        public static java.lang.String buildClassNameFromEntryString​(java.lang.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 java.util.Set<java.lang.String> buildClassSet​(javax.persistence.spi.PersistenceUnitInfo persistenceUnitInfo,
                                                                    java.util.Map properties)
        Build a set that contains all the class names at a URL.
        Returns:
        a Set of class name strings
      • buildEntityList

        public static java.util.Collection<MetadataClass> buildEntityList​(MetadataProcessor processor,
                                                                          java.lang.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 java.net.URL computePURootURL​(java.net.URL pxmlURL,
                                                    java.lang.String descriptorLocation)
                                             throws java.io.IOException,
                                                    java.net.URISyntaxException
        Determine the URL path to the persistence unit
        Parameters:
        pxmlURL - - Encoded URL containing the pu
        Returns:
        Throws:
        java.io.IOException
        java.net.URISyntaxException
      • findPersistenceArchives

        public static java.util.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 java.util.Set<Archive> findPersistenceArchives​(java.lang.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 of Archive 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

        public static java.util.Set<Archive> findPersistenceArchives​(java.lang.ClassLoader loader,
                                                                     java.lang.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 java.util.Set<Archive> findPersistenceArchives​(java.lang.ClassLoader loader,
                                                                     java.lang.String descriptorPath,
                                                                     java.util.List<java.net.URL> jarFileUrls,
                                                                     java.util.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 java.util.Set<SEPersistenceUnitInfo> getPersistenceUnits​(java.lang.ClassLoader loader,
                                                                               java.util.Map m,
                                                                               java.util.List<java.net.URL> jarFileUrls)
      • getArchiveFactory

        public static ArchiveFactory getArchiveFactory​(java.lang.ClassLoader loader)
      • getArchiveFactory

        public static ArchiveFactory getArchiveFactory​(java.lang.ClassLoader loader,
                                                       java.util.Map properties)
      • getClassNamesFromURL

        public static java.util.Set<java.lang.String> getClassNamesFromURL​(java.net.URL url,
                                                                           java.lang.ClassLoader loader,
                                                                           java.util.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 java.util.List<SEPersistenceUnitInfo> getPersistenceUnits​(Archive archive,
                                                                                java.lang.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 java.lang.Class loadClass​(java.lang.String className,
                                                java.lang.ClassLoader loader,
                                                boolean throwExceptionIfNotFound,
                                                MetadataProject project)
        Load the given class name with the given class loader.
      • processPersistenceArchive

        public static java.util.List<SEPersistenceUnitInfo> processPersistenceArchive​(Archive archive,
                                                                                      java.lang.ClassLoader loader)
        Go through the jar file for this PersistenceUnitProcessor and process any XML provided in it.
      • setArchiveFactory

        public static void setArchiveFactory​(ArchiveFactory factory)
      • buildPersistenceUnitName

        public static java.lang.String buildPersistenceUnitName​(java.net.URL url,
                                                                java.lang.String puName)
        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.
        Parameters:
        url -
        puName -
        Returns:
        String