private <T> T injectSetters(T r, JSONObject j, Collection<String> exclusions) {
        // try to assign rest of the properties
        OUTER:
        for (String key : (Set<String>)j.keySet()) {
            if (!exclusions.contains(key)) {
                try {
                    // try field injection first
                    for (Class c=r.getClass(); c!=null; c=c.getSuperclass()) {
                        try {
                            Field f = c.getDeclaredField(key);
                            if (f.getAnnotation(DataBoundSetter.class)!=null) {
                                f.setAccessible(true);
                                f.set(r, bindJSON(f.getGenericType(), f.getType(), j.get(key)));
                                continue OUTER;
                            }
                        } catch (NoSuchFieldException e) {
                            // recurse into parents
                        }
                    }

                    Method wm = findDataBoundSetter(r.getClass(), key);
                    if (wm==null)   continue;

                    Class<?>[] pt = wm.getParameterTypes();
                    assert pt.length==1;

                    // only invoking public methods for security reasons
                    wm.invoke(r, bindJSON(wm.getGenericParameterTypes()[0], pt[0], j.get(key)));
                } catch (IllegalAccessException e) {
                    LOGGER.log(WARNING, "Cannot access property " + key + " of " + r.getClass(), e);
                } catch (InvocationTargetException e) {
                    LOGGER.log(WARNING, "Cannot access property " + key + " of " + r.getClass(), e);
                }
            }
        }

        invokePostConstruct(getWebApp().getMetaClass(r).getPostConstructMethods(), r);

        return r;
    }
private < T > T injectSetters ( T r , JSONObject j , Collection < String > exclusions ) { OUTER : for ( String key : ( Set < String > ) j . keySet ( ) ) { if ( ! exclusions . contains ( key ) ) { try { for ( Class c = r . getClass ( ) ; c != null ; c = c . getSuperclass ( ) ) { try { Field f = c . getDeclaredField ( key ) ; if ( f . getAnnotation ( DataBoundSetter . class ) != null ) { f . setAccessible ( true ) ; f . set ( r , bindJSON ( f . getGenericType ( ) , f . getType ( ) , j . get ( key ) ) ) ; continue OUTER ; } } catch ( NoSuchFieldException e ) { } } Method wm = findDataBoundSetter ( r . getClass ( ) , key ) ; if ( wm == null ) continue ; Class < ? > [ ] pt = wm . getParameterTypes ( ) ; assert pt . length == 1 ; wm . invoke ( r , bindJSON ( wm . getGenericParameterTypes ( ) [ 0 ] , pt [ 0 ] , j . get ( key ) ) ) ; } catch ( IllegalAccessException e ) { LOGGER . log ( WARNING , "Cannot access property " + key + " of " + r . getClass ( ) , e ) ; } catch ( InvocationTargetException e ) { LOGGER . log ( WARNING , "Cannot access property " + key + " of " + r . getClass ( ) , e ) ; } } } invokePostConstruct ( getWebApp ( ) . getMetaClass ( r ) . getPostConstructMethods ( ) , r ) ; return r ; }
Performs {@link DataBoundSetter} injections.

@param exclusions
Properties that are already injected through the constructor, thus not subject of the setter injection.