org.zeroturnaround.javarebel.integration.weblogic.DebugLoggerCBP Maven / Gradle / Ivy
The newest version!
package org.zeroturnaround.javarebel.integration.weblogic;
import org.zeroturnaround.bundled.javassist.ClassPool;
import org.zeroturnaround.bundled.javassist.CtClass;
import org.zeroturnaround.bundled.javassist.CtMethod;
import org.zeroturnaround.bundled.javassist.NotFoundException;
import org.zeroturnaround.javarebel.integration.support.JavassistClassBytecodeProcessor;
/**
* Transforms weblogic.diagnostics.debug.DebugLogger
.
*
* @author Jevgeni Kabanov
*/
public class DebugLoggerCBP extends JavassistClassBytecodeProcessor {
public void process(ClassPool cp, ClassLoader cl, CtClass ctClass) throws Exception {
cp.importPackage("org.zeroturnaround.javarebel");
try {
CtMethod logMethod = ctClass.getDeclaredMethod("log");
if (logMethod.getParameterTypes().length < 3) return;
if (!logMethod.getParameterTypes()[1].getName().equals(String.class.getName())) return;
if (!logMethod.getParameterTypes()[2].getName().equals(Throwable.class.getName())) return;
logMethod.insertBefore(
"{" +
" LoggerFactory.getInstance().trace(\" \" + $2);" +
" if ($3 != null) LoggerFactory.getInstance().errorTrace($3);" +
"}");
} catch (NotFoundException e) {
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy