Skip to content

Commit

Permalink
Refactor the org.terasoluna.gfw.web.mvc.support package. #132
Browse files Browse the repository at this point in the history
  • Loading branch information
btshimizukza committed Nov 13, 2014
1 parent 209448d commit e85ccc4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
*/
package org.terasoluna.gfw.web.mvc.support;

import java.lang.reflect.Method;
import java.util.Arrays;
import java.util.Collections;
import java.util.LinkedHashMap;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,28 +38,28 @@ class ProcessActionInvocationHelper {
/**
* Flag that indicate whether legacy signature.
*/
private final boolean isOldProcessAction;
private final boolean isLegacySignature;

/**
* Default constructor.
*/
public ProcessActionInvocationHelper() {
ProcessActionInvocationHelper() {
// Check Spring4's signature
Method targetProcessActionMethod = ReflectionUtils.findMethod(RequestDataValueProcessor.class, "processAction",
HttpServletRequest.class, String.class, String.class);
boolean isOld = false;
boolean isLegacySignature = false;

if (targetProcessActionMethod == null) {
// Check Spring3's signature
targetProcessActionMethod = ReflectionUtils.findMethod(RequestDataValueProcessor.class, "processAction",
HttpServletRequest.class, String.class);
isOld = true;
isLegacySignature = true;
}
if (targetProcessActionMethod == null) {
throw new IllegalStateException("'processActionMethod' is not found. Should never get here!");
}
this.processActionMethod = targetProcessActionMethod;
this.isOldProcessAction = isOld;
this.isLegacySignature = isLegacySignature;
}

/**
Expand All @@ -71,8 +71,8 @@ public ProcessActionInvocationHelper() {
* @param method http method of from
* @return action that returned from specified {@link RequestDataValueProcessor}
*/
public String invokeProcessAction(RequestDataValueProcessor requestDataValueProcessor, HttpServletRequest request, String action, String method) {
if (isOldProcessAction) {
String invokeProcessAction(RequestDataValueProcessor requestDataValueProcessor, HttpServletRequest request, String action, String method) {
if (isLegacySignature) {
return (String) ReflectionUtils.invokeMethod(this.processActionMethod, requestDataValueProcessor, request, action);
} else {
return (String) ReflectionUtils.invokeMethod(this.processActionMethod, requestDataValueProcessor, request, action, method);
Expand Down

0 comments on commit e85ccc4

Please sign in to comment.