use of com.navercorp.pinpoint.profiler.instrument.aspect.AspectWeaverClass in project pinpoint by naver.
the class AspectWeaverClassTest method createAspect.
public Object createAspect(String originalName, String aspectName) {
try {
ClassPool classPool = new ClassPool(true);
Loader loader = getLoader(classPool);
CtClass ctOriginal = classPool.get(originalName);
CtClass ctAdvice = classPool.get(aspectName);
AspectWeaverClass weaver = new AspectWeaverClass();
weaver.weaving(ctOriginal, ctAdvice);
Class aClass = loader.loadClass(originalName);
return aClass.newInstance();
} catch (Exception e) {
throw new RuntimeException(e.getMessage(), e);
}
}
use of com.navercorp.pinpoint.profiler.instrument.aspect.AspectWeaverClass in project pinpoint by naver.
the class JavassistClass method weave.
@Override
public void weave(String adviceClassName) throws InstrumentException {
pluginContext.injectClass(classLoader, adviceClassName);
CtClass adviceClass;
try {
adviceClass = getCtClass(adviceClassName);
} catch (NotFoundException e) {
throw new NotFoundInstrumentException(adviceClassName + " not found. Caused:" + e.getMessage(), e);
}
try {
AspectWeaverClass weaverClass = new AspectWeaverClass();
weaverClass.weaving(ctClass, adviceClass);
} catch (CannotCompileException e) {
throw new InstrumentException("weaving fail. sourceClassName:" + ctClass.getName() + " adviceClassName:" + adviceClassName + " Caused:" + e.getMessage(), e);
} catch (NotFoundException e) {
throw new InstrumentException("weaving fail. sourceClassName:" + ctClass.getName() + " adviceClassName:" + adviceClassName + " Caused:" + e.getMessage(), e);
}
}
Aggregations