Top Description Inners Fields Constructors Methods
org.eclipse.persistence.internal.oxm

public final Class ReferenceResolver

extends Object
Class Inheritance
Imports
java.util.ArrayList, .Collection, .HashMap, .Iterator, .LinkedHashMap, .List, .Map, .Vector, java.util.concurrent.Callable, org.eclipse.persistence.core.descriptors.CoreDescriptor, .CoreInheritancePolicy, org.eclipse.persistence.core.mappings.CoreAttributeAccessor, .CoreMapping, org.eclipse.persistence.exceptions.ConversionException, .XMLMarshalException, org.eclipse.persistence.internal.core.helper.CoreClassConstants, org.eclipse.persistence.internal.core.queries.CoreContainerPolicy, org.eclipse.persistence.internal.core.sessions.CoreAbstractSession, org.eclipse.persistence.internal.identitymaps.CacheId, org.eclipse.persistence.internal.oxm.mappings.CollectionReferenceMapping, .Descriptor, .Field, .InverseReferenceMapping, .Mapping, .ObjectReferenceMapping, org.xml.sax.ErrorHandler, .SAXException, .SAXParseException

This class is leveraged by reference mappings. It plays 3 roles:

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
ReferenceResolver.ReferenceKey

This class serves to represent a key for org.eclipse.persistence.internal.oxm.Reference when used in maps.

Field Summary

Modifier and TypeField and Description
private Map<Class<?>, Map<Object, Object>>
cache

Speed-up cache that was introduced in 2.5 instead of the previous speed-up mechanisms using session cache.

private static final int
LIST_INITIAL_CAPACITY

The default initial capacity of list - must be a power of two.

private static final int
MAP_INITIAL_CAPACITY

The default initial capacity of map - must be a power of two.

private LinkedHashMap<ReferenceResolver.ReferenceKey, Reference>
referencesMap

Stores References.

private final ReferenceResolver.ReferenceKey
refKey

This field is in fact used locally only.

private List<Reference>
unluckyReferences

Stores References that have been kicked out of the referencesMap because a Reference with same key was added to it.

private List<Integer>
unluckyRefPositions

Stores positions of References that have been kicked out of the referencesMap.

Constructor Summary

AccessConstructor and Description
public
ReferenceResolver()

The default constructor initializes the list of References.

Method Summary

Modifier and TypeMethod and Description
public void
addReference(final Reference ref)

Add a Reference object to the list - these References will be resolved after unmarshalling is complete.

private void
createPKVectorsFromMap(final Reference reference, final CollectionReferenceMapping<ABSTRACT_SESSION extends CoreAbstractSession<DESCRIPTOR extends CoreDescriptor<ATTRIBUTE_GROUP extends CoreAttributeGroup, DESCRIPTOR_EVENT_MANAGER extends CoreDescriptorEventManager, FIELD extends CoreField, INHERITANCE_POLICY extends CoreInheritancePolicy, INSTANTIATION_POLICY extends CoreInstantiationPolicy, LIST extends List<E>, OBJECT_BUILDER extends CoreObjectBuilder>, LOGIN extends CoreLogin<PLATFORM extends CorePlatform>, PLATFORM extends CorePlatform<CONVERSION_MANAGER extends CoreConversionManager>, PROJECT extends CoreProject<DESCRIPTOR extends CoreDescriptor<ATTRIBUTE_GROUP extends CoreAttributeGroup, DESCRIPTOR_EVENT_MANAGER extends CoreDescriptorEventManager, FIELD extends CoreField, INHERITANCE_POLICY extends CoreInheritancePolicy, INSTANTIATION_POLICY extends CoreInstantiationPolicy, LIST extends List<E>, OBJECT_BUILDER extends CoreObjectBuilder>, LOGIN extends CoreLogin<PLATFORM extends CorePlatform>, SESSION extends CoreSession>, SESSION_EVENT_MANAGER extends CoreSessionEventManager<SESSION_EVENT_LISTENER extends CoreSessionEventListener>>, ATTRIBUTE_ACCESSOR extends CoreAttributeAccessor, CONTAINER_POLICY extends CoreContainerPolicy<ABSTRACT_SESSION extends CoreAbstractSession>, DESCRIPTOR extends CoreDescriptor<ATTRIBUTE_GROUP extends CoreAttributeGroup, DESCRIPTOR_EVENT_MANAGER extends CoreDescriptorEventManager, FIELD extends CoreField, INHERITANCE_POLICY extends CoreInheritancePolicy, INSTANTIATION_POLICY extends CoreInstantiationPolicy, LIST extends List<E>, OBJECT_BUILDER extends CoreObjectBuilder>, FIELD extends CoreField, UNMARSHAL_RECORD extends UnmarshalRecord, XML_FIELD extends Field, XML_RECORD extends XMLRecord> mapping)

INTERNAL: Create primary key values to be used for cache lookup.

public Reference
getReference(final ObjectReferenceMapping<ABSTRACT_SESSION extends CoreAbstractSession<DESCRIPTOR extends CoreDescriptor<ATTRIBUTE_GROUP extends CoreAttributeGroup, DESCRIPTOR_EVENT_MANAGER extends CoreDescriptorEventManager, FIELD extends CoreField, INHERITANCE_POLICY extends CoreInheritancePolicy, INSTANTIATION_POLICY extends CoreInstantiationPolicy, LIST extends List<E>, OBJECT_BUILDER extends CoreObjectBuilder>, LOGIN extends CoreLogin<PLATFORM extends CorePlatform>, PLATFORM extends CorePlatform<CONVERSION_MANAGER extends CoreConversionManager>, PROJECT extends CoreProject<DESCRIPTOR extends CoreDescriptor<ATTRIBUTE_GROUP extends CoreAttributeGroup, DESCRIPTOR_EVENT_MANAGER extends CoreDescriptorEventManager, FIELD extends CoreField, INHERITANCE_POLICY extends CoreInheritancePolicy, INSTANTIATION_POLICY extends CoreInstantiationPolicy, LIST extends List<E>, OBJECT_BUILDER extends CoreObjectBuilder>, LOGIN extends CoreLogin<PLATFORM extends CorePlatform>, SESSION extends CoreSession>, SESSION_EVENT_MANAGER extends CoreSessionEventManager<SESSION_EVENT_LISTENER extends CoreSessionEventListener>>, ATTRIBUTE_ACCESSOR extends CoreAttributeAccessor, CONTAINER_POLICY extends CoreContainerPolicy<ABSTRACT_SESSION extends CoreAbstractSession>, DESCRIPTOR extends CoreDescriptor<ATTRIBUTE_GROUP extends CoreAttributeGroup, DESCRIPTOR_EVENT_MANAGER extends CoreDescriptorEventManager, FIELD extends CoreField, INHERITANCE_POLICY extends CoreInheritancePolicy, INSTANTIATION_POLICY extends CoreInstantiationPolicy, LIST extends List<E>, OBJECT_BUILDER extends CoreObjectBuilder>, FIELD extends CoreField, UNMARSHAL_RECORD extends UnmarshalRecord, XML_FIELD extends Field<CONVERSION_MANAGER extends ConversionManager, NAMESPACE_RESOLVER extends NamespaceResolver>, XML_RECORD extends XMLRecord> mapping, final Object sourceObject)

Retrieve the reference for a given mapping instance.

public Reference
getReference(final ObjectReferenceMapping<ABSTRACT_SESSION extends CoreAbstractSession<DESCRIPTOR extends CoreDescriptor<ATTRIBUTE_GROUP extends CoreAttributeGroup, DESCRIPTOR_EVENT_MANAGER extends CoreDescriptorEventManager, FIELD extends CoreField, INHERITANCE_POLICY extends CoreInheritancePolicy, INSTANTIATION_POLICY extends CoreInstantiationPolicy, LIST extends List<E>, OBJECT_BUILDER extends CoreObjectBuilder>, LOGIN extends CoreLogin<PLATFORM extends CorePlatform>, PLATFORM extends CorePlatform<CONVERSION_MANAGER extends CoreConversionManager>, PROJECT extends CoreProject<DESCRIPTOR extends CoreDescriptor<ATTRIBUTE_GROUP extends CoreAttributeGroup, DESCRIPTOR_EVENT_MANAGER extends CoreDescriptorEventManager, FIELD extends CoreField, INHERITANCE_POLICY extends CoreInheritancePolicy, INSTANTIATION_POLICY extends CoreInstantiationPolicy, LIST extends List<E>, OBJECT_BUILDER extends CoreObjectBuilder>, LOGIN extends CoreLogin<PLATFORM extends CorePlatform>, SESSION extends CoreSession>, SESSION_EVENT_MANAGER extends CoreSessionEventManager<SESSION_EVENT_LISTENER extends CoreSessionEventListener>>, ATTRIBUTE_ACCESSOR extends CoreAttributeAccessor, CONTAINER_POLICY extends CoreContainerPolicy<ABSTRACT_SESSION extends CoreAbstractSession>, DESCRIPTOR extends CoreDescriptor<ATTRIBUTE_GROUP extends CoreAttributeGroup, DESCRIPTOR_EVENT_MANAGER extends CoreDescriptorEventManager, FIELD extends CoreField, INHERITANCE_POLICY extends CoreInheritancePolicy, INSTANTIATION_POLICY extends CoreInstantiationPolicy, LIST extends List<E>, OBJECT_BUILDER extends CoreObjectBuilder>, FIELD extends CoreField, UNMARSHAL_RECORD extends UnmarshalRecord, XML_FIELD extends Field<CONVERSION_MANAGER extends ConversionManager, NAMESPACE_RESOLVER extends NamespaceResolver>, XML_RECORD extends XMLRecord> mapping, final Object sourceObject, final Field<CONVERSION_MANAGER extends ConversionManager, NAMESPACE_RESOLVER extends NamespaceResolver> xmlField)

Return a reference for the given mapping and source object, that doesn't already contain an entry for the provided field.

private Object
getValue(final CoreAbstractSession<DESCRIPTOR extends CoreDescriptor<ATTRIBUTE_GROUP extends CoreAttributeGroup, DESCRIPTOR_EVENT_MANAGER extends CoreDescriptorEventManager, FIELD extends CoreField, INHERITANCE_POLICY extends CoreInheritancePolicy, INSTANTIATION_POLICY extends CoreInstantiationPolicy, LIST extends List<E>, OBJECT_BUILDER extends CoreObjectBuilder>, LOGIN extends CoreLogin<PLATFORM extends CorePlatform>, PLATFORM extends CorePlatform<CONVERSION_MANAGER extends CoreConversionManager>, PROJECT extends CoreProject<DESCRIPTOR extends CoreDescriptor<ATTRIBUTE_GROUP extends CoreAttributeGroup, DESCRIPTOR_EVENT_MANAGER extends CoreDescriptorEventManager, FIELD extends CoreField, INHERITANCE_POLICY extends CoreInheritancePolicy, INSTANTIATION_POLICY extends CoreInstantiationPolicy, LIST extends List<E>, OBJECT_BUILDER extends CoreObjectBuilder>, LOGIN extends CoreLogin<PLATFORM extends CorePlatform>, SESSION extends CoreSession>, SESSION_EVENT_MANAGER extends CoreSessionEventManager<SESSION_EVENT_LISTENER extends CoreSessionEventListener>> session, final Reference reference, final CacheId primaryKey, final ErrorHandler handler)

Add java doc if you understand this code.

private Object
getValue(Class<?> clazz, CacheId primaryKey)

Retrieves value from cache.

private void
perform(final CoreAbstractSession<DESCRIPTOR extends CoreDescriptor<ATTRIBUTE_GROUP extends CoreAttributeGroup, DESCRIPTOR_EVENT_MANAGER extends CoreDescriptorEventManager, FIELD extends CoreField, INHERITANCE_POLICY extends CoreInheritancePolicy, INSTANTIATION_POLICY extends CoreInstantiationPolicy, LIST extends List<E>, OBJECT_BUILDER extends CoreObjectBuilder>, LOGIN extends CoreLogin<PLATFORM extends CorePlatform>, PLATFORM extends CorePlatform<CONVERSION_MANAGER extends CoreConversionManager>, PROJECT extends CoreProject<DESCRIPTOR extends CoreDescriptor<ATTRIBUTE_GROUP extends CoreAttributeGroup, DESCRIPTOR_EVENT_MANAGER extends CoreDescriptorEventManager, FIELD extends CoreField, INHERITANCE_POLICY extends CoreInheritancePolicy, INSTANTIATION_POLICY extends CoreInstantiationPolicy, LIST extends List<E>, OBJECT_BUILDER extends CoreObjectBuilder>, LOGIN extends CoreLogin<PLATFORM extends CorePlatform>, SESSION extends CoreSession>, SESSION_EVENT_MANAGER extends CoreSessionEventManager<SESSION_EVENT_LISTENER extends CoreSessionEventListener>> session, final IDResolver userSpecifiedResolver, final ErrorHandler handler, final Reference reference)

Add java doc if you understand this code.

public void
putValue(final Class<?> clazz, final Object key, final Object object)

Store an instance by key based on a mapped class.

private void
resetContainers()

Resets the references containers.

public void
resolveReferences(final CoreAbstractSession<DESCRIPTOR extends CoreDescriptor<ATTRIBUTE_GROUP extends CoreAttributeGroup, DESCRIPTOR_EVENT_MANAGER extends CoreDescriptorEventManager, FIELD extends CoreField, INHERITANCE_POLICY extends CoreInheritancePolicy, INSTANTIATION_POLICY extends CoreInstantiationPolicy, LIST extends List<E>, OBJECT_BUILDER extends CoreObjectBuilder>, LOGIN extends CoreLogin<PLATFORM extends CorePlatform>, PLATFORM extends CorePlatform<CONVERSION_MANAGER extends CoreConversionManager>, PROJECT extends CoreProject<DESCRIPTOR extends CoreDescriptor<ATTRIBUTE_GROUP extends CoreAttributeGroup, DESCRIPTOR_EVENT_MANAGER extends CoreDescriptorEventManager, FIELD extends CoreField, INHERITANCE_POLICY extends CoreInheritancePolicy, INSTANTIATION_POLICY extends CoreInstantiationPolicy, LIST extends List<E>, OBJECT_BUILDER extends CoreObjectBuilder>, LOGIN extends CoreLogin<PLATFORM extends CorePlatform>, SESSION extends CoreSession>, SESSION_EVENT_MANAGER extends CoreSessionEventManager<SESSION_EVENT_LISTENER extends CoreSessionEventListener>>
typically will be a unit of work
session
,
final IDResolver
a user-provided subclass of IDResolver, may be null
userSpecifiedResolver
,
final ErrorHandler handler)

INTERNAL: Iterates through all references.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait