1 17 package org.apache.geronimo.persistence; 18 19 import java.lang.instrument.ClassFileTransformer ; 20 import java.lang.instrument.IllegalClassFormatException ; 21 import java.security.ProtectionDomain ; 22 23 import javax.persistence.spi.ClassTransformer; 24 25 28 public class TransformerWrapper implements ClassFileTransformer { 29 30 private final ClassTransformer classTransformer; 31 private final ClassLoader classLoader; 32 33 public TransformerWrapper(ClassTransformer classTransformer, ClassLoader classLoader) { 34 this.classTransformer = classTransformer; 35 this.classLoader = classLoader; 36 } 37 38 public byte[] transform(ClassLoader loader, String className, Class <?> classBeingRedefined, ProtectionDomain protectionDomain, byte[] classfileBuffer) throws IllegalClassFormatException { 39 if (loader != classLoader) { 40 return null; 41 } 42 try { 43 return classTransformer.transform(loader, className, classBeingRedefined, protectionDomain, classfileBuffer); 44 } catch (IllegalClassFormatException e) { 45 throw e; 46 } catch (RuntimeException e) { 47 return null; 48 } 49 } 50 } 51 | Popular Tags |