play.data.binding.CachedBoundActionMethodArgs Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of framework Show documentation
Show all versions of framework Show documentation
RePlay is a fork of the Play1 framework, created by Codeborne.
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 final ThreadLocal current = new ThreadLocal<>();
private final 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