Right listener implementation

Report a typo

You have the following event in your application:

public class LogEvent extends ApplicationEvent {

    private final String log;

    public LogEvent(Object source, String log) {
        super(source);
        this.log = log;
    }

    public String getLog() {
        return log;
    }
}

Choose all possible implementations of listeners for this event.

A)

@Component
public class LogListener implements ApplicationListener<LogEvent> {

    @Override
    public void onApplicationEvent(LogEvent event) {
        System.out.println(event.getLog());
    }
}

B)

@ApplicationListener
public class LogListener {

    @Override
    public void onApplicationEvent(LogEvent event) {
        System.out.println(event.getLog());
    }
}

C)

@Component
public class LogListener implements ApplicationListener<LogEvent> {
}

D)

@Component
public class LoggingService {
    @EventListener
    public void handleEvent(LogEvent event) {
        System.out.println(event.getLog());
    }
}
Select one or more options from the list
___

Create a free account to access the full topic