Supported Annotations

EzyFox Server provides a list of annotations:
# Annotation Scopes Description
1EzyDoHandleMethodMaps a request command to a controller's method
2EzyEventHandlerClassMaps an event to a controller
3EzyExceptionHandlerClassIndicates the annotated class will handle exceptions
4EzyRequestControllerMethodIndicates the annotated class is controller
5EzyRequestDataParameterMaps a request data to a java parameter
6EzyRequestInterceptorClassIndicate the annotated class will intercept requests
7EzyRequestListenerClassMap a request command to a handler class
8EzyTryCatchMethodIndicates the annotated method will handle the exception in TryCatch

1. EzyDoHandle

When you annotate a method in a controller with this annotation then when a request with the command come, EzyFox Server will call this method. In the below example, secureChat method will handle secureChat command:
public class ChatRequestController extends EzyLoggable {

    public void secureChat(EzyUser user, ChatRequest request) {
            .param("secure-message", greeting.greet(request.getWho()))

2. EzyEventHandler

If you want to handle an event, you need use this annotation, example for SERVER_READY event:
@EzyEventHandler(SERVER_READY) // refer EzyEventType
public class ServerReadyController
    extends EzyAbstractAppEventController<EzyServerReadyEvent> {

    public void handle(EzyAppContext ctx, EzyServerReadyEvent event) {"hello-world app: fire custom app ready, node name: {}", appConfig.getNodeName());

3. EzyExceptionHandler

You can use this annotation for a class that handles exceptions. Example for GlobalExceptionHandler:
public class GlobalExceptionHandler extends EzyLoggable {

    private final EzyResponseFactory responseFactory;

    public void handle(InvalidChatRequestException e) {}

4. EzyRequestController

You can only use this annotation for controller class, example ChatRequestController:
public class ChatRequestController extends EzyLoggable {

    public void secureChat(EzyUser user, ChatRequest request) {}

5. EzyRequestData

In fact, EzyFox Server will detect and map request data automatically, but if you want to be clearer you can use EyRequestData like this:
public void handleHelloRequest(
    EzyContext context,
    String cmd,
    @EzyRequestData Hello data
) {
    // handle the hello request

6. EzyRequestInteceptor

You can use this annotation for a class that intercepts client requests, example:
public class AppRequestInterceptor
    extends EzyLoggable
    implements EzyUserRequestInterceptor<EzyAppContext> {

    public void preHandle(
        EzyAppContext context,
        EzyUserSessionEvent event,
        String command,
        Object data
    ) {"user: {} request command: {}", event.getUser(), command);

7. EzyRequestListener

Sometimes, maybe the request handler is too long and you don't want to use a controller, so you can use a class to handle a command, you can use EzyRequestListener, example GreetRequestHandler:
@EzyObjectBinding(write = false)
public class GreetRequestHandler
    extends ClientRequestHandler
    implements EzyDataBinding {

    private String who;

    private Greeting greeting;

    protected void execute() throws EzyBadRequestException {
            .param("message", greeting.greet(who))
You can look at Handle EzyFox Server Client Request for many way to handle a request with EzyFox Server

8. EzyTryCatch

You can use this annotation for a method that handles exceptions, example GlobalExceptionHandler.handle
public void handle(
    InvalidChatRequestException e,
    EzyUserSessionEvent event,
    String command,
    Object request
) {"invalid chat request, command: {}, data: {}", command, request, e);
        .data(EzyEntityObjects.newObject("request", "invalid"))

Next Step

You can take a look how to handle a socket event.