Package org.apache.openjpa.persistence
Class PersistenceMetaDataFactory
- java.lang.Object
-
- org.apache.openjpa.meta.AbstractMetaDataFactory
-
- org.apache.openjpa.meta.AbstractCFMetaDataFactory
-
- org.apache.openjpa.persistence.PersistenceMetaDataFactory
-
- All Implemented Interfaces:
Configurable
,GenericConfigurable
,MetaDataFactory
,MetaDataModes
- Direct Known Subclasses:
PersistenceMappingFactory
public class PersistenceMetaDataFactory extends AbstractCFMetaDataFactory implements Configurable, GenericConfigurable
MetaDataFactory
for JPA metadata.- Since:
- 0.4.0
- Author:
- Steve Kim
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.apache.openjpa.meta.AbstractCFMetaDataFactory
AbstractCFMetaDataFactory.Parser, AbstractCFMetaDataFactory.Serializer
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.Stack<XMLPersistenceMetaDataParser>
_stack
-
Fields inherited from class org.apache.openjpa.meta.AbstractCFMetaDataFactory
cpath, files, JAR_FILE_URLS, MAPPING_FILE_NAMES, PERSISTENCE_UNIT_ROOT_URL, rsrcs, urls
-
Fields inherited from class org.apache.openjpa.meta.AbstractMetaDataFactory
dir, log, repos, store, strict, types
-
Fields inherited from interface org.apache.openjpa.meta.MetaDataFactory
STORE_DEFAULT, STORE_PER_CLASS, STORE_VERBOSE
-
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 PersistenceMetaDataFactory()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clear()
Clear any internal caches.protected java.io.File
defaultSourceFile(ClassMetaData meta)
Return the default file for the given metadata.protected java.io.File
defaultSourceFile(QueryMetaData query, java.util.Map clsNames)
Return a default file for the given query.protected java.io.File
defaultSourceFile(SequenceMetaData seq, java.util.Map clsNames)
Return a default file for the given sequence.void
endConfiguration()
Invoked upon completion of bean property configuration for this object.AnnotationPersistenceMetaDataParser
getAnnotationParser()
Return metadata parser, creating it if it does not already exist.MetaDataDefaults
getDefaults()
Return the metadata defaults for this factory.boolean
getFieldOverride()
Whether to use field-level override or class-level override.java.lang.Class<?>
getManagedClass(java.lang.Class<?> c)
Gets the managed class corresponding to the given meta-class.java.lang.String
getManagedClassName(java.lang.String mmClassName)
Gets the name of the managed class for the given fully-qualified meta-model class name.java.lang.String
getMetaModelClassName(java.lang.String managedClassName)
Gets the name of the meta-model class for the given fully-qualified managed class name.java.lang.Class<?>
getQueryScope(java.lang.String queryName, java.lang.ClassLoader loader)
Return the type defining the given query name, if any.java.lang.Class<?>
getResultSetMappingScope(java.lang.String rsMappingName, java.lang.ClassLoader loader)
Return the type defining the given result set mapping name, if any.AnnotationPersistenceXMLMetaDataParser
getXMLAnnotationParser()
Return JAXB XML annotation parser, creating it if it does not already exist.XMLPersistenceMetaDataParser
getXMLParser()
Return XML metadata parser, creating it if it does not already exist or if the existing parser is parsing.boolean
isMetaClass(java.lang.Class<?> c)
Affirms if the given class is a meta-class.void
load(java.lang.Class<?> cls, int mode, java.lang.ClassLoader envLoader)
Load metadata for the given class in the given mode(s).void
loadXMLMetaData(java.lang.Class<?> cls)
Load XMLClassMetadata for the given class.protected void
mapPersistentTypeNames(java.lang.Object rsrc, java.lang.String[] names)
Implement this method to map metadata resources to the persistent types contained within them.protected AnnotationPersistenceMetaDataParser
newAnnotationParser()
Create a new metadata parser.protected AnnotationPersistenceMetaDataSerializer
newAnnotationSerializer()
Create a new annotation serializer.ClassArgParser
newClassArgParser()
Return a properly-configured class arg parser for our expected metadata format.protected MetaDataFilter
newMetaDataFilter()
Return a metadata filter that identifies metadata resources when performing jar and classpath scans.protected AbstractCFMetaDataFactory.Parser
newParser(boolean loading)
Create a new metadata parser.protected AbstractCFMetaDataFactory.Serializer
newSerializer()
Create a new metadata serializer.protected AnnotationPersistenceXMLMetaDataParser
newXMLAnnotationParser()
Create a new JAXB XML annotation parser.protected XMLPersistenceMetaDataParser
newXMLParser(boolean loading)
Create a new metadata parser.protected XMLPersistenceMetaDataSerializer
newXMLSerializer()
Create a new serializerprotected void
parse(MetaDataParser parser, java.lang.Class[] cls)
Parse all given classses.void
resetXMLParser()
void
setAnnotationParser(AnnotationPersistenceMetaDataParser parser)
Set the metadata parser.void
setConfiguration(Configuration conf)
Invoked prior to setting bean properties.void
setFieldOverride(boolean field)
Whether to use field-level override or class-level override.void
setInto(Options opts)
Perform any generic configuration based on the data inopts
.void
setXMLAnnotationParser(AnnotationPersistenceXMLMetaDataParser parser)
Set the JAXB XML annotation parser.void
setXMLParser(XMLPersistenceMetaDataParser parser)
Set the metadata parser.void
startConfiguration()
Invoked before bean property configuration is begun on this object.-
Methods inherited from class org.apache.openjpa.meta.AbstractCFMetaDataFactory
backupAndDelete, clearMapping, decode, drop, getDefiningMetaData, getPersistentTypeNames, getSourceFile, getSourceFile, isMappingOnlyFactory, isParseTopDown, parse, parsePersistentTypeNames, serialize, setClasspathScan, setClasspathScan, setFiles, setFiles, setResources, setResources, setSourceFile, setSourceFile, setURLs, setURLs, store
-
Methods inherited from class org.apache.openjpa.meta.AbstractMetaDataFactory
addClassExtensionKeys, addFieldExtensionKeys, setRepository, setStoreDirectory, setStoreMode, setStrict, setTypes, setTypes
-
-
-
-
Field Detail
-
_stack
protected java.util.Stack<XMLPersistenceMetaDataParser> _stack
-
-
Method Detail
-
setFieldOverride
public void setFieldOverride(boolean field)
Whether to use field-level override or class-level override. Defaults to true.
-
getFieldOverride
public boolean getFieldOverride()
Whether to use field-level override or class-level override. Defaults to true.
-
getAnnotationParser
public AnnotationPersistenceMetaDataParser getAnnotationParser()
Return metadata parser, creating it if it does not already exist.
-
setAnnotationParser
public void setAnnotationParser(AnnotationPersistenceMetaDataParser parser)
Set the metadata parser.
-
newAnnotationParser
protected AnnotationPersistenceMetaDataParser newAnnotationParser()
Create a new metadata parser.
-
newAnnotationSerializer
protected AnnotationPersistenceMetaDataSerializer newAnnotationSerializer()
Create a new annotation serializer.- Specified by:
newAnnotationSerializer
in classAbstractCFMetaDataFactory
-
getXMLParser
public XMLPersistenceMetaDataParser getXMLParser()
Return XML metadata parser, creating it if it does not already exist or if the existing parser is parsing.
-
resetXMLParser
public void resetXMLParser()
-
setXMLParser
public void setXMLParser(XMLPersistenceMetaDataParser parser)
Set the metadata parser.
-
newXMLParser
protected XMLPersistenceMetaDataParser newXMLParser(boolean loading)
Create a new metadata parser.
-
newXMLSerializer
protected XMLPersistenceMetaDataSerializer newXMLSerializer()
Create a new serializer
-
load
public void load(java.lang.Class<?> cls, int mode, java.lang.ClassLoader envLoader)
Description copied from interface:MetaDataFactory
Load metadata for the given class in the given mode(s). If loading inMetaDataModes.MODE_QUERY
, the class may be null. Loaded metadata should be added directly to the repository. It should have its source mode set appropriately viaClassMetaData.setSourceMode(int)
.- Specified by:
load
in interfaceMetaDataFactory
mode
- the mode to load metadata in: if mapping information is stored together with metadata, then you can load mapping data even if this mode only includesMODE_META
, so long as thestrict
property hasn't been set
-
mapPersistentTypeNames
protected void mapPersistentTypeNames(java.lang.Object rsrc, java.lang.String[] names)
Description copied from class:AbstractCFMetaDataFactory
Implement this method to map metadata resources to the persistent types contained within them. The method will be called whenAbstractCFMetaDataFactory.getPersistentTypeNames(boolean, java.lang.ClassLoader)
is invoked.- Overrides:
mapPersistentTypeNames
in classAbstractCFMetaDataFactory
-
getQueryScope
public java.lang.Class<?> getQueryScope(java.lang.String queryName, java.lang.ClassLoader loader)
Description copied from interface:MetaDataFactory
Return the type defining the given query name, if any.- Specified by:
getQueryScope
in interfaceMetaDataFactory
- Overrides:
getQueryScope
in classAbstractMetaDataFactory
-
getResultSetMappingScope
public java.lang.Class<?> getResultSetMappingScope(java.lang.String rsMappingName, java.lang.ClassLoader loader)
Description copied from interface:MetaDataFactory
Return the type defining the given result set mapping name, if any.- Specified by:
getResultSetMappingScope
in interfaceMetaDataFactory
- Overrides:
getResultSetMappingScope
in classAbstractMetaDataFactory
-
newMetaDataFilter
protected MetaDataFilter newMetaDataFilter()
Description copied from class:AbstractCFMetaDataFactory
Return a metadata filter that identifies metadata resources when performing jar and classpath scans.- Specified by:
newMetaDataFilter
in classAbstractCFMetaDataFactory
-
getDefaults
public MetaDataDefaults getDefaults()
Description copied from interface:MetaDataFactory
Return the metadata defaults for this factory.- Specified by:
getDefaults
in interfaceMetaDataFactory
-
newClassArgParser
public ClassArgParser newClassArgParser()
Description copied from interface:MetaDataFactory
Return a properly-configured class arg parser for our expected metadata format.- Specified by:
newClassArgParser
in interfaceMetaDataFactory
- Overrides:
newClassArgParser
in classAbstractMetaDataFactory
-
clear
public void clear()
Description copied from interface:MetaDataFactory
Clear any internal caches.- Specified by:
clear
in interfaceMetaDataFactory
- Overrides:
clear
in classAbstractCFMetaDataFactory
-
newParser
protected AbstractCFMetaDataFactory.Parser newParser(boolean loading)
Description copied from class:AbstractCFMetaDataFactory
Create a new metadata parser.- Specified by:
newParser
in classAbstractCFMetaDataFactory
- Parameters:
loading
- if true, this will be the cached parser used for loading metadata
-
newSerializer
protected AbstractCFMetaDataFactory.Serializer newSerializer()
Description copied from class:AbstractCFMetaDataFactory
Create a new metadata serializer.- Specified by:
newSerializer
in classAbstractCFMetaDataFactory
-
parse
protected void parse(MetaDataParser parser, java.lang.Class[] cls)
Description copied from class:AbstractCFMetaDataFactory
Parse all given classses.- Overrides:
parse
in classAbstractCFMetaDataFactory
-
defaultSourceFile
protected java.io.File defaultSourceFile(ClassMetaData meta)
Description copied from class:AbstractCFMetaDataFactory
Return the default file for the given metadata.- Specified by:
defaultSourceFile
in classAbstractCFMetaDataFactory
-
defaultSourceFile
protected java.io.File defaultSourceFile(QueryMetaData query, java.util.Map clsNames)
Description copied from class:AbstractCFMetaDataFactory
Return a default file for the given query.- Specified by:
defaultSourceFile
in classAbstractCFMetaDataFactory
-
defaultSourceFile
protected java.io.File defaultSourceFile(SequenceMetaData seq, java.util.Map clsNames)
Description copied from class:AbstractCFMetaDataFactory
Return a default file for the given sequence.- Specified by:
defaultSourceFile
in classAbstractCFMetaDataFactory
-
setConfiguration
public void setConfiguration(Configuration conf)
Description copied from interface:Configurable
Invoked prior to setting bean properties.- Specified by:
setConfiguration
in interfaceConfigurable
-
startConfiguration
public void startConfiguration()
Description copied from interface:Configurable
Invoked before bean property configuration is begun on this object.- Specified by:
startConfiguration
in interfaceConfigurable
-
endConfiguration
public void endConfiguration()
Description copied from interface:Configurable
Invoked upon completion of bean property configuration for this object.- Specified by:
endConfiguration
in interfaceConfigurable
-
setInto
public void setInto(Options opts)
Description copied from interface:GenericConfigurable
Perform any generic configuration based on the data inopts
. This method should remove any values inopts
that have been successfully processed; if any values remain inopts
after this method is executed, an exception will be thrown identifying those key-value pairs as invalid.- Specified by:
setInto
in interfaceGenericConfigurable
-
getXMLAnnotationParser
public AnnotationPersistenceXMLMetaDataParser getXMLAnnotationParser()
Return JAXB XML annotation parser, creating it if it does not already exist.
-
setXMLAnnotationParser
public void setXMLAnnotationParser(AnnotationPersistenceXMLMetaDataParser parser)
Set the JAXB XML annotation parser.
-
newXMLAnnotationParser
protected AnnotationPersistenceXMLMetaDataParser newXMLAnnotationParser()
Create a new JAXB XML annotation parser.
-
loadXMLMetaData
public void loadXMLMetaData(java.lang.Class<?> cls)
Description copied from interface:MetaDataFactory
Load XMLClassMetadata for the given class. Loaded metadata should be added directly to the repository.- Specified by:
loadXMLMetaData
in interfaceMetaDataFactory
-
getManagedClassName
public java.lang.String getManagedClassName(java.lang.String mmClassName)
Description copied from interface:MetaDataFactory
Gets the name of the managed class for the given fully-qualified meta-model class name.- Specified by:
getManagedClassName
in interfaceMetaDataFactory
-
getMetaModelClassName
public java.lang.String getMetaModelClassName(java.lang.String managedClassName)
Description copied from interface:MetaDataFactory
Gets the name of the meta-model class for the given fully-qualified managed class name.- Specified by:
getMetaModelClassName
in interfaceMetaDataFactory
-
isMetaClass
public boolean isMetaClass(java.lang.Class<?> c)
Description copied from interface:MetaDataFactory
Affirms if the given class is a meta-class.- Specified by:
isMetaClass
in interfaceMetaDataFactory
-
getManagedClass
public java.lang.Class<?> getManagedClass(java.lang.Class<?> c)
Description copied from interface:MetaDataFactory
Gets the managed class corresponding to the given meta-class.- Specified by:
getManagedClass
in interfaceMetaDataFactory
- Returns:
- null if the given input is not a meta-class.
-
-