/** * init - generates the Introspector. As the setup code * makes sure that the log gets set before this is called, * we can initialize the Introspector using the log object. */ public void init() { introspector = new Introspector(log, conversionHandler); }
/** * Default constructor. */ public GetExecutor(RuntimeLogger r, Introspector ispect, Class c, String key) throws Exception { rlog = r; args[0] = key; method = ispect.getMethod(c, "get", args); }
/** * @param clazz * @param property * @param arg */ protected void discover(final Class clazz, final String property, final Object arg) { try { Field field = introspector.getField(clazz, property); if(!Modifier.isFinal(field.getModifiers())) { setField(field); } } /** * pass through application level runtime exceptions */ catch( RuntimeException e ) { throw e; } catch(Exception e) { String msg = "Exception while looking for public field '" + property; log.error(msg, e); throw new VelocityException(msg, e); } }
/** * @param clazz * @param property */ protected void discover(final Class clazz, final String property) { try { setField(introspector.getField(clazz, property)); } /** * pass through application level runtime exceptions */ catch( RuntimeException e ) { throw e; } catch(Exception e) { String msg = "Exception while looking for public field '" + property; log.error(msg, e); throw new VelocityException(msg, e); } }
/** * Method */ public VelMethod getMethod(Object obj, String methodName, Object[] args, Info i) throws Exception { if (obj == null) return null; Method m = introspector.getMethod(obj.getClass(), methodName, args); return (m != null) ? new VelMethodImpl(m) : null; }
/** * Sets the runtime logger - this must be called before anything * else besides init() as to get the logger. Makes the pull * model appealing... */ public void setRuntimeLogger(RuntimeLogger runtimeLogger) { rlog = runtimeLogger; introspector = new Introspector(rlog); }
/** * Get the Method object corresponding to the given class, name and parameters. * Will check for appropriate execute permissions and return null if the method * is not allowed to be executed. * * @param clazz Class on which method will be called * @param methodName Name of method to be called * @param params array of parameters to method * @return Method object retrieved by Introspector * @throws IllegalArgumentException The parameter passed in were incorrect. */ public Method getMethod(Class clazz, String methodName, Object[] params) throws IllegalArgumentException { if (!checkObjectExecutePermission(clazz, methodName)) { log.warn("Cannot retrieve method {} from object of class {} due to security restrictions." , methodName, clazz.getName()); return null; } else { return super.getMethod(clazz, methodName, params); } }
/** * init - generates the Introspector. As the setup code * makes sure that the log gets set before this is called, * we can initialize the Introspector using the log object. */ public void init() { introspector = new Introspector(log); }
@Override public VelMethod getMethod(Object obj, String methodName, Object[] args, Info i) throws Exception { VelMethod method = super.getMethod(obj, methodName, args, i); if (method != null) { Method m = this.introspector.getMethod(obj.getClass(), method.getMethodName(), args); if (m != null && (m.isAnnotationPresent(Deprecated.class) || m.getDeclaringClass().isAnnotationPresent(Deprecated.class) || obj.getClass().isAnnotationPresent(Deprecated.class))) { logWarning("method", obj, method.getMethodName(), i); } } return method; }
/** * init - generates the Introspector. As the setup code * makes sure that the log gets set before this is called, * we can initialize the Introspector using the log object. */ public void init() { introspector = new Introspector(log); }
@Override public VelPropertyGet getPropertyGet(Object obj, String identifier, Info i) throws Exception { VelPropertyGet method = super.getPropertyGet(obj, identifier, i); if (method != null) { Method m = this.introspector.getMethod(obj.getClass(), method.getMethodName(), new Object[] {}); if (m != null && (m.isAnnotationPresent(Deprecated.class) || m.getDeclaringClass().isAnnotationPresent(Deprecated.class) || obj.getClass().isAnnotationPresent(Deprecated.class))) { logWarning("getter", obj, method.getMethodName(), i); } } return method; }
/** * init - generates the Introspector. As the setup code * makes sure that the log gets set before this is called, * we can initialize the Introspector using the log object. */ public void init() throws Exception { introspector = new Introspector(log); }
private Method lookupMethod(final String methodName, final AnnotatedValueHelper valueHelper, final Object[] unboxedArgs, final Info info) { final Method targetMethod = introspector.getMethod(valueHelper.getTargetClass(), methodName, unboxedArgs); if (targetMethod != null) { logOrThrowDeprecationWarningsIfNecessary(valueHelper, info, targetMethod); } return targetMethod; }
@Override public void init() { super.init(); this.introspector = new Introspector(this.log); }
method = introspector.getMethod(clazz, methodUsed, params);
@Override public void init() { super.init(); this.introspector = new Introspector(this.log); }
@Override public VelPropertySet getPropertySet(Object obj, String identifier, Object arg, Info i) { // TODO Auto-generated method stub VelPropertySet method = super.getPropertySet(obj, identifier, arg, i); if (method != null) { Method m = this.introspector.getMethod(obj.getClass(), method.getMethodName(), new Object[] { arg }); if (m != null && (m.isAnnotationPresent(Deprecated.class) || m.getDeclaringClass().isAnnotationPresent(Deprecated.class) || obj.getClass().isAnnotationPresent(Deprecated.class))) { logWarning("setter", obj, method.getMethodName(), i); } } return method; }
/***********************************************************************/ public void setRuntimeLogger(RuntimeLogger runtimeLogger) { introspector = new IntrospectorBase(); introspectorWithLog = new Introspector(runtimeLogger); log = runtimeLogger; } public void setBeKindToNulls(boolean behavior)
@Override public VelMethod getMethod(Object obj, String methodName, Object[] args, Info i) { VelMethod method = super.getMethod(obj, methodName, args, i); if (method != null) { Method m = this.introspector.getMethod(obj.getClass(), method.getMethodName(), args); if (m != null && (m.isAnnotationPresent(Deprecated.class) || m.getDeclaringClass().isAnnotationPresent(Deprecated.class) || obj.getClass().isAnnotationPresent(Deprecated.class))) { logWarning("method", obj, method.getMethodName(), i); } } return method; }
/** * {@inheritDoc} * * @see Uberspect#init() */ public void init() { super.init(); this.introspector = new Introspector(log); }