Package org.apache.openjpa.persistence
Class AnnotationPersistenceMetaDataSerializer
java.lang.Object
org.apache.openjpa.persistence.AnnotationPersistenceMetaDataSerializer
- All Implemented Interfaces:
MetaDataSerializer,AbstractCFMetaDataFactory.Serializer
- Direct Known Subclasses:
AnnotationPersistenceMappingSerializer
public class AnnotationPersistenceMetaDataSerializer
extends Object
implements AbstractCFMetaDataFactory.Serializer
Serializes persistence metadata as annotations.
This class processes all object level tags that are store-agnostic.
However, it provides hooks for the subclasses to include store-specific
tags to be serialized both at <entity-mappings> and
<entity> level.
- Since:
- 1.0.0
- Author:
- Steve Kim, Gokhan Ergul
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected classCompares clases, sequences, and queries to order them for serialization. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final intprotected static final intprotected static final intprotected static final intprotected static final intFields inherited from interface org.apache.openjpa.lib.meta.MetaDataSerializer
APPEND, COMPACT, PRETTY, VERBOSE -
Constructor Summary
ConstructorsConstructorDescriptionConstructor. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddAll(MetaDataRepository repos) Add all components in the given repository to the set to be serialized.protected AnnotationBuilderaddAnnotation(Class<? extends Annotation> annType, ClassMetaData meta) Creates an an annotation builder for the specified class metadata and adds it to list of builders.protected AnnotationBuilderaddAnnotation(Class<? extends Annotation> annType, FieldMetaData meta) Creates an an annotation builder for the specified class metadata and adds it to list of builders.protected AnnotationBuilderaddAnnotation(Class<? extends Annotation> annType, QueryMetaData meta) Creates an an annotation builder for the specified class metadata and adds it to list of builders.protected AnnotationBuilderaddAnnotation(Class<? extends Annotation> annType, SequenceMetaData meta) Creates an an annotation builder for the specified class metadata and adds it to list of builders.protected voidaddAnnotation(AnnotationBuilder ab, Object meta) protected voidaddAnnotation(AnnotationBuilder ab, ClassMetaData meta) Add an annotation builder to list of builders for the specified class metadata.protected voidaddAnnotation(AnnotationBuilder ab, FieldMetaData meta) Add an annotation builder to list of builders for the specified field metadata.protected voidaddAnnotation(AnnotationBuilder ab, QueryMetaData meta) Add an annotation builder to list of builders for the specified query metadata.protected voidaddAnnotation(AnnotationBuilder ab, SequenceMetaData meta) Add an annotation builder to list of builders for the specified sequence metadata.protected voidaddClassMappingAnnotations(ClassMetaData mapping) Add mapping attributes for the given class.protected voidaddFieldMappingAttributes(FieldMetaData fmd, FieldMetaData orig, AnnotationBuilder ab) Add mapping attributes for the given field.voidaddMetaData(ClassMetaData meta) Add a class meta data to the set to be serialized.voidAdd a query meta data to the set to be serialized.voidAdd a sequence meta data to the set to be serialized.protected voidSet mapping attributes for strategy.protected voidaddSystemMappingElements(Collection toSerialize) Add system-level mapping elements to be serialized.voidclear()Clear the set of metadatas to be serialized.Returns the stored ClassMetaDataConfiguration.getLog()The log to write to.intgetMode()The serialization mode according to the expected document type.protected Collectionprotected PersistenceStrategygetStrategy(FieldMetaData fmd) Return the serialized strategy name.protected booleanConvenience method for interpretinggetMode().protected booleanisMappingMode(ClassMetaData meta) Convenience method for interpretinggetMode().protected booleanConvenience method for interpretinggetMode().protected booleanConvenience method for interpretinggetMode().protected booleanConvenience method for interpretinggetMode().protected AnnotationBuildernewAnnotationBuilder(Class<? extends Annotation> annType) Creates a new annotation builder for the specified annotation type.Create a new comparator for ordering objects that are to be serialized.booleanremoveAll(MetaDataRepository repos) Remove all the components in the given repository from the set to be serialized.booleanremoveMetaData(ClassMetaData meta) Remove a metadata from the set to be serialized.booleanRemove a query metadata from the set to be serialized.booleanRemove a sequence metadata from the set to be serialized.voidserialize(int flags) Serialize the current set of objects to the files from which they were parsed.voidSerialize the current set of objects to the given file.voidSerialize the current set of objects to the given stream.protected voidserialize(Collection objects) voidSerialize the current set of objects to the files from which they were parsed.protected booleanserializeAttributeOverride(FieldMetaData fmd, FieldMetaData orig) Always returns false by default.protected voidserializeAttributeOverrideMappingContent(FieldMetaData fmd, FieldMetaData orig, AnnotationBuilder ab) Serialize attribute override mapping content.protected voidserializeClass(ClassMetaData meta) Serialize class metadata.protected voidSerialize class mapping content.protected voidserializeFieldMappingContent(FieldMetaData fmd, PersistenceStrategy strategy, AnnotationBuilder ab) Serialize field mapping content; this will be called before#serializeValueMappingContent.protected voidserializeInheritanceContent(ClassMetaData mapping) Serialize inheritance content.protected voidSerialize query mappings.protected voidSerialize sequence metadata.protected voidSerialize unknown mapping element at system level.voidThe log to write to.voidsetMode(int mode) The serialization mode according to the expected document type.voidsetMode(int mode, boolean on) The serialization mode according to the expected document type.protected intReturn the type constant for the given object based on its runtime class.protected voidwriteAnnotations(Object meta, List<AnnotationBuilder> builders, Map output)
-
Field Details
-
TYPE_SEQ
protected static final int TYPE_SEQ- See Also:
-
TYPE_QUERY
protected static final int TYPE_QUERY- See Also:
-
TYPE_META
protected static final int TYPE_META- See Also:
-
TYPE_CLASS_SEQS
protected static final int TYPE_CLASS_SEQS- See Also:
-
TYPE_CLASS_QUERIES
protected static final int TYPE_CLASS_QUERIES- See Also:
-
-
Constructor Details
-
AnnotationPersistenceMetaDataSerializer
Constructor. Supply configuration.
-
-
Method Details
-
getConfiguration
Configuration. -
getLog
The log to write to. -
setLog
The log to write to. -
getMode
public int getMode()The serialization mode according to the expected document type. The mode constants act as bit flags, and therefore can be combined. -
setMode
public void setMode(int mode) The serialization mode according to the expected document type. The mode constants act as bit flags, and therefore can be combined.- Specified by:
setModein interfaceAbstractCFMetaDataFactory.Serializer
-
setMode
public void setMode(int mode, boolean on) The serialization mode according to the expected document type. -
isMetaDataMode
protected boolean isMetaDataMode()Convenience method for interpretinggetMode(). -
isQueryMode
protected boolean isQueryMode()Convenience method for interpretinggetMode(). -
isMappingMode
protected boolean isMappingMode()Convenience method for interpretinggetMode(). -
isMappingMode
Convenience method for interpretinggetMode(). Takes into account whether mapping information is loaded for the given instance. OPENJPA-1360 - Allow @Column attributes when meta.isEmbeddedOnly() -
isMappingMode
Convenience method for interpretinggetMode(). Takes into account whether mapping information is loaded for the given instance. -
addMetaData
Add a class meta data to the set to be serialized.- Specified by:
addMetaDatain interfaceAbstractCFMetaDataFactory.Serializer
-
addSequenceMetaData
Add a sequence meta data to the set to be serialized.- Specified by:
addSequenceMetaDatain interfaceAbstractCFMetaDataFactory.Serializer
-
addQueryMetaData
Add a query meta data to the set to be serialized.- Specified by:
addQueryMetaDatain interfaceAbstractCFMetaDataFactory.Serializer
-
addAll
Add all components in the given repository to the set to be serialized.- Specified by:
addAllin interfaceAbstractCFMetaDataFactory.Serializer
-
removeMetaData
Remove a metadata from the set to be serialized.- Specified by:
removeMetaDatain interfaceAbstractCFMetaDataFactory.Serializer- Returns:
- true if removed, false if not in set
-
removeSequenceMetaData
Remove a sequence metadata from the set to be serialized.- Returns:
- true if removed, false if not in set
-
removeQueryMetaData
Remove a query metadata from the set to be serialized.- Returns:
- true if removed, false if not in set
-
removeAll
Remove all the components in the given repository from the set to be serialized.- Returns:
- true if any components removed, false if none in set
-
clear
public void clear()Clear the set of metadatas to be serialized. -
addSystemMappingElements
Add system-level mapping elements to be serialized. Does nothing by default. -
newSerializationComparator
protected AnnotationPersistenceMetaDataSerializer.SerializationComparator newSerializationComparator()Create a new comparator for ordering objects that are to be serialized. -
newAnnotationBuilder
Creates a new annotation builder for the specified annotation type. -
addAnnotation
-
addAnnotation
Add an annotation builder to list of builders for the specified class metadata. -
addAnnotation
Add an annotation builder to list of builders for the specified field metadata. -
addAnnotation
Add an annotation builder to list of builders for the specified sequence metadata. -
addAnnotation
Add an annotation builder to list of builders for the specified query metadata. -
addAnnotation
Creates an an annotation builder for the specified class metadata and adds it to list of builders. -
addAnnotation
Creates an an annotation builder for the specified class metadata and adds it to list of builders. -
addAnnotation
protected AnnotationBuilder addAnnotation(Class<? extends Annotation> annType, SequenceMetaData meta) Creates an an annotation builder for the specified class metadata and adds it to list of builders. -
addAnnotation
Creates an an annotation builder for the specified class metadata and adds it to list of builders. -
serialize
-
type
Return the type constant for the given object based on its runtime class. If the runtime class does not correspond to any of the known types then returns -1. This can happen for tags that are not handled at this store-agnostic level. -
serializeSystemMappingElement
Serialize unknown mapping element at system level. -
serializeSequence
Serialize sequence metadata. -
serializeClass
Serialize class metadata. -
addClassMappingAnnotations
Add mapping attributes for the given class. Does nothing by default -
serializeClassMappingContent
Serialize class mapping content. Does nothing by default. -
serializeInheritanceContent
Serialize inheritance content. Does nothing by default. -
serializeQueryMappings
Serialize query mappings. Does nothing by default. -
addFieldMappingAttributes
protected void addFieldMappingAttributes(FieldMetaData fmd, FieldMetaData orig, AnnotationBuilder ab) Add mapping attributes for the given field. Does nothing by default. -
serializeAttributeOverride
Always returns false by default. -
serializeAttributeOverrideMappingContent
protected void serializeAttributeOverrideMappingContent(FieldMetaData fmd, FieldMetaData orig, AnnotationBuilder ab) Serialize attribute override mapping content. Does nothing by default, -
getStrategy
Return the serialized strategy name. -
serializeFieldMappingContent
protected void serializeFieldMappingContent(FieldMetaData fmd, PersistenceStrategy strategy, AnnotationBuilder ab) Serialize field mapping content; this will be called before#serializeValueMappingContent. Does nothing by default. -
addStrategyMappingAttributes
Set mapping attributes for strategy. Sets mapped-by by default. -
getObjects
-
writeAnnotations
-
serialize
Description copied from interface:MetaDataSerializerSerialize the current set of objects to the files from which they were parsed. The objects must implement theSourceTrackerinterface.- Specified by:
serializein interfaceMetaDataSerializer- Parameters:
output- if null, then serialize directly to the file system; otherwise, populate the specifiedMapwith keys that are theFileinstances, and values that are theStringcontents of the MetaDataflags- bit flags specifying the output flags; e.g.MetaDataSerializer.PRETTY- Throws:
IOException
-
serialize
Description copied from interface:MetaDataSerializerSerialize the current set of objects to the given file.- Specified by:
serializein interfaceMetaDataSerializerflags- bit flags specifying the output flags; e.g.MetaDataSerializer.PRETTY|MetaDataSerializer.APPEND- Throws:
IOException
-
serialize
Description copied from interface:MetaDataSerializerSerialize the current set of objects to the given stream.- Specified by:
serializein interfaceMetaDataSerializerflags- bit flags specifying the output flags; e.g.MetaDataSerializer.PRETTY- Throws:
IOException
-
serialize
Description copied from interface:MetaDataSerializerSerialize the current set of objects to the files from which they were parsed. Any objects for which a source file cannot be determined will not be included in the output.- Specified by:
serializein interfaceMetaDataSerializer- Parameters:
flags- bit flags specifying the output flags; e.g.MetaDataSerializer.PRETTY- Throws:
IOException
-
getClassMetaData
Returns the stored ClassMetaData
-