more stuff
This commit is contained in:
parent
b4dc4bc910
commit
839d0f030f
1 changed files with 26 additions and 30 deletions
|
@ -21,37 +21,33 @@ public class EventListener {
|
||||||
Method method = methods[i];
|
Method method = methods[i];
|
||||||
if(method.getDeclaredAnnotations().length == 0)
|
if(method.getDeclaredAnnotations().length == 0)
|
||||||
continue;
|
continue;
|
||||||
if(
|
if(method.getReturnType() == void.class) {
|
||||||
method.getParameterCount() != 3 ||
|
boolean usable = true;
|
||||||
method.getParameterTypes()[0] != Request.class ||
|
if(method.getDeclaredAnnotation(GET.class) != null && !request.method.equals("GET")) {
|
||||||
method.getParameterTypes()[1] != Callback.class ||
|
usable = false;
|
||||||
method.getParameterTypes()[2] != Callback.class ||
|
}
|
||||||
method.getReturnType() != void.class
|
if(method.getDeclaredAnnotation(POST.class) != null && !request.method.equals("POST")) {
|
||||||
) {
|
usable = false;
|
||||||
continue;
|
}
|
||||||
}
|
Path pathA = method.getDeclaredAnnotation(Path.class);
|
||||||
boolean usable = true;
|
if(pathA != null && !request.realPath.matches("^" + pathA.value() + "$")) {
|
||||||
if(method.getDeclaredAnnotation(GET.class) != null && !request.method.equals("GET")) {
|
usable = false;
|
||||||
usable = false;
|
}
|
||||||
}
|
RequestMethod methodA = method.getDeclaredAnnotation(RequestMethod.class);
|
||||||
if(method.getDeclaredAnnotation(POST.class) != null && !request.method.equals("POST")) {
|
if(methodA != null && !request.method.matches("^" + methodA.value() + "$")) {
|
||||||
usable = false;
|
usable = false;
|
||||||
}
|
}
|
||||||
Path pathA = method.getDeclaredAnnotation(Path.class);
|
|
||||||
if(pathA != null && !request.realPath.matches("^" + pathA.value() + "$")) {
|
|
||||||
usable = false;
|
|
||||||
}
|
|
||||||
RequestMethod methodA = method.getDeclaredAnnotation(RequestMethod.class);
|
|
||||||
if(methodA != null && !request.method.matches("^" + methodA.value() + "$")) {
|
|
||||||
usable = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(usable) {
|
if(usable) {
|
||||||
try {
|
try {
|
||||||
method.invoke(catcher, request, res, rej);
|
method.invoke(catcher, request, res, rej);
|
||||||
} catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
|
} catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(method.getReturnType() == Response.class) {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue