java.lang.Object
org.eclipse.persistence.internal.jpa.weaving.TransformerFactory

public class TransformerFactory extends Object
This class creates a ClassFileTransformer that is used for dynamic bytecode weaving. It is called by EntityManagerSetupImpl.predeploy(jakarta.persistence.spi.PersistenceUnitInfo, java.util.Map)

Note: The Session's Project is is scanned to ensure that weaving is supported and is modified to suit (set the ObjectChangePolicy for the Descriptor).

  • Field Details

    • WEAVER_DISABLE_CT_NOT_SUPPORTED

      public static final String WEAVER_DISABLE_CT_NOT_SUPPORTED
      See Also:
    • WEAVER_FOUND_USER_IMPL_CT

      public static final String WEAVER_FOUND_USER_IMPL_CT
      See Also:
    • WEAVER_NULL_PROJECT

      public static final String WEAVER_NULL_PROJECT
      See Also:
    • WEAVER_DISABLE_BY_SYSPROP

      public static final String WEAVER_DISABLE_BY_SYSPROP
      See Also:
    • WEAVER_CLASS_NOT_IN_PROJECT

      public static final String WEAVER_CLASS_NOT_IN_PROJECT
      See Also:
    • WEAVER_PROCESSING_CLASS

      public static final String WEAVER_PROCESSING_CLASS
      See Also:
    • CANNOT_WEAVE_CHANGETRACKING

      public static final String CANNOT_WEAVE_CHANGETRACKING
      See Also:
    • CANNOT_WEAVE_VIRTUAL_ONE_TO_ONE

      public static final String CANNOT_WEAVE_VIRTUAL_ONE_TO_ONE
      See Also:
    • session

      protected Session session
    • entityClasses

      protected Collection<MetadataClass> entityClasses
    • classDetailsMap

      protected Map<String,ClassDetails> classDetailsMap
    • classLoader

      protected ClassLoader classLoader
    • weaveChangeTracking

      protected boolean weaveChangeTracking
    • weaveLazy

      protected boolean weaveLazy
    • weaveFetchGroups

      protected boolean weaveFetchGroups
    • weaveInternal

      protected boolean weaveInternal
    • weaveRest

      protected boolean weaveRest
    • weaveMappedSuperClass

      protected boolean weaveMappedSuperClass
  • Constructor Details

    • TransformerFactory

      public TransformerFactory(Session session, Collection<MetadataClass> entityClasses, ClassLoader classLoader, boolean weaveLazy, boolean weaveChangeTracking, boolean weaveFetchGroups, boolean weaveInternal, boolean weaveRest, boolean weaveMappedSuperClass)
  • Method Details

    • createTransformerAndModifyProject

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

      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.
    • buildPersistenceWeaver

      public PersistenceWeaver buildPersistenceWeaver()
    • buildClassDetailsAndModifyProject

      public void buildClassDetailsAndModifyProject()
      Build a list ClassDetails instance that contains a ClassDetails for each class in our entities list.
    • canChangeTrackingBeEnabled

      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.
    • wasChangeTrackingAlreadyWeaved

      protected boolean wasChangeTrackingAlreadyWeaved(Class<?> clz)
    • canWeaveValueHolders

      protected boolean canWeaveValueHolders(MetadataClass clz, List<DatabaseMapping> mappings)
      Determine if value holders are required to be weaved into the class.
    • findDescriptor

      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
    • hasFieldInClass

      protected boolean hasFieldInClass(MetadataClass metadataClass, String attributeName)
      Return if the class contains the field.
    • storeAttributeMappings

      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.
    • log

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