use of org.eclipse.persistence.internal.jpa.metadata.accessors.objects.MetadataAccessibleObject in project eclipselink by eclipse-ee4j.
the class ClassAccessor method 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.
*/
public void addAccessors() {
if (m_attributes != null) {
for (MappingAccessor accessor : m_attributes.getAccessors()) {
// Load the accessible object from the class.
MetadataAccessibleObject accessibleObject = null;
// We must init all xml mapping accessors with a reference
// of their owning class accessor. The mapping accessors
// require metatata information from them to ensure they
// process themselves correctly.
accessor.initXMLMappingAccessor(this);
// from a parent class)
if (accessor.usesVirtualAccess()) {
accessibleObject = getAccessibleVirtualMethod(accessor);
} else if (accessor.usesPropertyAccess()) {
accessibleObject = getAccessibleMethod(accessor);
} else {
accessibleObject = getAccessibleField(accessor);
}
// further process this accessor.
if (accessibleObject != null) {
// Initialize the accessor with its real accessible object
// now, that is a field or method since it will currently
// hold a reference to its owning class' accessible object.
accessor.initXMLObject(accessibleObject, getEntityMappings());
// It's now safe to init the correct access type for this
// mapping accessor since we now have set the actual
// accessible object for this mapping accessor. Note: the
// initAccess call was originally in initXMLObject, but with
// the current processing setup that isn't valid since
// mapping accessors have their accessible object 'faked'
// out for xml merging purposes during XMLAttributes
// initXMLObject call. Doing the access initialization there
// could cause one of two problems: Firstly, an incorrect
// access type setting and secondly and more importantly, a
// null pointer exception (bug 264596) since our descriptor
// hasn't been set which we use to retrieve the default
// access type.
accessor.initAccess();
// for a virtual class.
if (accessor.usesVirtualAccess() && !accessor.hasAttributeType()) {
throw ValidationException.noAttributeTypeSpecification(accessor.getAttributeName(), getJavaClassName(), getLocation());
}
// Add the accessor to the descriptor's list
addAccessor(accessor);
}
}
}
// look any further then what is defined in XML.
if (!usesVirtualAccess()) {
if (usesPropertyAccess()) {
addAccessorMethods(false);
} else {
addAccessorFields(false);
}
}
}
Aggregations