1 package alt.jiapi.interceptor; 2 3 /** 4 * AccessAdvisor provides methods that are called when instrumented 5 * class is accessing some field. 6 * It is possible to change access behaviour by returning a different 7 * value to calling method(Jiapi runtime). <p> 8 * 9 * Minimum viable implementation ensuring correct functionality is 10 * <pre> 11 * public Object set(Object target, String fieldName, Object value) { 12 * return value; 13 * } 14 * public Object get(Object target, String fieldName, Object value) { 15 * return value; 16 * } 17 * </pre> 18 * 19 * @author Mika Riekkinen 20 */ 21 public interface AccessAdvisor { 22 /** 23 * This method is called, when a field is being set. 24 * 25 * @param target target Object or target Class, if the field is 26 * static 27 * @param fieldName name of the field 28 * @param value value to set. If the field holds a primitive type, 29 * value is wrapped to corresponding primitive wrapper, 30 * like <code>java.lang.Integer</code> 31 * 32 * @return a new value to set 33 */ 34 public Object set(Object target, String fieldName, Object value); 35 36 /** 37 * This method is called, when a field has been get. 38 * It must be noted, that this method will not change the 39 * value of the target field. 40 * 41 * @param target target Object or target Class, if the field is 42 * static 43 * @param fieldName name of the field 44 * @param value value of the field. If the field holds a primitive type, 45 * value is wrapped to corresponding primitive wrapper, 46 * like <code>java.lang.Integer</code> 47 * 48 * @return a new value to get 49 */ 50 public Object get(Object target, String fieldName, Object value); 51 } 52