public void addContexts(Object o) throws IllegalArgumentException {
            for (Class<?> c = o.getClass(); c != null; c = c.getSuperclass()) {   
                // add to contexts those with @Context annotation
                for (Method m : c.getDeclaredMethods()) {
                    Context context = m.getAnnotation(Context.class);
                    if (context != null) {
                        m.setAccessible(true); // allow access to private member
                        Class<?>[] params = m.getParameterTypes();
                        if (params.length != 2
                            || !Request.class.isAssignableFrom(params[0])
                            || !Response.class.isAssignableFrom(params[1])
                            || !int.class.isAssignableFrom(m.getReturnType()))
                                throw new IllegalArgumentException(
                                    "@Context used with invalid method: " + m);
                        String path = context.value();
                        addContext(path, new MethodContextHandler(m, o));
                    }
                }
            }
        }