1 16 17 package org.springframework.instrument.classloading; 18 19 import java.lang.instrument.ClassFileTransformer ; 20 21 import org.springframework.util.Assert; 22 import org.springframework.util.ClassUtils; 23 24 36 public class SimpleLoadTimeWeaver implements LoadTimeWeaver { 37 38 private final SimpleInstrumentableClassLoader classLoader; 39 40 41 44 public SimpleLoadTimeWeaver() { 45 this.classLoader = new SimpleInstrumentableClassLoader(ClassUtils.getDefaultClassLoader()); 46 } 47 48 53 public SimpleLoadTimeWeaver(SimpleInstrumentableClassLoader classLoader) { 54 Assert.notNull(classLoader, "ClassLoader must not be null"); 55 this.classLoader = classLoader; 56 } 57 58 59 public void addTransformer(ClassFileTransformer transformer) { 60 this.classLoader.addTransformer(transformer); 61 } 62 63 public ClassLoader getInstrumentableClassLoader() { 64 return this.classLoader; 65 } 66 67 70 public ClassLoader getThrowawayClassLoader() { 71 return new SimpleThrowawayClassLoader(getInstrumentableClassLoader()); 72 } 73 74 } 75 | Popular Tags |