use of com.tvd12.ezyfox.reflect.EzyMethod in project ezyfox-server by youngmonkeys.
the class EzyRequestHandlerImplementer method makeHandleRequestMethodContent.
protected String makeHandleRequestMethodContent() {
EzyMethod method = getHandleRequestMethod();
EzyFunction function = new EzyFunction(method).throwsException();
EzyBody body = function.body();
int paramCount = prepareHandleMethodArguments(body);
EzyInstruction instruction = new EzyInstruction("\t", "\n");
StringBuilder answerExpression = new StringBuilder();
if (handlerMethod.getReturnType() != void.class) {
answerExpression.append(Object.class.getName()).append(" data = ");
}
answerExpression.append("this.controller.").append(handlerMethod.getName()).append("(");
for (int i = 0; i < paramCount; ++i) {
answerExpression.append(PARAMETER_PREFIX).append(i);
if (i < paramCount - 1) {
answerExpression.append(", ");
}
}
answerExpression.append(")");
instruction.append(answerExpression);
body.append(instruction);
if (handlerMethod.getReturnType() != void.class) {
EzyInstruction responseInstruction = new EzyInstruction("\t", "\n").invoke("this", "responseToSession", "arg1", "data");
body.append(responseInstruction);
}
return function.toString();
}
use of com.tvd12.ezyfox.reflect.EzyMethod in project ezyfox-server by youngmonkeys.
the class EzyExceptionHandlerImplementerTest method testFailedCase.
@Test(expectedExceptions = IllegalStateException.class)
public void testFailedCase() throws Exception {
EzyExceptionHandlerProxy handlerProxy = new EzyExceptionHandlerProxy(new ExceptionHandlerFail());
EzyExceptionHandlerMethod method = new EzyExceptionHandlerMethod(new EzyMethod(ExceptionHandlerFail.class.getDeclaredMethod("handle", Exception.class, int.class)));
new EzyExceptionHandlerImplementer(handlerProxy, method) {
@SuppressWarnings("rawtypes")
@Override
protected EzyUncaughtExceptionHandler doImplement() {
throw new IllegalStateException("test");
}
}.implement();
}
use of com.tvd12.ezyfox.reflect.EzyMethod in project ezyfox-server by youngmonkeys.
the class EzyRequestHandlerMethodTest method test.
@Test
public void test() throws Exception {
EzyMethod method = new EzyMethod(AppClientHelloRequestController.class.getDeclaredMethod("handleHello5", EzyContext.class));
EzyRequestHandlerMethod handlerMethod = new EzyRequestHandlerMethod("c_hello5", method);
assert handlerMethod.getMethod() == method;
System.out.println(handlerMethod);
// noinspection ConstantConditions
assert handlerMethod.getParameterTypes().length >= 0;
}
Aggregations