Class RemoveCacheClassTransformer

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

public class RemoveCacheClassTransformer extends AbstractClassTransformer implements BroadleafClassTransformer, org.springframework.beans.factory.BeanFactoryAware
Strip the cache annotation from classes and the class fields

Example configuration

 
 @Merge("blMergedClassTransformers")
 public RemoveCacheClassTransformer RemoveProductCache() {
     RemoveCacheClassTransformer transformer = new RemoveCacheClassTransformer("Remove Product Cache");
     List<String> cacheRegions = new ArrayList<>();
     cacheRegions.add("blCustomerElements");
     cacheRegions.add("blOrderElements");
     transformer.setCacheRegions(cacheRegions);
     return transformer;
 }
 
 

This feature requires that the property "remove.order.customer.entity.l2cache" be enabled (true).

Author:
Jeff Fischer, Daniel Colgrove
  • Field Details

    • moduleName

      protected String moduleName
    • classNames

      protected List<String> classNames
    • cacheRegions

      protected List<String> cacheRegions
    • annotationClass

      protected String annotationClass
    • beanFactory

      protected org.springframework.beans.factory.config.ConfigurableBeanFactory beanFactory
    • removeOrderCustomerEntityL2Cache

      @Value("${remove.order.customer.entity.l2cache:false}") protected Boolean removeOrderCustomerEntityL2Cache
  • Constructor Details

    • RemoveCacheClassTransformer

      public RemoveCacheClassTransformer(String moduleName)
  • Method Details

    • compileJPAProperties

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

      public void setBeanFactory(org.springframework.beans.factory.BeanFactory beanFactory) throws org.springframework.beans.BeansException
      Specified by:
      setBeanFactory in interface org.springframework.beans.factory.BeanFactoryAware
      Throws:
      org.springframework.beans.BeansException
    • transform

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

      protected Boolean classQualifies(String className)
    • annotationQualifies

      protected Boolean annotationQualifies(javassist.bytecode.ConstPool constantPool, List<?> attributes)
    • cacheRegionQualifies

      protected Boolean cacheRegionQualifies(javassist.bytecode.annotation.Annotation annotation)
    • stripAnnotation

      protected javassist.bytecode.AnnotationsAttribute stripAnnotation(javassist.bytecode.ConstPool constantPool, List<?> attributes)
    • isPropertyEnabled

      protected Boolean isPropertyEnabled(String propertyName)
    • getClassNames

      public List<String> getClassNames()
      The list of fully-qualified classes to be impacted by this transformer
      Returns:
    • setClassNames

      public void setClassNames(List<String> classNames)
    • getCacheRegions

      public List<String> getCacheRegions()
      The list of cache region names to be removed by this transformer
      Returns:
    • setCacheRegions

      public void setCacheRegions(List<String> cacheRegions)
    • getAnnotationClass

      public String getAnnotationClass()
      The fully-qualified classname of the annotation to remove at the class and field level
      Returns:
    • setAnnotationClass

      public void setAnnotationClass(String annotationClass)