Package org.apache.openjpa.persistence
Class AnnotationPersistenceMetaDataParser
- java.lang.Object
-
- org.apache.openjpa.persistence.AnnotationPersistenceMetaDataParser
-
- All Implemented Interfaces:
MetaDataModes
- Direct Known Subclasses:
AnnotationPersistenceMappingParser
public class AnnotationPersistenceMetaDataParser extends java.lang.Object implements MetaDataModes
Persistence annotation metadata parser. Currently does not parse deployment descriptors.- Author:
- Abe White, Steve Kim
-
-
Field Summary
Fields Modifier and Type Field Description protected java.lang.Class<?>
_cls
protected java.util.Stack<java.lang.Class<?>>
_stack
-
Fields inherited from interface org.apache.openjpa.meta.MetaDataModes
MODE_ALL, MODE_ANN_MAPPING, MODE_MAPPING, MODE_MAPPING_INIT, MODE_META, MODE_NONE, MODE_QUERY
-
-
Constructor Summary
Constructors Constructor Description AnnotationPersistenceMetaDataParser(OpenJPAConfiguration conf)
Constructor; supply configuration.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
addHints(QueryMetaData meta, jakarta.persistence.QueryHint... hints)
protected void
addSourceInfo(java.lang.reflect.AnnotatedElement el, QueryMetaData meta)
void
clear()
Clear caches.OpenJPAConfiguration
getConfiguration()
Configuration supplied on construction.java.lang.ClassLoader
getEnvClassLoader()
Return the environmental class loader to pass on to parsed metadata instances.Log
getLog()
Metadata log.boolean
getMappingOverride()
Whether to allow later parses of mapping information to override earlier information for the same class.int
getMode()
The parse mode.MetaDataRepository
getRepository()
Returns the repository for this parser.protected java.io.File
getSourceFile()
Determine the source file we're parsing.protected boolean
handleUnknownClassAnnotation(ClassMetaData meta, java.lang.annotation.Annotation anno)
Allow subclasses to handle unknown annotations.protected boolean
handleUnknownMemberAnnotation(FieldMetaData fmd, java.lang.annotation.Annotation anno)
Allow subclasses to handle unknown annotations.protected boolean
handleUnknownPackageAnnotation(java.lang.Package pkg, java.lang.annotation.Annotation anno)
Allow subclasses to handle unknown annotations.protected boolean
isMappingMode()
Convenience method for interpretinggetMode()
.protected boolean
isMappingOverrideMode()
Returns true if we're in mapping mode or in metadata mode with mapping overide enabled.protected boolean
isMetaDataMode()
Convenience method for interpretinggetMode()
.protected boolean
isQueryMode()
Convenience method for interpretinggetMode()
.protected java.lang.String
normalizeCatalogName(java.lang.String catName)
protected java.lang.String
normalizeSchemaName(java.lang.String schName)
protected java.lang.String
normalizeSequenceName(java.lang.String seqName)
void
parse(java.lang.Class<?> cls)
Parse persistence metadata for the given class.static java.util.Collection<LifecycleCallbacks>[]
parseCallbackMethods(java.lang.Class<?> cls, java.util.Collection<LifecycleCallbacks>[] callbacks, boolean sups, boolean listener, MetaDataRepository repos)
Parse callback methods into the given array, and return that array, creating one if null.protected void
parseClassMappingAnnotations(ClassMetaData meta)
Parse class mapping annotations.protected void
parseLobMapping(FieldMetaData fmd)
Setup the field as a LOB mapping.protected void
parseMemberMappingAnnotations(FieldMetaData fmd)
Parse member mapping components.protected void
parsePackageMappingAnnotations(java.lang.Package pkg)
Parse package mapping annotations.void
setEnvClassLoader(java.lang.ClassLoader loader)
Set the environmental class loader to pass on to parsed metadata instances.void
setMappingOverride(boolean override)
Whether to allow later parses of mapping information to override earlier information for the same class.void
setMode(int mode)
The parse mode.void
setMode(int mode, boolean on)
The parse mode.void
setRepository(MetaDataRepository repos)
Set the metadata repository for this parser.protected MultiQueryMetaData.Parameter.Mode
toKernelParameterMode(jakarta.persistence.ParameterMode mode)
static java.lang.Class<?>
toOverrideType(java.lang.Class<?> cls)
Convert the given class to its OpenJPA type override equivalent.
-
-
-
Constructor Detail
-
AnnotationPersistenceMetaDataParser
public AnnotationPersistenceMetaDataParser(OpenJPAConfiguration conf)
Constructor; supply configuration.
-
-
Method Detail
-
getConfiguration
public OpenJPAConfiguration getConfiguration()
Configuration supplied on construction.
-
getLog
public Log getLog()
Metadata log.
-
getRepository
public MetaDataRepository getRepository()
Returns the repository for this parser. If none has been set, create a new repository and sets it.
-
setRepository
public void setRepository(MetaDataRepository repos)
Set the metadata repository for this parser.
-
getEnvClassLoader
public java.lang.ClassLoader getEnvClassLoader()
Return the environmental class loader to pass on to parsed metadata instances.
-
setEnvClassLoader
public void setEnvClassLoader(java.lang.ClassLoader loader)
Set the environmental class loader to pass on to parsed metadata instances.
-
getMappingOverride
public boolean getMappingOverride()
Whether to allow later parses of mapping information to override earlier information for the same class. Defaults to false. Useful when a tool is mapping a class, so that annotation partial mapping information can be used even when mappings are stored in another location.
-
setMappingOverride
public void setMappingOverride(boolean override)
Whether to allow later parses of mapping information to override earlier information for the same class. Defaults to false. Useful when a tool is mapping a class, so that annotation partial mapping information can be used even when mappings are stored in another location.
-
getMode
public int getMode()
The parse mode.
-
setMode
public void setMode(int mode, boolean on)
The parse mode.
-
setMode
public void setMode(int mode)
The parse mode.
-
isMetaDataMode
protected boolean isMetaDataMode()
Convenience method for interpretinggetMode()
.
-
isQueryMode
protected boolean isQueryMode()
Convenience method for interpretinggetMode()
.
-
isMappingMode
protected boolean isMappingMode()
Convenience method for interpretinggetMode()
.
-
isMappingOverrideMode
protected boolean isMappingOverrideMode()
Returns true if we're in mapping mode or in metadata mode with mapping overide enabled.
-
clear
public void clear()
Clear caches.
-
parse
public void parse(java.lang.Class<?> cls)
Parse persistence metadata for the given class.
-
parsePackageMappingAnnotations
protected void parsePackageMappingAnnotations(java.lang.Package pkg)
Parse package mapping annotations.
-
handleUnknownPackageAnnotation
protected boolean handleUnknownPackageAnnotation(java.lang.Package pkg, java.lang.annotation.Annotation anno)
Allow subclasses to handle unknown annotations.
-
parseClassMappingAnnotations
protected void parseClassMappingAnnotations(ClassMetaData meta)
Parse class mapping annotations.
-
handleUnknownClassAnnotation
protected boolean handleUnknownClassAnnotation(ClassMetaData meta, java.lang.annotation.Annotation anno)
Allow subclasses to handle unknown annotations.
-
getSourceFile
protected java.io.File getSourceFile()
Determine the source file we're parsing.
-
parseCallbackMethods
public static java.util.Collection<LifecycleCallbacks>[] parseCallbackMethods(java.lang.Class<?> cls, java.util.Collection<LifecycleCallbacks>[] callbacks, boolean sups, boolean listener, MetaDataRepository repos)
Parse callback methods into the given array, and return that array, creating one if null. Each index into the array is a collection of callback adapters for that numeric event type.- Parameters:
sups
- whether to scan superclasseslistener
- whether this is a listener or not
-
parseMemberMappingAnnotations
protected void parseMemberMappingAnnotations(FieldMetaData fmd)
Parse member mapping components.
-
handleUnknownMemberAnnotation
protected boolean handleUnknownMemberAnnotation(FieldMetaData fmd, java.lang.annotation.Annotation anno)
Allow subclasses to handle unknown annotations.
-
toOverrideType
public static java.lang.Class<?> toOverrideType(java.lang.Class<?> cls)
Convert the given class to its OpenJPA type override equivalent.
-
parseLobMapping
protected void parseLobMapping(FieldMetaData fmd)
Setup the field as a LOB mapping.
-
normalizeSequenceName
protected java.lang.String normalizeSequenceName(java.lang.String seqName)
-
normalizeSchemaName
protected java.lang.String normalizeSchemaName(java.lang.String schName)
-
normalizeCatalogName
protected java.lang.String normalizeCatalogName(java.lang.String catName)
-
toKernelParameterMode
protected MultiQueryMetaData.Parameter.Mode toKernelParameterMode(jakarta.persistence.ParameterMode mode)
-
addSourceInfo
protected void addSourceInfo(java.lang.reflect.AnnotatedElement el, QueryMetaData meta)
-
addHints
protected void addHints(QueryMetaData meta, jakarta.persistence.QueryHint... hints)
-
-