beetl 2 方法读取优化

import com.beetl.performance.lab.User; 


public class UserAsmAccessor implements Access { 
public Object get(Object o,int index) throws ASMCastException{ 
User user = null; 
try{ 
user = (User)o; 
}catch(Exception ex){ 
throw new ASMCastException(); 
} 

switch(index){ 
case 1:return user.getName(); 
case 2:return user.getId(); 
} 
throw new RuntimeException(); 
} 
} 


在模板里${user.name} ,将user对应到UserAsmAccessor ,name对应到index=1,这样获取对象属性,将达到极限性能



你可能感兴趣的:(beetl 2 方法读取优化)