Search in sources :

Example 1 with EzyEventHandler

use of com.tvd12.ezyfox.core.annotation.EzyEventHandler in project ezyfox-server by youngmonkeys.

the class EzySimpleAppEntry method addEventControllers.

private void addEventControllers(EzyAppContext appContext, EzyBeanContext beanContext) {
    EzySetup setup = appContext.get(EzySetup.class);
    List<Object> eventControllers = beanContext.getSingletons(EzyEventHandler.class);
    sortEventHandlersByPriority(eventControllers);
    for (Object controller : eventControllers) {
        Class<?> controllerType = controller.getClass();
        EzyEventHandler annotation = controllerType.getAnnotation(EzyEventHandler.class);
        String eventName = EzyEventHandlerAnnotations.getEvent(annotation);
        setup.addEventController(EzyEventType.valueOf(eventName), (EzyEventController) controller);
        logger.info("add  event {} controller {}", eventName, controller);
    }
}
Also used : EzyEventHandler(com.tvd12.ezyfox.core.annotation.EzyEventHandler) EzySetup(com.tvd12.ezyfoxserver.command.EzySetup)

Example 2 with EzyEventHandler

use of com.tvd12.ezyfox.core.annotation.EzyEventHandler in project ezyfox-server by youngmonkeys.

the class EzySimplePluginEntry method addEventControllers.

private void addEventControllers(EzyPluginContext context, EzyBeanContext beanContext) {
    EzySetup setup = context.get(EzySetup.class);
    List<Object> eventControllers = beanContext.getSingletons(EzyEventHandler.class);
    sortEventHandlersByPriority(eventControllers);
    for (Object controller : eventControllers) {
        Class<?> handlerType = controller.getClass();
        EzyEventHandler annotation = handlerType.getAnnotation(EzyEventHandler.class);
        String eventName = EzyEventHandlerAnnotations.getEvent(annotation);
        setup.addEventController(EzyEventType.valueOf(eventName), (EzyEventController) controller);
        logger.info("add  event {} controller {}", eventName, controller);
    }
}
Also used : EzyEventHandler(com.tvd12.ezyfox.core.annotation.EzyEventHandler) EzySetup(com.tvd12.ezyfoxserver.command.EzySetup)

Example 3 with EzyEventHandler

use of com.tvd12.ezyfox.core.annotation.EzyEventHandler in project ezyfox-server-android-client by youngmonkeys.

the class EzyEventHandlers method handle.

public void handle(EzyEvent event) {
    EzyEventType eventType = event.getType();
    EzyEventHandler handler = handlers.get(eventType);
    if (handler != null)
        handler.handle(event);
    else
        EzyLogger.warn("has no handler for event type: " + eventType);
}
Also used : EzyEventType(com.tvd12.ezyfoxserver.client.event.EzyEventType)

Aggregations

EzyEventHandler (com.tvd12.ezyfox.core.annotation.EzyEventHandler)2 EzySetup (com.tvd12.ezyfoxserver.command.EzySetup)2 EzyEventType (com.tvd12.ezyfoxserver.client.event.EzyEventType)1