Top Description Inners Fields Constructors Methods
org.eclipse.persistence.internal.jpa.deployment

public Class PersistenceUnitProcessor

extends Object
Class Inheritance
Static Imports
org.eclipse.persistence.internal.jpa.metadata.MetadataConstants.JPA_CONVERTER, .MetadataConstants.JPA_EMBEDDABLE, .MetadataConstants.JPA_ENTITY, .MetadataConstants.JPA_MAPPED_SUPERCLASS, .MetadataConstants.JPA_STATIC_METAMODEL

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 and Inner Type Summary

Modifier and TypeClass and Description
public static enum
PersistenceUnitProcessor.Mode

Passed to processORMetadata method to indicate processing mode.

Field Summary

Modifier and TypeField and Description
public static ArchiveFactory
ARCHIVE_FACTORY

Cache the ArchiveFactory used to derive Archives.

private static final int
WEBINF_CLASSES_LEN

Length of application classes directory path String.

private static final String
WEBINF_CLASSES_STR

Path to application classes directory in WAR file.

Constructor Summary

AccessConstructor and Description
protected
PersistenceUnitProcessor()

Default constructor.

Method Summary

Modifier and TypeMethod and Description
public static String
buildClassNameFromEntryString(String classEntryString)

Entries in a zip file are directory entries using slashes to separate them.

public static Set<String>

Returns:

a Set of class name strings
buildClassSet
(PersistenceUnitInfo persistenceUnitInfo, Map<K, V> properties)

Build a set that contains all the class names at a URL.

public static Collection<MetadataClass>
buildEntityList(MetadataProcessor processor, ClassLoader loader)

Create a list of the entities that will be deployed.

public static String

Returns:

String
buildPersistenceUnitName
(URL url, String puName)

Build the unique persistence name by concatenating the decoded URL with the persistence unit name.

public static URL

Returns:

The URL of the PU root containing the resource.
computePURootURL
(URL
- URL of a resource belonging to the PU (obtained for descriptorLocation via Classloader.getResource(String)).
pxmlURL
,
String
- the name of the resource.
descriptorLocation
)

Determine the URL path to the persistence unit

public static Set<Archive>
findPersistenceArchives()

Search the classpath for persistence archives.

public static Set<Archive>
findPersistenceArchives(ClassLoader
the class loader to get the class path from
loader
)

Search the classpath for persistence archives.

public static Set<Archive>
findPersistenceArchives(ClassLoader
the class loader to get the class path from
loader
,
String descriptorPath)

Return a list of Archives representing the root of the persistence descriptor.

public static Set<Archive>
findPersistenceArchives(ClassLoader
the class loader to get the class path from
loader
,
String descriptorPath, List<URL> jarFileUrls, Map<K, V> properties)

Return a list of Archives representing the root of the persistence descriptor.

private static URL
fixUNC(URL url)

This method fixes incorrect authority attribute that is set by JDK when UNC is used in classpath.

public static ArchiveFactory
public static ArchiveFactory
getArchiveFactory(ClassLoader loader, Map<K, V> properties)

public static Set<String>
getClassNamesFromURL(URL url, ClassLoader loader, Map<K, V> properties)

public static MetadataAnnotation
getConverterAnnotation(MetadataClass candidateClass)

Return if a given class is annotated with @Embeddable.

public static MetadataAnnotation
getEmbeddableAnnotation(MetadataClass candidateClass)

Return if a given class is annotated with @Embeddable.

public static MetadataAnnotation
getEntityAnnotation(MetadataClass candidateClass)

Return if a given class is annotated with @Entity.

public static MetadataAnnotation
getMappedSuperclassAnnotation(MetadataClass candidateClass)

Return if a given class is annotated with @Entity.

public static Set<SEPersistenceUnitInfo>
getPersistenceUnits(ClassLoader loader, Map<K, V> m, List<URL> jarFileUrls)

public static List<SEPersistenceUnitInfo>
getPersistenceUnits(Archive
The url of a jar file or directory to check
archive
,
ClassLoader loader)

Get a list of persistence units from the file or directory at the given url.

public static MetadataAnnotation
getStaticMetamodelAnnotation(MetadataClass candidateClass)

Return the @StaticMetamodel annotation on the given class.

public static boolean
isConverter(MetadataClass candidateClass)

Return if a given class is annotated with @Converter.

public static boolean
isEmbeddable(MetadataClass candidateClass)

Return if a given class is annotated with @Embeddable.

public static boolean
isEntity(MetadataClass candidateClass)

Return if a given class is annotated with @Entity.

public static boolean
isMappedSuperclass(MetadataClass candidateClass)

Return if a given class is annotated with @MappedSuperclass.

public static boolean
isStaticMetamodelClass(MetadataClass candidateClass)

Return if a given class is annotated with @StaticMetamodel.

private static boolean

Returns:

true if the file-entry pair can be a persistence root according to JPA Spec (8.2).
isValidRootInArchive
(String
archive file URL. In case of a nested archive, this is the URL of the innermost archive.
file
,
String
a directory entry in the archive (or an empty string). In case of a nested archive, this is the entry in the innermost archive.
rootEntry
)

public static Class<?>
loadClass(String className, ClassLoader loader, boolean throwExceptionIfNotFound, MetadataProject project)

Load the given class name with the given class loader.

public static void
processORMetadata(MetadataProcessor processor, boolean throwExceptionOnFail, PersistenceUnitProcessor.Mode mode)

Process the Object/relational metadata from XML and annotations

public static List<SEPersistenceUnitInfo>
processPersistenceArchive(Archive archive, ClassLoader loader)

Go through the jar file for this PersistenceUnitProcessor and process any XML provided in it.

private static List<SEPersistenceUnitInfo>
processPersistenceXML(URL baseURL, InputStream input, ClassLoader loader)

Build a persistence.xml file into a SEPersistenceUnitInfo object.

public static void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

ARCHIVE_FACTORYback to summary
public static ArchiveFactory ARCHIVE_FACTORY

Cache the ArchiveFactory used to derive Archives. This allows applications to set the ArchiveFactory

WEBINF_CLASSES_LENback to summary
private static final int WEBINF_CLASSES_LEN

Length of application classes directory path String.

WEBINF_CLASSES_STRback to summary
private static final String WEBINF_CLASSES_STR

Path to application classes directory in WAR file.

Constructor Detail

PersistenceUnitProcessorback to summary
protected PersistenceUnitProcessor()

Default constructor.

Method Detail

buildClassNameFromEntryStringback to summary
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.

buildClassSetback to summary
public static Set<String> buildClassSet(PersistenceUnitInfo persistenceUnitInfo, Map<K, V> properties)

Build a set that contains all the class names at a URL.

Returns:Set<String>

a Set of class name strings

buildEntityListback to summary
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.

buildPersistenceUnitNameback to summary
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

String

computePURootURLback to summary
public static URL computePURootURL(URL pxmlURL, String descriptorLocation) throws IOException, URISyntaxException

Determine the URL path to the persistence unit

Parameters
pxmlURL:URL

- URL of a resource belonging to the PU (obtained for descriptorLocation via Classloader.getResource(String)).

descriptorLocation:String

- the name of the resource.

Returns:URL

The URL of the PU root containing the resource.

Exceptions
ValidationException:
if the resolved root doesn't conform to the JPA specification (8.2)
findPersistenceArchivesback to summary
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.

findPersistenceArchivesback to summary
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:ClassLoader

the class loader to get the class path from

findPersistenceArchivesback to summary
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:ClassLoader

the class loader to get the class path from

findPersistenceArchivesback to summary
public static Set<Archive> findPersistenceArchives(ClassLoader loader, String descriptorPath, List<URL> jarFileUrls, Map<K, V> 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:ClassLoader

the class loader to get the class path from

fixUNCback to summary
private static URL fixUNC(URL url) throws URISyntaxException, MalformedURLException, UnsupportedEncodingException

This method fixes incorrect authority attribute that is set by JDK when UNC is used in classpath. See JDK bug #6585937 and GlassFish issue #3209 for more details.

getArchiveFactoryback to summary
public static ArchiveFactory getArchiveFactory(ClassLoader loader)
getArchiveFactoryback to summary
public static ArchiveFactory getArchiveFactory(ClassLoader loader, Map<K, V> properties)
getClassNamesFromURLback to summary
public static Set<String> getClassNamesFromURL(URL url, ClassLoader loader, Map<K, V> properties)
getConverterAnnotationback to summary
public static MetadataAnnotation getConverterAnnotation(MetadataClass candidateClass)

Return if a given class is annotated with @Embeddable.

getEmbeddableAnnotationback to summary
public static MetadataAnnotation getEmbeddableAnnotation(MetadataClass candidateClass)

Return if a given class is annotated with @Embeddable.

getEntityAnnotationback to summary
public static MetadataAnnotation getEntityAnnotation(MetadataClass candidateClass)

Return if a given class is annotated with @Entity.

getMappedSuperclassAnnotationback to summary
public static MetadataAnnotation getMappedSuperclassAnnotation(MetadataClass candidateClass)

Return if a given class is annotated with @Entity.

getPersistenceUnitsback to summary
public static Set<SEPersistenceUnitInfo> getPersistenceUnits(ClassLoader loader, Map<K, V> m, List<URL> jarFileUrls)
getPersistenceUnitsback to summary
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:Archive

The url of a jar file or directory to check

getStaticMetamodelAnnotationback to summary
public static MetadataAnnotation getStaticMetamodelAnnotation(MetadataClass candidateClass)

Return the @StaticMetamodel annotation on the given class.

isConverterback to summary
public static boolean isConverter(MetadataClass candidateClass)

Return if a given class is annotated with @Converter.

isEmbeddableback to summary
public static boolean isEmbeddable(MetadataClass candidateClass)

Return if a given class is annotated with @Embeddable.

isEntityback to summary
public static boolean isEntity(MetadataClass candidateClass)

Return if a given class is annotated with @Entity.

isMappedSuperclassback to summary
public static boolean isMappedSuperclass(MetadataClass candidateClass)

Return if a given class is annotated with @MappedSuperclass.

isStaticMetamodelClassback to summary
public static boolean isStaticMetamodelClass(MetadataClass candidateClass)

Return if a given class is annotated with @StaticMetamodel.

isValidRootInArchiveback to summary
private static boolean isValidRootInArchive(String file, String rootEntry)
Parameters
file:String

archive file URL. In case of a nested archive, this is the URL of the innermost archive.

rootEntry:String

a directory entry in the archive (or an empty string). In case of a nested archive, this is the entry in the innermost archive.

Returns:boolean

true if the file-entry pair can be a persistence root according to JPA Spec (8.2).

loadClassback to summary
public static Class<?> loadClass(String className, ClassLoader loader, boolean throwExceptionIfNotFound, MetadataProject project)

Load the given class name with the given class loader.

processORMetadataback to summary
public static void processORMetadata(MetadataProcessor processor, boolean throwExceptionOnFail, PersistenceUnitProcessor.Mode mode)

Process the Object/relational metadata from XML and annotations

processPersistenceArchiveback to summary
public static List<SEPersistenceUnitInfo> processPersistenceArchive(Archive archive, ClassLoader loader)

Go through the jar file for this PersistenceUnitProcessor and process any XML provided in it.

processPersistenceXMLback to summary
private static List<SEPersistenceUnitInfo> processPersistenceXML(URL baseURL, InputStream input, ClassLoader loader)

Build a persistence.xml file into a SEPersistenceUnitInfo object. May eventually change this to use OX mapping as well.

setArchiveFactoryback to summary
public static void setArchiveFactory(ArchiveFactory factory)
org.eclipse.persistence.internal.jpa.deployment back to summary

public final Enum PersistenceUnitProcessor.Mode

extends Enum<PersistenceUnitProcessor.Mode>
Class Inheritance

Passed to processORMetadata method to indicate processing mode. ALL used when independent persistence unit is created. COMPOSITE_MEMBER_INITIAL, COMPOSITE_MEMBER_MIDDLE and COMPOSITE_MEMBER_FINAL used for a composite member persistence unit.

Field Summary

Modifier and TypeField and Description
public static final PersistenceUnitProcessor.Mode
public static final PersistenceUnitProcessor.Mode
public static final PersistenceUnitProcessor.Mode
public static final PersistenceUnitProcessor.Mode

Constructor Summary

AccessConstructor and Description
private
Mode()

Method Summary

Modifier and TypeMethod and Description
public static PersistenceUnitProcessor.Mode
public static PersistenceUnitProcessor.Mode[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

ALLback to summary
public static final PersistenceUnitProcessor.Mode ALL
COMPOSITE_MEMBER_FINALback to summary
public static final PersistenceUnitProcessor.Mode COMPOSITE_MEMBER_FINAL
COMPOSITE_MEMBER_INITIALback to summary
public static final PersistenceUnitProcessor.Mode COMPOSITE_MEMBER_INITIAL
COMPOSITE_MEMBER_MIDDLEback to summary
public static final PersistenceUnitProcessor.Mode COMPOSITE_MEMBER_MIDDLE

Constructor Detail

Modeback to summary
private Mode()

Method Detail

valueOfback to summary
public static PersistenceUnitProcessor.Mode valueOf(String name)
valuesback to summary
public static PersistenceUnitProcessor.Mode[] values()