/** * Attempt to find a {@link Method} on the supplied class with the supplied name and no parameters. * * Searches all superclasses up to <code>Object</code>. * * <p> * Returns <code>null</code> if no {@link Method} can be found. * * @param clazz the class to introspect * @param name the name of the method * @return the Method object, or <code>null</code> if none found */ public static Method findMethod(Class<?> clazz, String name) { return findMethod(clazz, name, Arrays2.EMPTY_CLASS_ARRAY); }
@Override public List<DbCommand> getSchemaChangeCommands(SchemaChange change, SchemaChangeContext context) { List<DbCommand> commands = new ArrayList<>(); Method method = schemaChangeMethods.get(change.getClass()); if (null == method) { method = Reflection.findMethod(this.getClass(), "createSchemaChangeCommands", SchemaChangeContext.class, change.getClass(), List.class); if (null == method) { throw new UnsupportedChangeException("Unsupported change '" + change.getClass().getSimpleName() + "'", change); } schemaChangeMethods.put(change.getClass(), method); } Reflection.invokeMethod(method, this, context, change, commands); return commands; }
initMethod = Reflection.findMethod(clazz, initMethodName);
bean.setInitMethod(Reflection.findMethod(bean.getBeanClass(), initMethodName)); if (null == bean.getInitMethod()) { throw new BeanDefinitionException("init method '" + initMethodName + "' not found in class '" + beanClassName + "', source : " + reader.getSource()); bean.setDestroyMethod(Reflection.findMethod(bean.getBeanClass(), destroyMethodName)); if (null == bean.getDestroyMethod()) { throw new BeanDefinitionException("destroy method '" + initMethodName + "' not found in class '" + beanClassName + "', source : " + reader.getSource());