Class EntityMarkerClassTransformer

java.lang.Object
org.broadleafcommerce.common.extensibility.jpa.copy.AbstractClassTransformer
org.broadleafcommerce.common.extensibility.jpa.convert.EntityMarkerClassTransformer
All Implemented Interfaces:
jakarta.persistence.spi.ClassTransformer, BroadleafClassTransformer, org.springframework.beans.factory.InitializingBean

public class EntityMarkerClassTransformer extends AbstractClassTransformer implements BroadleafClassTransformer

This class transformer will check to see if there is class that should have been loaded by the MergePersistenceUnitManager (meaning, it has an @Entity, @MappedSuperclass or @Embeddable annotation on it and will be inside of a persistence.xml). If it it should have, it will add the fully qualified classname of that class to the transformedClassNames list.

This is a validation check to ensure that the class transformers are actually working properly

Author:
Andre Azzolini (apazzolini)
  • Field Details

    • LOG

      protected static final org.apache.commons.logging.Log LOG
    • transformedEntityClassNames

      protected HashSet<String> transformedEntityClassNames
    • transformedNonEntityClassNames

      protected HashSet<String> transformedNonEntityClassNames
    • ignorePatterns

      protected List<DirectCopyIgnorePattern> ignorePatterns
  • Constructor Details

    • EntityMarkerClassTransformer

      public EntityMarkerClassTransformer()
  • Method Details

    • transform

      public byte[] transform(ClassLoader loader, String className, Class<?> classBeingRedefined, ProtectionDomain protectionDomain, byte[] classfileBuffer) throws IllegalClassFormatException
      Specified by:
      transform in interface jakarta.persistence.spi.ClassTransformer
      Throws:
      IllegalClassFormatException
    • containsTypeLevelPersistenceAnnotation

      protected boolean containsTypeLevelPersistenceAnnotation(javassist.bytecode.annotation.Annotation[] annotations)
      Determines if a given annotation set contains annotations that correspond to ones that someone would expect to appear in a persistence.xml
      Parameters:
      annotations -
      Returns:
    • isIgnored

      protected boolean isIgnored(String convertedClassName)
    • compileJPAProperties

      public void compileJPAProperties(Properties props, Object key) throws Exception
      Specified by:
      compileJPAProperties in interface BroadleafClassTransformer
      Throws:
      Exception
    • getTransformedEntityClassNames

      public HashSet<String> getTransformedEntityClassNames()
      Returns:
      a list of fully qualified classnames of class that have an @Entity, @MappedSuperclass or @Embeddable annotation and were picked up by this class transformer (meaning that other class transformers also would have had a chance to perform their necessary work on those classes)
    • getTransformedNonEntityClassNames

      public HashSet<String> getTransformedNonEntityClassNames()
      Returns:
      a list of fully qualified classnames of classes that do not have an @Entity, @MappedSuperclass or @Embeddable annotation but were picked up by this class transformer. This usually results in a benign misconfiguration as there are unnecessary classes within the MergePersistenceUnitManager
    • getIgnorePatterns

      public List<DirectCopyIgnorePattern> getIgnorePatterns()
    • setIgnorePatterns

      public void setIgnorePatterns(List<DirectCopyIgnorePattern> ignorePatterns)