@Override
    public void configure(JettyWebSocketServletFactory factory)
    {
        if (!WebSocketClientConnectionHandler.isCompressionEnabled()) {
            factory.getAvailableExtensionNames().remove("permessage-deflate");
        }
        final int messageSize = JiveGlobals.getIntProperty("xmpp.parser.buffer.size", 1048576);
        factory.setMaxTextMessageSize(messageSize);

        // Jetty's idle policy cannot be modified - it will bluntly kill the connection. Ensure that it's longer than
        // the maximum amount of idle-time that Openfire allows for its client connections!
        final Duration propValue = ConnectionSettings.Client.IDLE_TIMEOUT_PROPERTY.getValue();
        final long maxJettyIdleMs;
        if (propValue.isNegative() || propValue.isZero()) {
            maxJettyIdleMs = Long.MAX_VALUE;
        } else {
            maxJettyIdleMs = propValue.plus(Duration.of(30, ChronoUnit.SECONDS)).toMillis();
        }
        factory.setIdleTimeout(Duration.ofMillis(maxJettyIdleMs));

        factory.setCreator((req, resp) -> {
            try {
                for (String subprotocol : req.getSubProtocols())
                {
                    if ("xmpp".equals(subprotocol))
                    {
                        resp.setAcceptedSubProtocol(subprotocol);
                        return new WebSocketClientConnectionHandler();
                    }
                }
            } catch (Exception e) {
                Log.warn("Unable to load websocket factory", e);
            }
            Log.warn("Failed to create websocket for {}:{} make a request at {}", req.getHttpServletRequest().getRemoteAddr(), req.getHttpServletRequest().getRemotePort(), req.getRequestPath() );
            return null;
        });
    }
This Servlet enables XMPP over WebSocket (RFC 7395) for Openfire.

The Jetty WebSocketServlet serves as a base class and enables easy integration into the
BOSH (http-bind) web context. Each WebSocket request received at the "/ws/" URI will be
forwarded to this plugin/servlet, which will in turn create a new {@link WebSocketClientConnectionHandler}
for each new connection.
xmppserver/src/main/java/org/jivesoftware/openfire/websocket/OpenfireWebSocketServlet.java