Class ClassAccessor

  • Direct Known Subclasses:
    EmbeddableAccessor, InterfaceAccessor, MappedSuperclassAccessor

    public abstract class ClassAccessor
    extends MetadataAccessor
    INTERNAL: A abstract class accessor. Holds common metadata for entities, embeddables and mapped superclasses. Key notes: - all metadata mapped from XML to this class must be compared in the equals method. - all metadata mapped from XML must be initialized in the initXMLObject method. - all metadata mapped from XML to this class must be handled in the merge method. (merging is done at the accessor/mapping level) - any metadata mapped from XML to this class must be initialized in the initXMLObject method. - methods should be preserved in alphabetical order.
    Since:
    TopLink EJB 3.0 Reference Implementation
    Author:
    Guy Pelletier
    • Constructor Detail

      • ClassAccessor

        protected ClassAccessor​(java.lang.String xmlElement)
        INTERNAL:
      • ClassAccessor

        protected ClassAccessor​(MetadataAnnotation annotation,
                                MetadataClass cls,
                                MetadataDescriptor descriptor)
        INTERNAL: Called from MappedSuperclassAccessor. We want to avoid setting the class accessor on the descriptor to be the MappedSuperclassAccessor.
    • Method Detail

      • addAccessor

        protected void addAccessor​(MappingAccessor accessor)
        INTERNAL: Add the accessor to the descriptor
      • addAccessors

        public void addAccessors()
        INTERNAL: Add the accessors from this class accessors java class to the descriptor tied to this class accessor. This method is called for every class accessor and is also called from parent class accessors to each of its subclasses of a TABLE_PER_CLASS inheritance strategy. Add accessors is called in the preProcess stage and must not be called until its owning class accessor has processed its access type.
      • addAccessorFields

        protected void addAccessorFields​(boolean processingInverse)
        INTERNAL: Create mappings from the fields directly. If the mustBeExplicit flag is true, then we are processing the inverse of an explicit access setting and for a field to be processed it must have a Access(FIELD) setting.
      • addAccessorMethods

        protected void addAccessorMethods​(boolean processingInverse)
        INTERNAL: Create mappings via the class properties. If the mustBeExplicit flag is true, then we are processing the inverse of an explicit access setting and for a field to be processed it must have a Access(PROPERTY) setting.
      • addPotentialEmbeddableAccessor

        protected void addPotentialEmbeddableAccessor​(MetadataClass potentialEmbeddableClass,
                                                      ClassAccessor embeddingAccessor)
        INTERNAL Add an embeddable class to the embeddable accessor list if it is indeed an embeddable. This method is overridden in EmbeddableAccessor and is called during pre-process. At the entity level all we want to do is set the owning descriptor whereas for nested embeddables they'll need the list of owning descriptors. Any nested embeddables will be discovered and pre-processed when pre-processing the known list of root embeddables.
        See Also:
        processStage1()
      • addPotentialMappedSuperclass

        protected void addPotentialMappedSuperclass​(MetadataClass metadataClass,
                                                    boolean addMappedSuperclassAccessors)
        INTERNAL: Add mapped superclass accessors to inheriting entities. Add new descriptors for these mapped superclasses to the core project.
      • buildAccessor

        protected MappingAccessor buildAccessor​(MetadataAnnotatedElement accessibleObject)
        INTERNAL: Create and return the appropriate accessor based on the accessible object given. Order of checking is important, careful when modifying or adding, check what the isXyz call does to determine if the accessor is of type xyz.
      • clearMappedSuperclassesAndInheritanceParents

        protected void clearMappedSuperclassesAndInheritanceParents()
        INTERNAL:
      • clearPreProcessed

        public void clearPreProcessed()
        INTERNAL: In some cases the pre-processing may need to be re-done. Namely, during the canonical model generation between compile rounds.
      • equals

        public boolean equals​(java.lang.Object objectToCompare)
        INTERNAL:
        Overrides:
        equals in class MetadataAccessor
      • excludeDefaultMappings

        public boolean excludeDefaultMappings()
        INTERNAL: Return true if this class accessor has been set to metadata complete.
      • getAccessibleField

        protected MetadataField getAccessibleField​(MappingAccessor accessor)
        INTERNAL: Return the accessible field for the given mapping accessor. Validation is performed on the existence of the field.
      • getAccessibleMethod

        protected MetadataMethod getAccessibleMethod​(MappingAccessor accessor)
        INTERNAL: Return the accessible method for the given mapping accessor. Validation is performed on the existence of the method by property name or by the access methods if specified.
      • getAccessibleVirtualMethod

        protected MetadataMethod getAccessibleVirtualMethod​(MappingAccessor accessor)
        INTERNAL: This method should only be called when using virtual access and presumably for dynamic persistence. No method validation is done and either the access methods specified or the default get and set methods for name access will be used.
      • getAccessType

        public java.lang.String getAccessType()
        INTERNAL: Return the access type of this accessor. Assumes all access processing has been performed before calling this method.
      • getAssociationOverrides

        public java.util.List<AssociationOverrideMetadata> getAssociationOverrides()
        INTERNAL: Used for OX mapping.
      • getAttributeOverrides

        public java.util.List<AttributeOverrideMetadata> getAttributeOverrides()
        INTERNAL: Used for OX mapping.
      • getAttributes

        public XMLAttributes getAttributes()
        INTERNAL: Used for OX mapping.
      • getClassName

        public java.lang.String getClassName()
        INTERNAL: Used for OX mapping.
      • getCustomizerClass

        public MetadataClass getCustomizerClass()
        INTERNAL:
      • getCustomizerClassName

        public java.lang.String getCustomizerClassName()
        INTERNAL: Used for OX mapping.
      • getDescription

        public java.lang.String getDescription()
        INTERNAL: Used for OX mapping.
      • getExcludeDefaultMappings

        public java.lang.Boolean getExcludeDefaultMappings()
        INTERNAL: Used for OX mapping.
      • getJavaClass

        public MetadataClass getJavaClass()
        INTERNAL: Return the java class that defines this accessor. It may be an entity, embeddable or mapped superclass.
        Overrides:
        getJavaClass in class MetadataAccessor
      • getJavaClassName

        public java.lang.String getJavaClassName()
        INTERNAL: Return the java class name that defines this accessor. It may be an entity, embeddable or mapped superclass.
        Overrides:
        getJavaClassName in class MetadataAccessor
      • getMappedSuperclasses

        public java.util.List<MappedSuperclassAccessor> getMappedSuperclasses()
        INTERNAL: Return the mapped superclasses associated with this entity accessor. A call to discoverMappedSuperclassesAndInheritanceParents() should be made before calling this method.
        See Also:
        preProcess()
      • getMetadataComplete

        public java.lang.Boolean getMetadataComplete()
        INTERNAL: Used for OX mapping.
      • getNoSql

        public NoSqlMetadata getNoSql()
        INTERNAL: Used for OX mapping.
      • setNoSql

        public void setNoSql​(NoSqlMetadata noSql)
        INTERNAL: Used for OX mapping.
      • getOwningDescriptor

        public MetadataDescriptor getOwningDescriptor()
        INTERNAL: In most cases the owning descriptor is the descriptor associated with this class accessor. Owning descriptors come into play when dealing with embeddable classes and their accessors. Processing certain accessors from an embeddable class requires knowledge of owning descriptors that require metadata settings from processing the embeddable metadata.
        See Also:
        EmbeddableAccessor
      • getOwningDescriptors

        public java.util.List<MetadataDescriptor> getOwningDescriptors()
        INTERNAL: In most cases the owning descriptors is the single descriptor associated with this class accessor. Owning descriptors come into play when dealing with shared embeddable classes (included nested) and their accessors. Processing certain accessors from an embeddable class requires knowledge of owning descriptors that require metadata settings from processing the embeddable metadata.
        See Also:
        EmbeddableAccessor
      • getParentClass

        protected MetadataClass getParentClass()
        INTERNAL:
      • getParentClassName

        public java.lang.String getParentClassName()
        INTERNAL: Used for OX mapping.
      • getPLSQLRecords

        public java.util.List<PLSQLRecordMetadata> getPLSQLRecords()
        INTERNAL: Used for OX mapping.
      • getPLSQLTables

        public java.util.List<PLSQLTableMetadata> getPLSQLTables()
        INTERNAL: Used for OX mapping.
      • getStruct

        public StructMetadata getStruct()
        INTERNAL: Used for OX mapping.
      • hasDerivedId

        public boolean hasDerivedId()
        INTERNAL:
      • hasParentClass

        protected boolean hasParentClass()
        INTERNAL:
      • isMappedSuperclass

        public boolean isMappedSuperclass()
        INTERNAL: Return whether this ClassAccessor is a MappedSuperclassAccessor
      • isMetadataComplete

        public boolean isMetadataComplete()
        INTERNAL:
      • isPreProcessed

        public boolean isPreProcessed()
        INTERNAL: Return true if this accessor has been pre-processed.
      • isProcessed

        public boolean isProcessed()
        INTERNAL: Return true if this accessor has been processed.
        Specified by:
        isProcessed in class MetadataAccessor
        Returns:
      • ignoreAnnotations

        public boolean ignoreAnnotations()
        INTERNAL: Return true if this class accessor has been set to metadata complete.
      • isAnnotationPresent

        public boolean isAnnotationPresent​(java.lang.String annotation)
        INTERNAL: Indicates whether the specified annotation is present on the annotated element for this accessor. Method checks against the metadata complete flag.
        Specified by:
        isAnnotationPresent in class MetadataAccessor
      • isClassAccessor

        public boolean isClassAccessor()
        INTERNAL: Return true if this accessor represents a class.
      • isEmbeddableAccessor

        public boolean isEmbeddableAccessor()
        INTERNAL: Return true if this accessor represents an embeddable class.
      • isEntityAccessor

        public boolean isEntityAccessor()
        INTERNAL: Return true if this accessor represents an entity class.
      • merge

        public void merge​(ORMetadata metadata)
        INTERNAL: Generic class level merging details for entities, mapped superclasses and embeddables.
        Overrides:
        merge in class MetadataAccessor
      • preProcess

        public void preProcess()
        INTERNAL: The pre-process method is called during regular deployment and metadata processing.
      • preProcessForCanonicalModel

        public void preProcessForCanonicalModel()
        INTERNAL: The pre-process for canonical model method is called (and only called) during the canonical model generation. The use of this pre-process allows us to remove some items from the regular pre-process that do not apply to the canonical model generation.
      • preProcessMappedSuperclassMetadata

        protected void preProcessMappedSuperclassMetadata​(MappedSuperclassAccessor mappedSuperclass)
        INTERNAL: Sub classes that support extending mapped superclasses should override this method to control what is pre-processed from a mapped superclass. By default it does full pre-processing.
        See Also:
        EmbeddableAccessor
      • process

        public void process()
        INTERNAL: This method should be overridden by all class accessors to process their specific class metadata first then call up to this method to process the common metadata.
        Specified by:
        process in class MetadataAccessor
      • processAccessType

        protected abstract void processAccessType()
        INTERNAL:
      • processAssociationOverride

        protected void processAssociationOverride​(AssociationOverrideMetadata associationOverride)
        INTERNAL: Process the association override metadata specified on an entity or mapped superclass. For any given class, XML association overrides are always added first (see processAssociationOverrides()).
      • processAssociationOverrides

        protected void processAssociationOverrides()
        INTERNAL: Process the association override metadata specified on an entity or mapped superclass. Once the association overrides are processed from XML process the association overrides from annotations. This order of processing must be maintained.
      • processAttributeOverride

        protected void processAttributeOverride​(AttributeOverrideMetadata attributeOverride)
        INTERNAL: Process the attribute override metadata specified on an entity or mapped superclass. For any given class, XML attribute overrides are always added first (see processAttributeOverrides()).
      • processAttributeOverrides

        protected void processAttributeOverrides()
        INTERNAL: Process the attribute override metadata specified on an entity or mapped superclass. Once the attribute overrides are processed from XML process the attribute overrides from annotations. This order of processing must be maintained.
      • processChangeTracking

        protected void processChangeTracking()
        INTERNAL: Process the change tracking setting for this accessor.
      • processComplexMetadataTypes

        public void processComplexMetadataTypes()
        Process PL/SQL record and table types, Oracle object array and XMLType types.
      • processCopyPolicy

        protected void processCopyPolicy()
        INTERNAL:
      • processCustomizer

        protected void processCustomizer()
        INTERNAL:
      • processDerivedId

        public void processDerivedId​(java.util.HashSet<ClassAccessor> processing,
                                     java.util.HashSet<ClassAccessor> processed)
        INTERNAL: Allows for processing derived ids, either from an Id or MapsId specification. All referenced accessors are processed first to ensure the necessary fields are set before the derived id is processed and circular references are checked.
      • processMappedSuperclassMetadata

        protected void processMappedSuperclassMetadata​(MappedSuperclassAccessor mappedSuperclass)
        INTERNAL Sub classes that support extending mapped superclasses should override this method to control what is processed from a mapped superclass. By default it does full processing.
        See Also:
        EmbeddableAccessor
      • processMappingAccessors

        public void processMappingAccessors()
        INTERNAL: Process the accessors for the given class.
      • processNoSql

        protected void processNoSql()
        INTERNAL: Check for and process a NoSql annotation and configure the correct descriptor type. NOTE: NoSql metadata is supported only on Entity and Embeddable.
      • processParentClass

        public void processParentClass()
        INTERNAL: If the user specified a parent class set it on the metadata class for this accessor. The parent class is only ever required in a VIRTUAL case when no java class file is available (otherwise we look at the class for the parent).
      • processProperties

        protected void processProperties()
        INTERNAL: Adds properties to the descriptor.
      • processStruct

        protected void processStruct()
        Check for and process a Struct annotation and configure the correct descriptor type. NOTE: Struct metadata is supported only on Entity and Embeddable.
      • processVirtualClass

        protected void processVirtualClass()
        INTERNAL: If this class accessor uses VIRTUAL access and is not accessible, add it to our list of virtual classes that will be dynamically created.
      • resolveGenericTypes

        protected void resolveGenericTypes​(java.util.List<java.lang.String> genericTypes,
                                           MetadataClass parent)
        INTERNAL: This method resolves generic types. Resolving generic types will be the responsibility of the metadata factory since each factory could have its own means to do so and not respect a generic format on the metadata objects.
      • setAssociationOverrides

        public void setAssociationOverrides​(java.util.List<AssociationOverrideMetadata> associationOverrides)
        INTERNAL: Used for OX mapping.
      • setAttributeOverrides

        public void setAttributeOverrides​(java.util.List<AttributeOverrideMetadata> attributeOverrides)
        INTERNAL: Used for OX mapping.
      • setAttributes

        public void setAttributes​(XMLAttributes attributes)
        INTERNAL: Used for OX mapping.
      • setChangeTracking

        public void setChangeTracking​(ChangeTrackingMetadata changeTracking)
        INTERNAL: Used for OX mapping.
      • setClassName

        public void setClassName​(java.lang.String className)
        INTERNAL: Used for OX mapping.
      • setCloneCopyPolicy

        public void setCloneCopyPolicy​(CloneCopyPolicyMetadata copyPolicy)
        INTERNAL: set the copy policy metadata
      • setCustomCopyPolicy

        public void setCustomCopyPolicy​(CustomCopyPolicyMetadata copyPolicy)
        INTERNAL: set the copy policy metadata
      • setCustomizerClassName

        public void setCustomizerClassName​(java.lang.String customizerClassName)
        INTERNAL: Used for OX mapping.
      • setDescription

        public void setDescription​(java.lang.String description)
        INTERNAL: Used for OX mapping.
      • setExcludeDefaultMappings

        public void setExcludeDefaultMappings​(java.lang.Boolean excludeDefaultMappings)
        INTERNAL: Used for OX mapping.
      • setInstantiationCopyPolicy

        public void setInstantiationCopyPolicy​(InstantiationCopyPolicyMetadata copyPolicy)
        INTERNAL: set the copy policy metadata
      • setIsPreProcessed

        protected void setIsPreProcessed()
        INTERNAL:
      • setIsProcessed

        protected void setIsProcessed()
        INTERNAL:
      • setJavaClass

        public void setJavaClass​(MetadataClass cls)
        INTERNAL: Set the java class for this accessor. This is currently called after the class loader has changed and we are adding entity listeners.
      • setMetadataComplete

        public void setMetadataComplete​(java.lang.Boolean metadataComplete)
        INTERNAL: Used for OX mapping.
      • setParentClass

        protected void setParentClass​(MetadataClass parentClass)
        INTERNAL:
      • setParentClassName

        public void setParentClassName​(java.lang.String parentClassName)
        INTERNAL: Used for OX mapping.
      • setPLSQLRecords

        public void setPLSQLRecords​(java.util.List<PLSQLRecordMetadata> records)
        INTERNAL: Used for OX mapping.
      • setPLSQLTables

        public void setPLSQLTables​(java.util.List<PLSQLTableMetadata> tables)
        INTERNAL: Used for OX mapping.
      • setStruct

        public void setStruct​(StructMetadata struct)
        INTERNAL: Used for OX mapping.
      • toString

        public java.lang.String toString()
        INTERNAL:
        Overrides:
        toString in class java.lang.Object
      • usesFieldAccess

        public boolean usesFieldAccess()
        INTERNAL: Returns true if this class uses field access. It will first check for an explicit access type specification, otherwise will use the default access as specified on the descriptor for this accessor since we may be processing a mapped superclass.
      • usesPropertyAccess

        public boolean usesPropertyAccess()
        INTERNAL: Returns true if this class uses property access. It will first check for an explicit access type specification, otherwise will use the default access as specified on the descriptor for this accessor since we may be processing a mapped superclass.
      • usesVirtualAccess

        public boolean usesVirtualAccess()
        INTERNAL: Returns true if this class uses virtual access. It will first check for an explicit access type specification, otherwise will use the default access as specified on the descriptor for this accessor since we may be processing a mapped superclass.
      • getOracleObjectTypes

        public java.util.List<OracleObjectTypeMetadata> getOracleObjectTypes()
        Returns the list of OracleObjectType instances.
      • setOracleObjectTypes

        public void setOracleObjectTypes​(java.util.List<OracleObjectTypeMetadata> oracleObjectTypes)
        Sets the list of OracleObjectType instances.
      • getOracleArrayTypes

        public java.util.List<OracleArrayTypeMetadata> getOracleArrayTypes()
        Returns the list of OracleArrayType instances.
      • setOracleArrayTypes

        public void setOracleArrayTypes​(java.util.List<OracleArrayTypeMetadata> oracleArrayTypes)
        Sets the list of OracleArrayType instances.