All Downloads are FREE. Search and download functionalities are using the official Maven repository.

play.data.binding.CachedBoundActionMethodArgs Maven / Gradle / Ivy

There is a newer version: 1.5.0
Show newest version
package play.data.binding;

import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Map;

// ActionInvoker.getActionMethodArgs() is called twice when using validation
// so we use this threadlocal cache to store the binding-result pr method pr request.
// This way we don't have to do it twice.
public class CachedBoundActionMethodArgs {

    private static ThreadLocal current = new ThreadLocal();

    private Map preBoundActionMethodArgs = new HashMap(1);

    public static void init() {
        current.set( new CachedBoundActionMethodArgs());
    }

    public static void clear() {
        current.remove();
    }

    public static CachedBoundActionMethodArgs current() {
        return current.get();
    }

    public void storeActionMethodArgs( Method method, Object[] rArgs) {
        preBoundActionMethodArgs.put(method, rArgs);
    }

    public Object[] retrieveActionMethodArgs( Method method) {
        return preBoundActionMethodArgs.get(method);
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy