org.zeroturnaround.javarebel.integration.weblogic.BaseLoggerCBP Maven / Gradle / Ivy
The newest version!
package org.zeroturnaround.javarebel.integration.weblogic;
import java.util.logging.LogRecord;
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 com.bea.logging.BaseLogger
.
*
* @author Jevgeni Kabanov
*/
public class BaseLoggerCBP 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 < 1) return;
if (!logMethod.getParameterTypes()[0].getName().equals(LogRecord.class.getName())) return;
logMethod.insertBefore(
"LoggerFactory.getInstance().log(\" \" + $1);");
} catch (NotFoundException e) {
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy