org.broadleafcommerce.common.extensibility.jpa.copy
Class DirectCopyClassTransformer

java.lang.Object
  extended by org.broadleafcommerce.common.extensibility.jpa.copy.DirectCopyClassTransformer
All Implemented Interfaces:
javax.persistence.spi.ClassTransformer, BroadleafClassTransformer

public class DirectCopyClassTransformer
extends Object
implements BroadleafClassTransformer

This class transformer will copy fields, methods, and interface definitions from a source class to a target class, based on the xformTemplates map. It will fail if it encouters any duplicate definitions.

Author:
Andre Azzolini (apazzolini)

Field Summary
protected  SupportLogger logger
           
protected  String moduleName
           
protected static List<String> transformedMethods
           
protected  Map<String,String> xformTemplates
           
 
Constructor Summary
DirectCopyClassTransformer(String moduleName)
           
 
Method Summary
 void compileJPAProperties(Properties props, Object key)
           
protected  String getImplementationType(String className)
          This method will do its best to return an implementation type for a given classname.
 Map<String,String> getXformTemplates()
           
protected  String methodDescription(javassist.CtMethod method)
           
 void setXformTemplates(Map<String,String> xformTemplates)
           
 byte[] transform(ClassLoader loader, String className, Class<?> classBeingRedefined, ProtectionDomain protectionDomain, byte[] classfileBuffer)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

protected SupportLogger logger

moduleName

protected String moduleName

xformTemplates

protected Map<String,String> xformTemplates

transformedMethods

protected static List<String> transformedMethods
Constructor Detail

DirectCopyClassTransformer

public DirectCopyClassTransformer(String moduleName)
Method Detail

compileJPAProperties

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

transform

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

getImplementationType

protected String getImplementationType(String className)
This method will do its best to return an implementation type for a given classname. This will allow weaving template classes to have initialized values. We provide default implementations for List, Map, and Set, and will attempt to utilize a default constructor for other classes. If the className contains an '[', we will return null.


methodDescription

protected String methodDescription(javassist.CtMethod method)

getXformTemplates

public Map<String,String> getXformTemplates()

setXformTemplates

public void setXformTemplates(Map<String,String> xformTemplates)


Copyright © 2013. All Rights Reserved.