All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.zeroturnaround.javarebel.integration.resin.LineConfigExceptionCBP Maven / Gradle / Ivy

The newest version!
package org.zeroturnaround.javarebel.integration.resin;

import org.zeroturnaround.bundled.javassist.ClassPool;
import org.zeroturnaround.bundled.javassist.CtClass;
import org.zeroturnaround.bundled.javassist.CtConstructor;
import org.zeroturnaround.javarebel.integration.support.JavassistClassBytecodeProcessor;

/**
 * Processes com.caucho.config.LineConfigException
 * to log the whole stacktrace.
 * 
 * @author Rein Raudjärv
 */
public class LineConfigExceptionCBP extends JavassistClassBytecodeProcessor {
  
  public void process(ClassPool cp, ClassLoader cl, CtClass ctClass) throws Exception {
    cp.importPackage("org.zeroturnaround.javarebel");
    
    CtConstructor[] constructors = ctClass.getDeclaredConstructors();
    for (int i = 0; i < constructors.length; i++) {
      CtConstructor c = constructors[i];
      c.insertAfter(
          "{" +
          "  Logger log = LoggerFactory.getInstance();" +
          "  log.log(\"LineConfigException\");" +
      	  "  log.error(this);" +
      	  "  Throwable t = getCause();" +
      	  "  if (t != null)" +
      	  "    log.error(t);" +
      	  "}");
    }
  }
  
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy