use of com.tvd12.ezyfox.reflect.EzyClass in project ezyfox-server by youngmonkeys.
the class EzyExceptionHandlerImplementer method doImplement.
protected EzyUncaughtExceptionHandler doImplement() throws Exception {
ClassPool pool = ClassPool.getDefault();
String implClassName = getImplClassName();
CtClass implClass = pool.makeClass(implClassName);
EzyClass superClass = new EzyClass(getSuperClass());
String exceptionHandlerFieldContent = makeExceptionHandlerFieldContent();
String setExceptionHandlerMethodContent = makeSetExceptionHandlerMethodContent();
String handleExceptionMethodContent = makeHandleExceptionMethodContent();
printComponentContent(implClassName);
printComponentContent(exceptionHandlerFieldContent);
printComponentContent(setExceptionHandlerMethodContent);
printComponentContent(handleExceptionMethodContent);
implClass.setSuperclass(pool.get(superClass.getName()));
implClass.addField(CtField.make(exceptionHandlerFieldContent, implClass));
implClass.addMethod(CtNewMethod.make(setExceptionHandlerMethodContent, implClass));
implClass.addMethod(CtNewMethod.make(handleExceptionMethodContent, implClass));
Class answerClass = implClass.toClass();
implClass.detach();
EzyAsmUncaughtExceptionHandler handler = (EzyAsmUncaughtExceptionHandler) answerClass.newInstance();
setRepoComponent(handler);
return handler;
}
use of com.tvd12.ezyfox.reflect.EzyClass in project ezyfox-server by youngmonkeys.
the class EzyRequestHandlerImplementer method doImplement.
@SuppressWarnings("rawtypes")
protected EzyAsmRequestHandler doImplement() throws Exception {
ClassPool pool = ClassPool.getDefault();
String implClassName = getImplClassName();
CtClass implClass = pool.makeClass(implClassName);
EzyClass superClass = new EzyClass(getSuperClass());
String controllerFieldContent = makeControllerFieldContent();
String setControllerMethodContent = makeSetControllerMethodContent();
String handleRequestMethodContent = makeHandleRequestMethodContent();
String handleExceptionMethodContent = makeHandleExceptionMethodContent();
String getRequestDataTypeMethodContent = makeGetRequestDataTypeMethodContent();
printComponentContent(controllerFieldContent);
printComponentContent(setControllerMethodContent);
printComponentContent(handleRequestMethodContent);
printComponentContent(handleExceptionMethodContent);
printComponentContent(getRequestDataTypeMethodContent);
implClass.setSuperclass(pool.get(superClass.getName()));
implClass.addField(CtField.make(controllerFieldContent, implClass));
implClass.addMethod(CtNewMethod.make(setControllerMethodContent, implClass));
implClass.addMethod(CtNewMethod.make(handleRequestMethodContent, implClass));
implClass.addMethod(CtNewMethod.make(handleExceptionMethodContent, implClass));
implClass.addMethod(CtNewMethod.make(getRequestDataTypeMethodContent, implClass));
Class answerClass = implClass.toClass();
implClass.detach();
EzyAsmRequestHandler handler = (EzyAsmRequestHandler) answerClass.newInstance();
handler.setCommand(handlerMethod.getCommand());
handler.setResponseFactory(responseFactory);
setRepoComponent(handler);
return handler;
}
use of com.tvd12.ezyfox.reflect.EzyClass in project ezyhttp by youngmonkeys.
the class ExceptionHandlerImplementer method doImplement.
@SuppressWarnings("rawtypes")
protected UncaughtExceptionHandler doImplement() throws Exception {
ClassPool pool = ClassPool.getDefault();
String implClassName = getImplClassName();
CtClass implClass = pool.makeClass(implClassName);
EzyClass superClass = new EzyClass(getSuperClass());
String exceptionHandlerFieldContent = makeExceptionHandlerFieldContent();
String setExceptionHandlerMethodContent = makeSetExceptionHandlerMethodContent();
String handleExceptionMethodContent = makeHandleExceptionMethodContent();
String getResponseContentTypeMethodContent = makeGetResponseContentTypeMethodContent();
printComponentContent(implClassName);
printComponentContent(exceptionHandlerFieldContent);
printComponentContent(setExceptionHandlerMethodContent);
printComponentContent(handleExceptionMethodContent);
printComponentContent(getResponseContentTypeMethodContent);
implClass.setSuperclass(pool.get(superClass.getName()));
implClass.addField(CtField.make(exceptionHandlerFieldContent, implClass));
implClass.addMethod(CtNewMethod.make(setExceptionHandlerMethodContent, implClass));
implClass.addMethod(CtNewMethod.make(handleExceptionMethodContent, implClass));
implClass.addMethod(CtNewMethod.make(getResponseContentTypeMethodContent, implClass));
Class answerClass = implClass.toClass();
implClass.detach();
AsmUncaughtExceptionHandler handler = (AsmUncaughtExceptionHandler) answerClass.newInstance();
setRepoComponent(handler);
return handler;
}
use of com.tvd12.ezyfox.reflect.EzyClass in project ezyhttp by youngmonkeys.
the class RequestHandlerImplementer method doImplement.
@SuppressWarnings("rawtypes")
protected RequestHandler doImplement() throws Exception {
ClassPool pool = ClassPool.getDefault();
String implClassName = getImplClassName();
CtClass implClass = pool.makeClass(implClassName);
EzyClass superClass = new EzyClass(getSuperClass());
String controllerFieldContent = makeControllerFieldContent();
String setControllerMethodContent = makeSetControllerMethodContent();
String handleRequestMethodContent = makeHandleRequestMethodContent();
String handleExceptionMethodContent = makeHandleExceptionMethodContent();
String getHttpMethodMethodContent = makeGetHttpMethodMethodContent();
String getRequestURIMethodContent = makeGetRequestURIMethodContent();
String getResponseContentTypeMethodContent = makeGetResponseContentTypeMethodContent();
String isAsyncMethodContent = makeIsAsyncMethodContent();
printComponentContent(controllerFieldContent);
printComponentContent(setControllerMethodContent);
printComponentContent(handleRequestMethodContent);
printComponentContent(handleExceptionMethodContent);
printComponentContent(getHttpMethodMethodContent);
printComponentContent(getRequestURIMethodContent);
printComponentContent(getResponseContentTypeMethodContent);
printComponentContent(isAsyncMethodContent);
implClass.setSuperclass(pool.get(superClass.getName()));
implClass.addField(CtField.make(controllerFieldContent, implClass));
implClass.addMethod(CtNewMethod.make(setControllerMethodContent, implClass));
implClass.addMethod(CtNewMethod.make(handleRequestMethodContent, implClass));
implClass.addMethod(CtNewMethod.make(handleExceptionMethodContent, implClass));
implClass.addMethod(CtNewMethod.make(getHttpMethodMethodContent, implClass));
implClass.addMethod(CtNewMethod.make(getRequestURIMethodContent, implClass));
implClass.addMethod(CtNewMethod.make(getResponseContentTypeMethodContent, implClass));
implClass.addMethod(CtNewMethod.make(isAsyncMethodContent, implClass));
Class answerClass = implClass.toClass();
implClass.detach();
RequestHandler handler = (RequestHandler) answerClass.newInstance();
handler.setHandlerMethod(handlerMethod.getMethod().getMethod());
setRepoComponent(handler);
return handler;
}
Aggregations