/** * 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); }
/** * 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; }
/** * 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); } }
@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; }
@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; }
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 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; }
@Override public VelPropertySet getPropertySet(Object obj, String identifier, Object arg, Info i) throws Exception { // 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; }
@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; }
@Override public VelPropertyGet getPropertyGet(Object obj, String identifier, Info i) { 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; }
/** * 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 " + methodName + " from object of class " + clazz.getName() + " due to security restrictions."); return null; } else { return super.getMethod(clazz, methodName, params); } }
/** * 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 " + methodName + " from object of class " + clazz.getName() + " due to security restrictions."); return null; } else { return super.getMethod(clazz, methodName, params); } }
/** * {@inheritDoc} * * @see Uberspect#getMethod(java.lang.Object, java.lang.String, java.lang.Object[], * org.apache.velocity.util.introspection.Info) */ @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 = introspector.getMethod(obj.getClass(), method.getMethodName(), args); if (m != null && m.isAnnotationPresent(Deprecated.class)) { logWarning("method", obj, method.getMethodName(), i); } } return method; }
/** * {@inheritDoc} * * @see Uberspect#getPropertySet(java.lang.Object, java.lang.String, java.lang.Object, * org.apache.velocity.util.introspection.Info) */ @Override public VelPropertySet getPropertySet(Object obj, String identifier, Object arg, Info i) throws Exception { // TODO Auto-generated method stub VelPropertySet method = super.getPropertySet(obj, identifier, arg, i); if (method != null) { Method m = introspector.getMethod(obj.getClass(), method.getMethodName(), new Object[] {arg}); if (m != null && m.isAnnotationPresent(Deprecated.class)) { logWarning("setter", obj, method.getMethodName(), i); } } return method; }
/** * {@inheritDoc} * * @see Uberspect#getPropertyGet(java.lang.Object, java.lang.String, * org.apache.velocity.util.introspection.Info) */ @Override public VelPropertyGet getPropertyGet(Object obj, String identifier, Info i) throws Exception { VelPropertyGet method = super.getPropertyGet(obj, identifier, i); if (method != null) { Method m = introspector.getMethod(obj.getClass(), method.getMethodName(), new Object[] {}); if (m != null && m.isAnnotationPresent(Deprecated.class)) { logWarning("getter", obj, method.getMethodName(), i); } } return method; }
/** * @since 1.5 */ protected void discover(final Class clazz) { try { setMethod(introspector.getMethod(clazz, "get", params)); } /** * pass through application level runtime exceptions */ catch( RuntimeException e ) { throw e; } catch(Exception e) { String msg = "Exception while looking for get('" + params[0] + "') method"; log.error(msg, e); throw new VelocityException(msg, e); } }
setMethod(introspector.getMethod(clazz, "get", params));
/** * @since 1.5 */ protected void discover(final Class clazz) { try { setMethod(introspector.getMethod(clazz, "get", params)); } /** * pass through application level runtime exceptions */ catch( RuntimeException e ) { throw e; } catch(Exception e) { String msg = "Exception while looking for get('" + params[0] + "') method"; log.error(msg, e); throw new VelocityException(msg, e); } }
setMethod(introspector.getMethod(clazz, "put", params));