private static Method findListenerMethod(Object obj, String methodName) {

        final Class<?> type = obj.getClass();
        final Method[] methods = type.getDeclaredMethods();

        Method foundMethod = null;
        for (Method m : methods) {
            if (!methodName.equals(m.getName())) {
                continue;
            }

            final Class<?>[] paramTypes = m.getParameterTypes();
            if (foundMethod == null ||
                    (paramTypes.length < 4 && paramTypes.length > foundMethod.getParameterTypes().length)) {
                foundMethod = m;
            }
        }
        if (foundMethod == null) {
            throw new IllegalArgumentException("unable to find method with name '" +
                    methodName + "' in class '" + type.toString() + "'");
        }
        return foundMethod;

    }