Class JettyWSUtil
The embedding application owns and configures the Jetty server, its network listeners, and handler tree. This utility contributes an upgrade handler; it does not create, start, stop, or own those server resources. The acceptor list scopes routing for this handler, preventing it from selecting another context's acceptor merely because that acceptor is registered in the JVM-wide Net4j registry. Other provider integrations may use different routing arrangements.
- Author:
- Eike Stepper
-
Method Summary
Modifier and TypeMethodDescriptionstatic org.eclipse.jetty.websocket.server.WebSocketUpgradeHandlercreateUpgradeHandler(org.eclipse.jetty.server.Server server, org.eclipse.jetty.server.handler.ContextHandler context, String pathSpec, IWSAcceptor... acceptors) Creates a Jetty handler that registers one WebSocket path and routes upgrades only to the configured Net4j acceptors.
-
Method Details
-
createUpgradeHandler
public static org.eclipse.jetty.websocket.server.WebSocketUpgradeHandler createUpgradeHandler(org.eclipse.jetty.server.Server server, org.eclipse.jetty.server.handler.ContextHandler context, String pathSpec, IWSAcceptor... acceptors) Creates a Jetty handler that registers one WebSocket path and routes upgrades only to the configured Net4j acceptors. Both the decoded request path suffix (the@nameroute) andNet4jAcceptorhandshake header must identify the same acceptor. At routing time, the selected acceptor must still be the instance registered under its name. Registry removal or replacement is therefore observed by subsequent routing checks. A request that passed the check before a concurrent change can still carry the previously selected instance into the handshake; if that acceptor is deactivated before acceptance, the accept call can fail.The returned handler wraps the context's current handler, preserving the existing application handler as its fallback. Install it as the context's handler before starting the server. Use a path spec such as
/net4j/*, because Net4j clients append the selected acceptor name to the path. The request's secure state must match the acceptor type (wsfor non-secure,wssfor secure requests); TLS is configured by the application's server connectors. The explicit acceptor set is snapshotted for this handler, but registration and deactivation remain lifecycle responsibilities of the caller and the Net4j container.- Parameters:
server- the operator-owned Jetty server used to create the upgrade handlercontext- the context that will contain the WebSocket mappingpathSpec- the Jetty path specification for the Net4j WebSocket endpointacceptors- the active acceptors explicitly exposed by this endpoint; each must be the currently registered instance- Returns:
- the configured upgrade handler to link into the Jetty handler tree
- Throws:
IllegalArgumentException- if an argument isnull, the path is empty, or the acceptors are empty, inactive, or duplicated
-