Search in sources :

Example 1 with EzyRequestHandlerMethod

use of com.tvd12.ezyfoxserver.support.reflect.EzyRequestHandlerMethod in project ezyfox-server by youngmonkeys.

the class EzyRequestHandlersImplementer method implement.

private Map<String, EzyUserRequestHandler> implement(Object controller) {
    Map<String, EzyUserRequestHandler> handlers = new HashMap<>();
    EzyRequestControllerProxy proxy = new EzyRequestControllerProxy(controller);
    String feature = proxy.getFeature();
    for (EzyRequestHandlerMethod method : proxy.getRequestHandlerMethods()) {
        EzyRequestHandlerImplementer implementer = newImplementer(proxy, method);
        EzyAsmRequestHandler handler = implementer.implement();
        String command = handler.getCommand();
        handlers.put(command, handler);
        requestCommandManager.addCommand(command);
        if (proxy.isManagement() || method.isManagement()) {
            requestCommandManager.addManagementCommand(command);
        }
        if (proxy.isPayment() || method.isPayment()) {
            requestCommandManager.addPaymentCommand(command);
        }
        String methodFeature = feature != null ? feature : method.getFeature();
        if (EzyStrings.isNotBlank(methodFeature)) {
            featureCommandManager.addFeatureCommand(methodFeature, command);
        }
    }
    return handlers;
}
Also used : HashMap(java.util.HashMap) EzyRequestControllerProxy(com.tvd12.ezyfoxserver.support.reflect.EzyRequestControllerProxy) EzyUserRequestHandler(com.tvd12.ezyfoxserver.support.handler.EzyUserRequestHandler) EzyRequestHandlerMethod(com.tvd12.ezyfoxserver.support.reflect.EzyRequestHandlerMethod)

Example 2 with EzyRequestHandlerMethod

use of com.tvd12.ezyfoxserver.support.reflect.EzyRequestHandlerMethod in project ezyfox-server by youngmonkeys.

the class EzyRequestControllerProxy method fetchRequestHandlerMethods.

protected List<EzyRequestHandlerMethod> fetchRequestHandlerMethods() {
    List<EzyRequestHandlerMethod> list = new ArrayList<>();
    List<EzyMethod> methods = clazz.getPublicMethods(this::isRequestHandlerMethod);
    for (EzyMethod method : methods) {
        EzyRequestHandlerMethod m = new EzyRequestHandlerMethod(commandGroup, method);
        list.add(m);
    }
    return list;
}
Also used : ArrayList(java.util.ArrayList) EzyMethod(com.tvd12.ezyfox.reflect.EzyMethod)

Example 3 with EzyRequestHandlerMethod

use of com.tvd12.ezyfoxserver.support.reflect.EzyRequestHandlerMethod 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;
}
Also used : AppClientHelloRequestController(com.tvd12.ezyfoxserver.support.test.controller.app.AppClientHelloRequestController) EzyMethod(com.tvd12.ezyfox.reflect.EzyMethod) EzyContext(com.tvd12.ezyfoxserver.context.EzyContext) EzyRequestHandlerMethod(com.tvd12.ezyfoxserver.support.reflect.EzyRequestHandlerMethod) Test(org.testng.annotations.Test)

Aggregations

EzyMethod (com.tvd12.ezyfox.reflect.EzyMethod)2 EzyRequestHandlerMethod (com.tvd12.ezyfoxserver.support.reflect.EzyRequestHandlerMethod)2 EzyContext (com.tvd12.ezyfoxserver.context.EzyContext)1 EzyUserRequestHandler (com.tvd12.ezyfoxserver.support.handler.EzyUserRequestHandler)1 EzyRequestControllerProxy (com.tvd12.ezyfoxserver.support.reflect.EzyRequestControllerProxy)1 AppClientHelloRequestController (com.tvd12.ezyfoxserver.support.test.controller.app.AppClientHelloRequestController)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Test (org.testng.annotations.Test)1