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

org.zeroturnaround.javarebel.integration.elcommons.BeanInfoManagerClassBytecodeProcessor Maven / Gradle / Ivy

There is a newer version: 2.0.2
Show newest version
package org.zeroturnaround.javarebel.integration.elcommons;

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;

public class BeanInfoManagerClassBytecodeProcessor extends
		JavassistClassBytecodeProcessor {

	public void process(ClassPool cp, ClassLoader cl, CtClass ctClass) throws Exception {
		CtMethod m = null;
		String commonsPackage = "org.apache.commons.el.";
		try {
			m = 
				ctClass.getMethod(
			        "getProperty", 
			        "(Ljava/lang/String;Lorg/apache/commons/el/Logger;)Lorg/apache/commons/el/BeanInfoProperty;");
		}
		catch (NotFoundException e) {
			commonsPackage = "org.apache.taglibs.standard.lang.jstl.";
			m = 
				ctClass.getMethod(
			        "getProperty", 
			        "(Ljava/lang/String;Lorg/apache/taglibs/standard/lang/jstl/Logger;)Lorg/apache/taglibs/standard/lang/jstl/BeanInfoProperty;");
		}
		
		m.setBody("{ checkInitialized($2);" + 
	    		commonsPackage+"BeanInfoProperty beanInfoProperty = ("+commonsPackage+"BeanInfoProperty) mPropertyByName.get($1);" + 
 
	    		"if (beanInfoProperty == null) {" +
	    		"    mInitialized = false;" + 
	    		"    java.beans.Introspector.flushFromCaches(mBeanClass);" + 
	    		"    this.checkInitialized($2);" + 
	    		"} " + 
	    		"return ("+commonsPackage+"BeanInfoProperty) mPropertyByName.get($1); }");
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy