Class AnnotationsProcessor
- java.lang.Object
-
- org.eclipse.persistence.jaxb.compiler.AnnotationsProcessor
-
public final class AnnotationsProcessor extends java.lang.Object
INTERNAL:Purpose:To perform some initial processing of Java classes and JAXB 2.0 Annotations and generate meta data that can be used by the Mappings Generator and Schema Generator
Responsibilities:
- Generate a map of TypeInfo objects, keyed on class name
- Generate a map of user defined schema types
- Identify any class-based JAXB 2.0 callback methods, and create MarshalCallback and UnmarshalCallback objects to wrap them.
- Centralize processing which is common to both Schema Generation and Mapping Generation tasks
This class does the initial processing of the JAXB 2.0 Generation. It generates meta data that can be used by the later Schema Generation and Mapping Generation steps.
- See Also:
Generator
- Author:
- mmacivor
- Since:
- Oracle TopLink 11.1.1.0.0
-
-
Constructor Summary
Constructors Constructor Description AnnotationsProcessor(Helper helper)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description SchemaTypeInfo
addClass(JavaClass javaClass)
void
addEnumTypeInfo(JavaClass javaClass, EnumTypeInfo info)
void
addPackageToNamespaceMapping(java.lang.String packageName, NamespaceInfo nsInfo)
Add a package name/NamespaceInfo entry to the map.void
addPackageToPackageInfoMapping(java.lang.String packageName, PackageInfo packageInfo)
void
addPackageToXmlElementNillable(java.lang.String packageName, XmlElementNillable xmlElementNillable)
Add a package name/XmlElementNillable entry to the map.void
addPackageToXmlNullPolicy(java.lang.String packageName, XmlNullPolicy xmlNullPolicy)
Add a package name/XmlNullPolicy entry to the map.void
addXmlRegistry(java.lang.String factoryClassName, XmlRegistry xmlReg)
Add an XmlRegistry to ObjectFactory class name pair to the map.protected boolean
areEquals(JavaClass src, java.lang.Class tgt)
Compares a JavaModel JavaClass to a Class.protected boolean
areEquals(JavaClass src, java.lang.String tgtCanonicalName)
Compares a JavaModel JavaClass to a Class.void
buildNewTypeInfo(JavaClass[] javaClasses)
Convenience method which class pre and postBuildTypeInfo for a given set of JavaClasses.void
createElementsForTypeMappingInfo()
void
finalizeProperties()
Perform any final generation and/or validation operations on TypeInfo properties.NamespaceInfo
findInfoForNamespace(java.lang.String namespace)
java.util.Map<java.lang.String,java.lang.Class>
getArrayClassesToGeneratedClasses()
java.util.Map<java.lang.reflect.Type,java.lang.Class>
getCollectionClassesToGeneratedClasses()
java.util.ArrayList<Property>
getFieldPropertiesForClass(JavaClass cls, TypeInfo info, boolean onlyPublic)
java.util.ArrayList<Property>
getFieldPropertiesForClass(JavaClass cls, TypeInfo info, boolean onlyPublic, boolean onlyExplicit)
java.util.Map<java.lang.Class,JavaClass>
getGeneratedClassesToArrayClasses()
java.util.Map<java.lang.Class,java.lang.reflect.Type>
getGeneratedClassesToCollectionClasses()
java.util.Map<javax.xml.namespace.QName,ElementDeclaration>
getGlobalElements()
Lazy load and return the map of global elements.java.util.List<ElementDeclaration>
getLocalElements()
java.util.Map<java.lang.String,MarshalCallback>
getMarshalCallbacks()
java.util.ArrayList
getNoAccessTypePropertiesForClass(JavaClass cls, TypeInfo info)
PackageInfo
getPackageInfoForPackage(JavaClass javaClass)
PackageInfo
getPackageInfoForPackage(JavaPackage pack, java.lang.String packageName)
java.util.Map<java.lang.String,PackageInfo>
getPackageToPackageInfoMappings()
java.util.ArrayList<Property>
getPropertiesForClass(JavaClass cls, TypeInfo info)
java.util.HashMap<java.lang.String,Property>
getPropertyMapFromArrayList(java.util.ArrayList<Property> props)
java.util.ArrayList<Property>
getPropertyPropertiesForClass(JavaClass cls, TypeInfo info, boolean onlyPublic)
java.util.ArrayList<Property>
getPropertyPropertiesForClass(JavaClass cls, TypeInfo info, boolean onlyPublic, boolean onlyExplicit)
java.util.ArrayList
getPublicMemberPropertiesForClass(JavaClass cls, TypeInfo info)
javax.xml.namespace.QName
getQNameForProperty(Property property, java.lang.String defaultName, JavaHasAnnotations element, NamespaceInfo namespaceInfo, TypeInfo info)
java.util.List
getReferencedByTransformer()
javax.xml.namespace.QName
getSchemaTypeFor(JavaClass javaClass)
javax.xml.namespace.QName
getSchemaTypeOrNullFor(JavaClass javaClass)
java.util.List<JavaClass>
getTypeInfoClasses()
java.util.Map<java.lang.String,TypeInfo>
getTypeInfos()
java.util.Map<java.lang.String,TypeInfo>
getTypeInfosForPackage(java.lang.String packageName)
Convenience method for returning all of the TypeInfo objects for a given package name.java.util.Map<TypeMappingInfo,java.lang.Class>
getTypeMappingInfosToGeneratedClasses()
java.util.Map<TypeMappingInfo,javax.xml.namespace.QName>
getTypeMappingInfosToSchemaTypes()
java.util.Map<TypeMappingInfo,java.lang.Class>
getTypeMappingInfoToAdapterClasses()
java.util.Map<java.lang.String,UnmarshalCallback>
getUnmarshalCallbacks()
java.util.Map<java.lang.String,javax.xml.namespace.QName>
getUserDefinedSchemaTypes()
boolean
hasSwaRef()
boolean
hasXmlBindings()
boolean
isDefaultNamespaceAllowed()
boolean
isMtomAttachment(Property property)
Indicates if a given Property represents an MTOM attachment.boolean
isXmlAccessorFactorySupport()
Indicates whether this AnnotationsProcessor has been configured to enable processing of XmlAccessorFactory annotations.JavaClass[]
postBuildTypeInfo(JavaClass[] javaClasses)
Process any additional classes (i.e. inner classes, @XmlSeeAlso, @XmlRegistry, etc.) for a given set of JavaClasses, then complete building all of the required TypeInfo objects.java.util.Map<java.lang.String,TypeInfo>
preBuildTypeInfo(JavaClass[] javaClasses)
Process class level annotations only.NamespaceInfo
processNamespaceInformation(XmlSchema xmlSchema)
JavaClass[]
processObjectFactory(JavaClass objectFactoryClass, java.util.List<JavaClass> classes)
void
processPropertiesSuperClass(JavaClass cls, TypeInfo info)
void
processSchemaType(java.lang.String name, java.lang.String namespace, java.lang.String jClassQualifiedName)
Use name, namespace and type information to setup a user-defined schema type.void
processSchemaType(XmlSchemaType type)
void
setDefaultNamespaceAllowed(boolean isDefaultNamespaceAllowed)
void
setHasSwaRef(boolean swaRef)
void
setHasXmlBindings(boolean b)
void
setPackageToNamespaceMappings(java.util.HashMap<java.lang.String,NamespaceInfo> packageToNamespaceMappings)
Set namespace override info from XML bindings file.void
setPackageToPackageInfoMappings(java.util.HashMap<java.lang.String,PackageInfo> packageToPackageInfoMappings)
void
setXmlAccessorFactorySupport(boolean value)
Sets whether this AnnotationsProcessor should process XmlAccessorFactory annotations.boolean
shouldGenerateTypeInfo(JavaClass javaClass)
void
updateGlobalElements(JavaClass[] classesToProcess)
-
-
-
Constructor Detail
-
AnnotationsProcessor
public AnnotationsProcessor(Helper helper)
-
-
Method Detail
-
createElementsForTypeMappingInfo
public void createElementsForTypeMappingInfo()
-
preBuildTypeInfo
public java.util.Map<java.lang.String,TypeInfo> preBuildTypeInfo(JavaClass[] javaClasses)
Process class level annotations only. It is assumed that a call to init() has been made prior to calling this method. After the types created via this method have been modified (if necessary) postBuildTypeInfo and processJavaClasses should be called to finish processing.- Parameters:
javaClasses
-- Returns:
-
postBuildTypeInfo
public JavaClass[] postBuildTypeInfo(JavaClass[] javaClasses)
Process any additional classes (i.e. inner classes, @XmlSeeAlso, @XmlRegistry, etc.) for a given set of JavaClasses, then complete building all of the required TypeInfo objects. This method is typically called after init and preBuildTypeInfo have been called.- Parameters:
javaClasses
-- Returns:
- updated array of JavaClasses, made up of the original classes plus any additional ones
-
finalizeProperties
public void finalizeProperties()
Perform any final generation and/or validation operations on TypeInfo properties.
-
shouldGenerateTypeInfo
public boolean shouldGenerateTypeInfo(JavaClass javaClass)
-
getPropertiesForClass
public java.util.ArrayList<Property> getPropertiesForClass(JavaClass cls, TypeInfo info)
-
getFieldPropertiesForClass
public java.util.ArrayList<Property> getFieldPropertiesForClass(JavaClass cls, TypeInfo info, boolean onlyPublic)
-
getFieldPropertiesForClass
public java.util.ArrayList<Property> getFieldPropertiesForClass(JavaClass cls, TypeInfo info, boolean onlyPublic, boolean onlyExplicit)
-
areEquals
protected boolean areEquals(JavaClass src, java.lang.Class tgt)
Compares a JavaModel JavaClass to a Class. Equality is based on the raw name of the JavaClass compared to the canonical name of the Class.- Parameters:
src
-tgt
-- Returns:
-
areEquals
protected boolean areEquals(JavaClass src, java.lang.String tgtCanonicalName)
Compares a JavaModel JavaClass to a Class. Equality is based on the raw name of the JavaClass compared to the canonical name of the Class.- Parameters:
src
-tgtCanonicalName
-- Returns:
-
getPropertyPropertiesForClass
public java.util.ArrayList<Property> getPropertyPropertiesForClass(JavaClass cls, TypeInfo info, boolean onlyPublic)
-
getPropertyPropertiesForClass
public java.util.ArrayList<Property> getPropertyPropertiesForClass(JavaClass cls, TypeInfo info, boolean onlyPublic, boolean onlyExplicit)
-
getPublicMemberPropertiesForClass
public java.util.ArrayList getPublicMemberPropertiesForClass(JavaClass cls, TypeInfo info)
-
getPropertyMapFromArrayList
public java.util.HashMap<java.lang.String,Property> getPropertyMapFromArrayList(java.util.ArrayList<Property> props)
-
getNoAccessTypePropertiesForClass
public java.util.ArrayList getNoAccessTypePropertiesForClass(JavaClass cls, TypeInfo info)
-
processSchemaType
public void processSchemaType(java.lang.String name, java.lang.String namespace, java.lang.String jClassQualifiedName)
Use name, namespace and type information to setup a user-defined schema type. This method will typically be called when processing an @XmlSchemaType(s) annotation or xml-schema-type(s) metadata.- Parameters:
name
-namespace
-jClassQualifiedName
-
-
processSchemaType
public void processSchemaType(XmlSchemaType type)
-
addEnumTypeInfo
public void addEnumTypeInfo(JavaClass javaClass, EnumTypeInfo info)
-
getSchemaTypeOrNullFor
public javax.xml.namespace.QName getSchemaTypeOrNullFor(JavaClass javaClass)
-
getSchemaTypeFor
public javax.xml.namespace.QName getSchemaTypeFor(JavaClass javaClass)
-
processNamespaceInformation
public NamespaceInfo processNamespaceInformation(XmlSchema xmlSchema)
-
getTypeInfos
public java.util.Map<java.lang.String,TypeInfo> getTypeInfos()
-
getTypeInfoClasses
public java.util.List<JavaClass> getTypeInfoClasses()
-
getUserDefinedSchemaTypes
public java.util.Map<java.lang.String,javax.xml.namespace.QName> getUserDefinedSchemaTypes()
-
getQNameForProperty
public javax.xml.namespace.QName getQNameForProperty(Property property, java.lang.String defaultName, JavaHasAnnotations element, NamespaceInfo namespaceInfo, TypeInfo info)
-
getPackageToPackageInfoMappings
public java.util.Map<java.lang.String,PackageInfo> getPackageToPackageInfoMappings()
-
addPackageToNamespaceMapping
public void addPackageToNamespaceMapping(java.lang.String packageName, NamespaceInfo nsInfo)
Add a package name/NamespaceInfo entry to the map. This method will lazy-load the map if necessary.
-
addPackageToXmlElementNillable
public void addPackageToXmlElementNillable(java.lang.String packageName, XmlElementNillable xmlElementNillable)
Add a package name/XmlElementNillable entry to the map. This method will lazy-load the map if necessary.
-
addPackageToXmlNullPolicy
public void addPackageToXmlNullPolicy(java.lang.String packageName, XmlNullPolicy xmlNullPolicy)
Add a package name/XmlNullPolicy entry to the map. This method will lazy-load the map if necessary.
-
addPackageToPackageInfoMapping
public void addPackageToPackageInfoMapping(java.lang.String packageName, PackageInfo packageInfo)
-
getPackageInfoForPackage
public PackageInfo getPackageInfoForPackage(JavaClass javaClass)
-
getPackageInfoForPackage
public PackageInfo getPackageInfoForPackage(JavaPackage pack, java.lang.String packageName)
-
findInfoForNamespace
public NamespaceInfo findInfoForNamespace(java.lang.String namespace)
-
getMarshalCallbacks
public java.util.Map<java.lang.String,MarshalCallback> getMarshalCallbacks()
-
getUnmarshalCallbacks
public java.util.Map<java.lang.String,UnmarshalCallback> getUnmarshalCallbacks()
-
processObjectFactory
public JavaClass[] processObjectFactory(JavaClass objectFactoryClass, java.util.List<JavaClass> classes)
-
getGlobalElements
public java.util.Map<javax.xml.namespace.QName,ElementDeclaration> getGlobalElements()
Lazy load and return the map of global elements.- Returns:
-
updateGlobalElements
public void updateGlobalElements(JavaClass[] classesToProcess)
-
getCollectionClassesToGeneratedClasses
public java.util.Map<java.lang.reflect.Type,java.lang.Class> getCollectionClassesToGeneratedClasses()
-
getArrayClassesToGeneratedClasses
public java.util.Map<java.lang.String,java.lang.Class> getArrayClassesToGeneratedClasses()
-
getGeneratedClassesToCollectionClasses
public java.util.Map<java.lang.Class,java.lang.reflect.Type> getGeneratedClassesToCollectionClasses()
-
getGeneratedClassesToArrayClasses
public java.util.Map<java.lang.Class,JavaClass> getGeneratedClassesToArrayClasses()
-
getTypeInfosForPackage
public java.util.Map<java.lang.String,TypeInfo> getTypeInfosForPackage(java.lang.String packageName)
Convenience method for returning all of the TypeInfo objects for a given package name. This method is inefficient as we need to iterate over the entire typeinfo map for each call. We should eventually store the TypeInfos in a Map based on package name, i.e.: Map <String, Map<String, TypeInfo>>- Parameters:
packageName
-- Returns:
- List of TypeInfo objects for a given package name
-
setPackageToNamespaceMappings
public void setPackageToNamespaceMappings(java.util.HashMap<java.lang.String,NamespaceInfo> packageToNamespaceMappings)
Set namespace override info from XML bindings file. This will typically be called from the XMLProcessor.- Parameters:
packageToNamespaceMappings
-
-
setPackageToPackageInfoMappings
public void setPackageToPackageInfoMappings(java.util.HashMap<java.lang.String,PackageInfo> packageToPackageInfoMappings)
-
addClass
public SchemaTypeInfo addClass(JavaClass javaClass)
-
buildNewTypeInfo
public void buildNewTypeInfo(JavaClass[] javaClasses)
Convenience method which class pre and postBuildTypeInfo for a given set of JavaClasses.- Parameters:
javaClasses
-
-
isDefaultNamespaceAllowed
public boolean isDefaultNamespaceAllowed()
-
getLocalElements
public java.util.List<ElementDeclaration> getLocalElements()
-
getTypeMappingInfosToGeneratedClasses
public java.util.Map<TypeMappingInfo,java.lang.Class> getTypeMappingInfosToGeneratedClasses()
-
getTypeMappingInfoToAdapterClasses
public java.util.Map<TypeMappingInfo,java.lang.Class> getTypeMappingInfoToAdapterClasses()
-
addXmlRegistry
public void addXmlRegistry(java.lang.String factoryClassName, XmlRegistry xmlReg)
Add an XmlRegistry to ObjectFactory class name pair to the map.- Parameters:
factoryClassName
- ObjectFactory class namexmlReg
- org.eclipse.persistence.jaxb.xmlmodel.XmlRegistry instance
-
getTypeMappingInfosToSchemaTypes
public java.util.Map<TypeMappingInfo,javax.xml.namespace.QName> getTypeMappingInfosToSchemaTypes()
-
setDefaultNamespaceAllowed
public void setDefaultNamespaceAllowed(boolean isDefaultNamespaceAllowed)
-
isMtomAttachment
public boolean isMtomAttachment(Property property)
Indicates if a given Property represents an MTOM attachment. Will return true if the given Property's actual type is one of: - DataHandler - byte[] - Byte[] - Image - Source - MimeMultipart- Parameters:
property
-- Returns:
-
hasSwaRef
public boolean hasSwaRef()
-
setHasSwaRef
public void setHasSwaRef(boolean swaRef)
-
getReferencedByTransformer
public java.util.List getReferencedByTransformer()
-
isXmlAccessorFactorySupport
public boolean isXmlAccessorFactorySupport()
Indicates whether this AnnotationsProcessor has been configured to enable processing of XmlAccessorFactory annotations.- See Also:
com.sun.xml.internal.bind.XmlAccessorFactory
-
setXmlAccessorFactorySupport
public void setXmlAccessorFactorySupport(boolean value)
Sets whether this AnnotationsProcessor should process XmlAccessorFactory annotations.- See Also:
com.sun.xml.internal.bind.XmlAccessorFactory
-
setHasXmlBindings
public void setHasXmlBindings(boolean b)
-
hasXmlBindings
public boolean hasXmlBindings()
-
-