com.nitorcreations.willow.servers.StatisticsServlet Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of willow-servers Show documentation
Show all versions of willow-servers Show documentation
Willow operational servlets and servers
The newest version!
package com.nitorcreations.willow.servers;
import java.util.concurrent.TimeUnit;
import javax.inject.Inject;
import javax.inject.Singleton;
import org.eclipse.jetty.websocket.servlet.ServletUpgradeRequest;
import org.eclipse.jetty.websocket.servlet.ServletUpgradeResponse;
import org.eclipse.jetty.websocket.servlet.WebSocketCreator;
import org.eclipse.jetty.websocket.servlet.WebSocketServlet;
import org.eclipse.jetty.websocket.servlet.WebSocketServletFactory;
import com.google.inject.Injector;
@Singleton
public class StatisticsServlet extends WebSocketServlet {
private static final long serialVersionUID = 4980353154914279832L;
@Inject
private transient Injector injector;
@Override
public void configure(WebSocketServletFactory factory) {
factory.getPolicy().setIdleTimeout(TimeUnit.MINUTES.toMillis(10));
factory.getPolicy().setMaxBinaryMessageBufferSize(1024 * 1024);
factory.getPolicy().setMaxBinaryMessageSize(1024 * 1024 * 5);
factory.setCreator(new WebSocketCreator() {
@Override
public Object createWebSocket(ServletUpgradeRequest req, ServletUpgradeResponse resp) {
return injector.getInstance(SaveEventsSocket.class);
}
});
}
}