spark.embeddedserver.jetty.websocket.WebSocketHandlerWrapper Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of spark-core Show documentation
Show all versions of spark-core Show documentation
A micro framework for creating web applications in Kotlin and Java 8 with minimal effort
The newest version!
package spark.embeddedserver.jetty.websocket;
import org.eclipse.jetty.websocket.api.WebSocketListener;
import org.eclipse.jetty.websocket.api.annotations.WebSocket;
/**
* A wrapper for web socket handler classes/instances.
*/
public interface WebSocketHandlerWrapper {
/**
* Gets the actual handler - if necessary, instantiating an object.
*
* @return The handler instance.
*/
Object getHandler();
static void validateHandlerClass(Class> handlerClass) {
boolean valid = WebSocketListener.class.isAssignableFrom(handlerClass)
|| handlerClass.isAnnotationPresent(WebSocket.class);
if (!valid) {
throw new IllegalArgumentException(
"WebSocket handler must implement 'WebSocketListener' or be annotated as '@WebSocket'");
}
}
}