Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#1195] Fixes regression introduced after new Binder impl by making J…
…PA binding not modifying the ParamNode-structure. This commit also caches the main ActionInvoker http-to-method-args bind-operation pr request. This prevent us from performing the (heavy) bind-operation twice pr request when using Validation.
- Loading branch information
Showing
7 changed files
with
103 additions
and
11 deletions.
There are no files selected for viewing
36 changes: 36 additions & 0 deletions
36
framework/src/play/data/binding/CachedBoundActionMethodArgs.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
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<CachedBoundActionMethodArgs> current = new ThreadLocal<CachedBoundActionMethodArgs>(); | ||
|
||
private Map<Method, Object[]> preBoundActionMethodArgs = new HashMap<Method, Object[]>(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); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters