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
  • Field Details

    • ARCHIVE_FACTORY

      public static ArchiveFactory 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

      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(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 for descriptorLocation via Classloader.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

      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 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 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)
    • buildPersistenceUnitName

      public static String buildPersistenceUnitName(URL url, 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.
      Returns:
      String