Top Description Fields Constructors Methods
org.eclipse.persistence.internal.jpa.weaving

public Class TransformerFactory

extends Object
Class Inheritance
Imports
java.util.ArrayList, .Collection, .HashMap, .Iterator, .List, .Map, org.eclipse.persistence.asm.Type, org.eclipse.persistence.descriptors.ClassDescriptor, org.eclipse.persistence.indirection.ValueHolderInterface, org.eclipse.persistence.internal.descriptors.VirtualAttributeMethodInfo, org.eclipse.persistence.internal.helper.Helper, org.eclipse.persistence.internal.indirection.BasicIndirectionPolicy, org.eclipse.persistence.internal.jpa.metadata.accessors.objects.MetadataClass, .MetadataField, .MetadataMethod, org.eclipse.persistence.internal.sessions.AbstractSession, org.eclipse.persistence.internal.weaving.PersistenceWeavedChangeTracking, org.eclipse.persistence.logging.SessionLog, org.eclipse.persistence.mappings.DatabaseMapping, .ForeignReferenceMapping, org.eclipse.persistence.mappings.foundation.AbstractDirectMapping, org.eclipse.persistence.sessions.Project, .Session

This class creates a ClassFileTransformer that is used for dynamic bytecode weaving. It is called by org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl#predeploy

Note

The Session's Project is is scanned to ensure that weaving is supported and is modified to suit (set the org.eclipse.persistence.descriptors.changetracking.ObjectChangePolicy for the Descriptor).

Field Summary

Modifier and TypeField and Description
public static final String
public static final String
protected Map<String, ClassDetails>
protected ClassLoader
protected Collection<MetadataClass>
protected Session
protected boolean
protected boolean
protected boolean
protected boolean
protected boolean
public static final String
public static final String
public static final String
public static final String
public static final String
public static final String
protected boolean

Constructor Summary

AccessConstructor and Description
public
TransformerFactory(Session session, Collection<MetadataClass> entityClasses, ClassLoader classLoader, boolean weaveLazy, boolean weaveChangeTracking, boolean weaveFetchGroups, boolean weaveInternal, boolean weaveRest, boolean weaveMappedSuperClass)

Method Summary

Modifier and TypeMethod and Description
public void
addClassDetailsForMappedSuperClasses(MetadataClass clz, ClassDescriptor initialDescriptor, ClassDetails classDetails, Map<String, ClassDetails> classDetailsMap, List<DatabaseMapping> unMappedAttributes, boolean weaveChangeTracking)

INTERNAL: Look higher in the hierarchy for the mappings listed in the unMappedAttribute list.

public void
buildClassDetailsAndModifyProject()

Build a list ClassDetails instance that contains a ClassDetails for each class in our entities list.

public PersistenceWeaver
protected boolean
canChangeTrackingBeEnabled(ClassDescriptor descriptor, MetadataClass clz, boolean globalWeaveChangeTracking)

Check to ensure the class meets all the conditions necessary to enable change tracking This could occur either if the class already has change tracking implemented or if the class is capable of having change tracking woven based on the descriptor.

protected boolean
canWeaveValueHolders(MetadataClass clz, List<DatabaseMapping> mappings)

Determine if value holders are required to be weaved into the class.

private ClassDetails
createClassDetails(MetadataClass metadataClass, boolean weaveValueHolders, boolean weaveChangeTracking, boolean weaveFetchGroups, boolean weaveInternal, boolean weaveRest)

public static PersistenceWeaver
createTransformerAndModifyProject(Session session, Collection<MetadataClass> entityClasses, ClassLoader classLoader, boolean weaveLazy, boolean weaveChangeTracking, boolean weaveFetchGroups, boolean weaveInternal, boolean weaveRest, boolean weaveMappedSuperClass)

protected ClassDescriptor
findDescriptor(Project project, String className)

Find a descriptor by name in the given project used to avoid referring to descriptors by class.

private MetadataClass
getAttributeDeclaringClass(MetadataClass metadataClass, String attributeName)

Return the class which is the source of the attribute.

private MetadataClass
getAttributeTypeFromClass(MetadataClass metadataClass, String attributeName, DatabaseMapping mapping, boolean checkSuperclass)

Use the database mapping for an attribute to find it's type.

protected boolean
hasFieldInClass(MetadataClass metadataClass, String attributeName)

Return if the class contains the field.

protected void
log(int level, String msg, Object[] params)

protected List<DatabaseMapping>
storeAttributeMappings(MetadataClass metadataClass, ClassDetails classDetails, List<DatabaseMapping> mappings, boolean weaveValueHolders)

INTERNAL: Store a set of attribute mappings on the given ClassDetails that correspond to the given class.

protected boolean
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

CANNOT_WEAVE_CHANGETRACKINGback to summary
public static final String CANNOT_WEAVE_CHANGETRACKING
CANNOT_WEAVE_VIRTUAL_ONE_TO_ONEback to summary
public static final String CANNOT_WEAVE_VIRTUAL_ONE_TO_ONE
classDetailsMapback to summary
protected Map<String, ClassDetails> classDetailsMap
classLoaderback to summary
protected ClassLoader classLoader
entityClassesback to summary
protected Collection<MetadataClass> entityClasses
sessionback to summary
protected Session session
weaveChangeTrackingback to summary
protected boolean weaveChangeTracking
weaveFetchGroupsback to summary
protected boolean weaveFetchGroups
weaveInternalback to summary
protected boolean weaveInternal
weaveLazyback to summary
protected boolean weaveLazy
weaveMappedSuperClassback to summary
protected boolean weaveMappedSuperClass
WEAVER_CLASS_NOT_IN_PROJECTback to summary
public static final String WEAVER_CLASS_NOT_IN_PROJECT
WEAVER_DISABLE_BY_SYSPROPback to summary
public static final String WEAVER_DISABLE_BY_SYSPROP
WEAVER_DISABLE_CT_NOT_SUPPORTEDback to summary
public static final String WEAVER_DISABLE_CT_NOT_SUPPORTED
WEAVER_FOUND_USER_IMPL_CTback to summary
public static final String WEAVER_FOUND_USER_IMPL_CT
WEAVER_NULL_PROJECTback to summary
public static final String WEAVER_NULL_PROJECT
WEAVER_PROCESSING_CLASSback to summary
public static final String WEAVER_PROCESSING_CLASS
weaveRestback to summary
protected boolean weaveRest

Constructor Detail

TransformerFactoryback to summary
public TransformerFactory(Session session, Collection<MetadataClass> entityClasses, ClassLoader classLoader, boolean weaveLazy, boolean weaveChangeTracking, boolean weaveFetchGroups, boolean weaveInternal, boolean weaveRest, boolean weaveMappedSuperClass)

Method Detail

addClassDetailsForMappedSuperClassesback to summary
public void addClassDetailsForMappedSuperClasses(MetadataClass clz, ClassDescriptor initialDescriptor, ClassDetails classDetails, Map<String, ClassDetails> classDetailsMap, List<DatabaseMapping> unMappedAttributes, boolean weaveChangeTracking)

INTERNAL: Look higher in the hierarchy for the mappings listed in the unMappedAttribute list. We assume that if a mapping exists, the attribute must either be mapped from the owning class or from a superclass.

buildClassDetailsAndModifyProjectback to summary
public void buildClassDetailsAndModifyProject()

Build a list ClassDetails instance that contains a ClassDetails for each class in our entities list.

buildPersistenceWeaverback to summary
public PersistenceWeaver buildPersistenceWeaver()
canChangeTrackingBeEnabledback to summary
protected boolean canChangeTrackingBeEnabled(ClassDescriptor descriptor, MetadataClass clz, boolean globalWeaveChangeTracking)

Check to ensure the class meets all the conditions necessary to enable change tracking This could occur either if the class already has change tracking implemented or if the class is capable of having change tracking woven based on the descriptor.

canWeaveValueHoldersback to summary
protected boolean canWeaveValueHolders(MetadataClass clz, List<DatabaseMapping> mappings)

Determine if value holders are required to be weaved into the class.

createClassDetailsback to summary
private ClassDetails createClassDetails(MetadataClass metadataClass, boolean weaveValueHolders, boolean weaveChangeTracking, boolean weaveFetchGroups, boolean weaveInternal, boolean weaveRest)
createTransformerAndModifyProjectback to summary
public static PersistenceWeaver createTransformerAndModifyProject(Session session, Collection<MetadataClass> entityClasses, ClassLoader classLoader, boolean weaveLazy, boolean weaveChangeTracking, boolean weaveFetchGroups, boolean weaveInternal, boolean weaveRest, boolean weaveMappedSuperClass)
findDescriptorback to summary
protected ClassDescriptor findDescriptor(Project project, String className)

Find a descriptor by name in the given project used to avoid referring to descriptors by class. This avoids having to construct a project by class facilitating weaving

getAttributeDeclaringClassback to summary
private MetadataClass getAttributeDeclaringClass(MetadataClass metadataClass, String attributeName)

Return the class which is the source of the attribute. i.e. the class that defines the attribute in its class file.

getAttributeTypeFromClassback to summary
private MetadataClass getAttributeTypeFromClass(MetadataClass metadataClass, String attributeName, DatabaseMapping mapping, boolean checkSuperclass)

Use the database mapping for an attribute to find it's type. The type returned will either be the field type of the field in the object or the type returned by the getter method.

hasFieldInClassback to summary
protected boolean hasFieldInClass(MetadataClass metadataClass, String attributeName)

Return if the class contains the field.

logback to summary
protected void log(int level, String msg, Object[] params)
storeAttributeMappingsback to summary
protected List<DatabaseMapping> storeAttributeMappings(MetadataClass metadataClass, ClassDetails classDetails, List<DatabaseMapping> mappings, boolean weaveValueHolders)

INTERNAL: Store a set of attribute mappings on the given ClassDetails that correspond to the given class. Return the list of mappings that is not specifically found on the given class. These attributes will be found on MappedSuperclasses.

wasChangeTrackingAlreadyWeavedback to summary
protected boolean wasChangeTrackingAlreadyWeaved(Class<?> clz)