for (String path : webSocketHandlers.keySet()) { WebSocketCreator webSocketCreator = WebSocketCreatorFactory.create(webSocketHandlers.get(path)); webSocketConfiguration.addMapping(new ServletPathSpec(path), webSocketCreator);
private void addEndpoint(ServerEndpointMetadata metadata) throws DeploymentException { JsrCreator creator = new JsrCreator(this,metadata,this.configuration.getFactory().getExtensionFactory()); this.configuration.addMapping("uri-template|" + metadata.getPath(), creator); }
public WebSocketServletFactory getFactory() { return configuration.getFactory(); }
@Override public void addMapping(String rawspec, WebSocketCreator creator) { PathSpec spec = toPathSpec(rawspec); addMapping(spec, creator); }
@Override public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException if (configuration.getFactory().isUpgradeRequest(request,response)) MappedResource<WebSocketCreator> resource = configuration.getMatch(target); if (resource == null) if (configuration.getFactory().acceptWebSocket(creator,request,response))
@Override public int getDefaultMaxTextMessageBufferSize() { return this.configuration.getPolicy().getMaxTextMessageSize(); }
public WebSocketUpgradeFilter(WebSocketServerFactory factory) { this(new NativeWebSocketConfiguration(factory)); }
@Override public boolean removeMapping(String spec) { return configuration.removeMapping(spec); }
@Override public WebSocketCreator getMapping(String target) { return configuration.getMapping(target); }
/** * Manually add a WebSocket mapping. * <p> * If mapping is added before this configuration is started, then it is persisted through * stop/start of this configuration's lifecycle. Otherwise it will be removed when * this configuration is stopped. * </p> * * @param pathSpec the pathspec to respond on * @param creator the websocket creator to activate on the provided mapping. */ @Override public void addMapping(PathSpec pathSpec, WebSocketCreator creator) { WebSocketCreator wsCreator = creator; if (!isRunning()) { wsCreator = new PersistedWebSocketCreator(creator); } mappings.put(pathSpec, wsCreator); }
public WebSocketServerFactory getWebSocketServerFactory() { return this.configuration.getFactory(); }
/** * Manually add a WebSocket mapping. * * @param rawspec the pathspec to map to (see {@link MappedWebSocketCreator#addMapping(String, WebSocketCreator)} for syntax details) * @param endpointClass the endpoint class to use for new upgrade requests on the provided * pathspec (can be an {@link org.eclipse.jetty.websocket.api.annotations.WebSocket} annotated * POJO, or implementing {@link org.eclipse.jetty.websocket.api.WebSocketListener}) */ public void addMapping(String rawspec, final Class<?> endpointClass) { PathSpec pathSpec = toPathSpec(rawspec); addMapping(pathSpec, endpointClass); }
WebSocketServletFactory factory = configuration.getFactory(); MappedResource<WebSocketCreator> resource = configuration.getMatch(target); if (resource == null)
@Override public long getDefaultAsyncSendTimeout() { return this.configuration.getPolicy().getAsyncWriteTimeout(); }
public static NativeWebSocketConfiguration getDefaultFrom(ServletContext context) { final String KEY = NativeWebSocketConfiguration.class.getName(); NativeWebSocketConfiguration configuration = (NativeWebSocketConfiguration) context.getAttribute(KEY); if (configuration == null) { // Not provided to us, create a new default one. configuration = new NativeWebSocketConfiguration(context); context.setAttribute(KEY, configuration); // Attach default configuration to context lifecycle if (context instanceof ContextHandler.Context) { ContextHandler handler = ((ContextHandler.Context)context).getContextHandler(); // Let ContextHandler handle configuration lifecycle handler.addManaged(configuration); } } return configuration; }
@Override public boolean removeMapping(String spec) { return configuration.removeMapping(spec); }
@Override public WebSocketCreator getMapping(String target) { return getConfiguration().getMapping(target); }
@Override public void addMapping(PathSpec spec, WebSocketCreator creator) { this.configuration.addMapping(spec, creator); }