org.zeroturnaround.javarebel.integration.spring.cbp.AnnotationMethodHandlerAdapterCBP Maven / Gradle / Ivy
package org.zeroturnaround.javarebel.integration.spring.cbp;
import org.zeroturnaround.bundled.javassist.ClassPool;
import org.zeroturnaround.bundled.javassist.CtClass;
import org.zeroturnaround.bundled.javassist.CtConstructor;
import org.zeroturnaround.bundled.javassist.CtMethod;
import org.zeroturnaround.bundled.javassist.CtNewMethod;
import org.zeroturnaround.javarebel.ClassEventListener;
import org.zeroturnaround.javarebel.integration.support.JavassistClassBytecodeProcessor;
public class AnnotationMethodHandlerAdapterCBP extends JavassistClassBytecodeProcessor {
public void process(ClassPool cp, ClassLoader cl, CtClass ctClass) throws Exception {
cp.importPackage("org.zeroturnaround.javarebel");
// Empties cache
ctClass.addInterface(cp.get(ClassEventListener.class.getName()));
CtConstructor init = ctClass.getDeclaredConstructor(new CtClass[] {});
init.insertAfter(
"ReloaderFactory.getInstance().addClassReloadListener($0);");
CtMethod priorityMethod = CtNewMethod.make("public int priority() {\n" +
" return PRIORITY_CORE + 9800;\n" +
" }", ctClass);
ctClass.addMethod(priorityMethod);
CtMethod onClassEventMethod = CtNewMethod.make(
" public void onClassEvent(int eventType, Class beanClass) {\n" +
" methodResolverCache.remove(beanClass);" +
" }",
ctClass);
ctClass.addMethod(onClassEventMethod);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy