com.github.vindell.websocket.session.handler.AbstractEnabledEventHandler Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of spring-boot-starter-websocket Show documentation
Show all versions of spring-boot-starter-websocket Show documentation
Spring Boot Starter For WebSocket
The newest version!
package com.github.vindell.websocket.session.handler;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.github.vindell.websocket.event.WebSocketMessageEvent;
import com.github.vindell.websocket.session.handler.chain.HandlerChain;
public abstract class AbstractEnabledEventHandler extends AbstractNameableEventHandler {
protected final Logger LOG = LoggerFactory.getLogger(AbstractEnabledEventHandler.class);
protected boolean enabled = true;
protected abstract void doHandlerInternal(T event, HandlerChain handlerChain) throws Exception;
@Override
public void doHandler(T event, HandlerChain handlerChain) throws Exception {
if (!isEnabled(event)) {
LOG.debug("Handler '{}' is not enabled for the current event. Proceeding without invoking this handler.",
getName());
// Proceed without invoking this handler...
handlerChain.doHandler(event);
} else {
LOG.trace("Handler '{}' enabled. Executing now.", getName());
doHandlerInternal(event, handlerChain);
}
}
protected boolean isEnabled(T event) throws Exception {
return isEnabled();
}
public boolean isEnabled() {
return enabled;
}
public void setEnabled(boolean enabled) {
this.enabled = enabled;
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy