This commit is contained in:
@@ -219,29 +219,35 @@ public abstract class HttpBaseServlet extends HttpServlet {
|
|||||||
WebServlet module = this.getClass().getAnnotation(WebServlet.class);
|
WebServlet module = this.getClass().getAnnotation(WebServlet.class);
|
||||||
final int serviceid = module == null ? 0 : module.moduleid();
|
final int serviceid = module == null ? 0 : module.moduleid();
|
||||||
final HashMap<String, Entry> map = new HashMap<>();
|
final HashMap<String, Entry> map = new HashMap<>();
|
||||||
Set<String> nameset = new HashSet<>();
|
HashMap<String, Class> nameset = new HashMap<>();
|
||||||
for (final Method method : this.getClass().getMethods()) {
|
Class clz = this.getClass();
|
||||||
//-----------------------------------------------
|
do {
|
||||||
String methodname = method.getName();
|
if (Modifier.isAbstract(clz.getModifiers())) break;
|
||||||
if ("service".equals(methodname) || "preExecute".equals(methodname) || "execute".equals(methodname) || "authenticate".equals(methodname)) continue;
|
for (final Method method : clz.getMethods()) {
|
||||||
//-----------------------------------------------
|
//-----------------------------------------------
|
||||||
Class[] paramTypes = method.getParameterTypes();
|
String methodname = method.getName();
|
||||||
if (paramTypes.length != 2 || paramTypes[0] != HttpRequest.class
|
if ("service".equals(methodname) || "preExecute".equals(methodname) || "execute".equals(methodname) || "authenticate".equals(methodname)) continue;
|
||||||
|| paramTypes[1] != HttpResponse.class) continue;
|
//-----------------------------------------------
|
||||||
//-----------------------------------------------
|
Class[] paramTypes = method.getParameterTypes();
|
||||||
Class[] exps = method.getExceptionTypes();
|
if (paramTypes.length != 2 || paramTypes[0] != HttpRequest.class
|
||||||
if (exps.length > 0 && (exps.length != 1 || exps[0] != IOException.class)) continue;
|
|| paramTypes[1] != HttpResponse.class) continue;
|
||||||
//-----------------------------------------------
|
//-----------------------------------------------
|
||||||
|
Class[] exps = method.getExceptionTypes();
|
||||||
|
if (exps.length > 0 && (exps.length != 1 || exps[0] != IOException.class)) continue;
|
||||||
|
//-----------------------------------------------
|
||||||
|
|
||||||
final WebAction action = method.getAnnotation(WebAction.class);
|
final WebAction action = method.getAnnotation(WebAction.class);
|
||||||
if (action == null) continue;
|
if (action == null) continue;
|
||||||
final int actionid = action.actionid();
|
final int actionid = action.actionid();
|
||||||
final String name = action.url().trim();
|
final String name = action.url().trim();
|
||||||
|
if (nameset.containsKey(name)) {
|
||||||
if (nameset.contains(name)) throw new RuntimeException(this.getClass().getSimpleName() + " has two same " + WebAction.class.getSimpleName() + "(" + name + ")");
|
if (nameset.get(name) != clz) continue;
|
||||||
nameset.add(name);
|
throw new RuntimeException(this.getClass().getSimpleName() + " has two same " + WebAction.class.getSimpleName() + "(" + name + ")");
|
||||||
map.put(name, new Entry(typeIgnore, serviceid, actionid, name, action.methods(), method, createHttpServlet(method)));
|
}
|
||||||
}
|
nameset.put(name, clz);
|
||||||
|
map.put(name, new Entry(typeIgnore, serviceid, actionid, name, action.methods(), method, createHttpServlet(method)));
|
||||||
|
}
|
||||||
|
} while ((clz = clz.getSuperclass()) != HttpBaseServlet.class);
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user