Class ConditionalFieldAnnotationsClassTransformer
java.lang.Object
org.broadleafcommerce.common.extensibility.jpa.copy.AbstractClassTransformer
org.broadleafcommerce.common.extensibility.jpa.copy.ConditionalFieldAnnotationsClassTransformer
- All Implemented Interfaces:
jakarta.persistence.spi.ClassTransformer,BroadleafClassTransformer,org.springframework.beans.factory.InitializingBean
public class ConditionalFieldAnnotationsClassTransformer
extends AbstractClassTransformer
implements BroadleafClassTransformer
The purpose of this class is to allow the conditional addition or removal of annotations to a target entity based on template class.
This does not add new fields or methods, nor does it remove fields or methods. Rather, this class copies annotations from a template class' field(s) to a target class' fields. It removes annotations from the target that are not on the template.
As a result, this class takes the annotations from fields of a template class and adds them to fields in a target class. If the template contains fields that are not on the target, then unexpected behavior such as NullPointerExceptions may occur.
- Author:
- Kelly Tisdell
-
Field Summary
FieldsFields inherited from class org.broadleafcommerce.common.extensibility.jpa.copy.AbstractClassTransformer
alreadyLoadedClasses, preLoadClassNamePatterns -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidcompileJPAProperties(Properties props, Object key) byte[]transform(ClassLoader loader, String className, Class<?> classBeingRedefined, ProtectionDomain protectionDomain, byte[] classfileBuffer) Will return null if the Spring property value defined in#propertyNameresolves to false, or if an exception occurs while trying to determine the value for the property.Methods inherited from class org.broadleafcommerce.common.extensibility.jpa.copy.AbstractClassTransformer
afterPropertiesSet, setPreLoadClassNamePatterns
-
Field Details
-
manager
-
logger
-
moduleName
-
-
Constructor Details
-
ConditionalFieldAnnotationsClassTransformer
-
-
Method Details
-
transform
public byte[] transform(ClassLoader loader, String className, Class<?> classBeingRedefined, ProtectionDomain protectionDomain, byte[] classfileBuffer) throws IllegalClassFormatException Will return null if the Spring property value defined in#propertyNameresolves to false, or if an exception occurs while trying to determine the value for the property.- Specified by:
transformin interfacejakarta.persistence.spi.ClassTransformer- Parameters:
loader-className-classBeingRedefined-protectionDomain-classfileBuffer-- Returns:
- Throws:
IllegalClassFormatException
-
compileJPAProperties
- Specified by:
compileJPAPropertiesin interfaceBroadleafClassTransformer- Throws:
Exception
-