@Override public boolean handleRequest(VaadinSession session, VaadinRequest request, VaadinResponse response) throws IOException { if (!ServletPortletHelper.isPushRequest(request)) { return false; } if (request instanceof VaadinServletRequest) { if (atmosphere == null) { response.sendError(500, "Atmosphere initialization failed. No push available."); return true; } try { atmosphere.doCometSupport( AtmosphereRequestImpl .wrap((VaadinServletRequest) request), AtmosphereResponseImpl .wrap((VaadinServletResponse) response)); } catch (ServletException e) { // TODO PUSH decide how to handle throw new RuntimeException(e); } } else { throw new IllegalArgumentException( "Portlets not currently supported"); } return true; }
@Override public ServletOutputStream getOutputStream() throws IOException { if (sout == null) { sout = new BufferedServletOutputStream(super.getOutputStream()); } return sout; }
@Override public void operationComplete(ChannelFuture future) throws Exception { if (!future.isSuccess()) { future.channel().close(); } else { websocketChannels.add(ctx.channel()); ctx.channel().attr(ATTACHMENT).set(webSocket); if (config.noInternalAlloc()) { webSocket.resource(proxiedResource); } AtmosphereResponse response = config.noInternalAlloc() ? proxiedResponse : AtmosphereResponseImpl.newInstance(framework.getAtmosphereConfig(), atmosphereRequest, webSocket); webSocketProcessor.open(webSocket, atmosphereRequest, response); if (webSocketTimeout > 0) { webSocket.closeFuture(suspendTimer.scheduleAtFixedRate(() -> { if (webSocket.lastWriteTimeStampInMilliseconds() != 0 && (System.currentTimeMillis() - webSocket.lastWriteTimeStampInMilliseconds() > webSocketTimeout)) { logger.debug("Timing out {}", webSocket); webSocket.close(); } }, webSocketTimeout, webSocketTimeout, TimeUnit.MILLISECONDS)); } } } });
@Override public void preStart() { try { this.playWebSocket = new PlayWebSocket(actorRef, atmosphereConfig); this.webSocketProcessor = WebSocketProcessorFactory.getDefault().getWebSocketProcessor(atmosphereConfig.framework()); AtmosphereRequest atmosphereRequest = AtmosphereUtils.request(new Http.RequestImpl(requestHeader), additionalAttributes); this.webSocketProcessor.open(playWebSocket, atmosphereRequest, AtmosphereResponseImpl.newInstance(atmosphereConfig, atmosphereRequest, playWebSocket)); } catch (Throwable throwable) { LOG.error("Failed to start the actor ", throwable); } }
/** * Weblogic specific comet based implementation. * * @param rrk * @throws java.io.IOException * @throws javax.servlet.ServletException */ protected void doTimeout(RequestResponseKey rrk) throws IOException, ServletException { ((AsynchronousProcessor) framework.getAsyncSupport()).timedout(AtmosphereRequestImpl.wrap(rrk.getRequest()), AtmosphereResponseImpl.wrap(rrk.getResponse())); }
@Override public void operationComplete(ChannelFuture future) throws Exception { if (!future.isSuccess()) { future.channel().close(); } else { websocketChannels.add(ctx.channel()); ctx.channel().attr(ATTACHMENT).set(webSocket); if (config.noInternalAlloc()) { webSocket.resource(proxiedResource); } AtmosphereResponse response = config.noInternalAlloc() ? proxiedResponse : AtmosphereResponseImpl.newInstance(framework.getAtmosphereConfig(), atmosphereRequest, webSocket); webSocketProcessor.open(webSocket, atmosphereRequest, response); if (webSocketTimeout > 0) { webSocket.closeFuture(suspendTimer.scheduleAtFixedRate(() -> { if (webSocket.lastWriteTimeStampInMilliseconds() != 0 && (System.currentTimeMillis() - webSocket.lastWriteTimeStampInMilliseconds() > webSocketTimeout)) { logger.debug("Timing out {}", webSocket); webSocket.close(); } }, webSocketTimeout, webSocketTimeout, TimeUnit.MILLISECONDS)); } } } });
@Override public void doPost(HttpServletRequest req, HttpServletResponse res) throws IOException, ServletException { framework.doCometSupport(AtmosphereRequestImpl.wrap(req), AtmosphereResponseImpl.wrap(res)); }
.build(); final WebSocket w = new VertxWebSocket(framework.getAtmosphereConfig(), webSocket); try { webSocketProcessor.open(w, r, AtmosphereResponseImpl.newInstance(framework.getAtmosphereConfig(), r, w)); } catch (IOException e) { logger.debug("", e);
@Override public ServletOutputStream getOutputStream() throws IOException { if (sout == null) { sout = new BufferedServletOutputStream(super.getOutputStream()); } return sout; }
public void handleNormalRequest(HttpServletRequest request, HttpServletResponse response) throws Exception { try { framework.doCometSupport(AtmosphereRequestImpl.wrap(request), AtmosphereResponseImpl.wrap(response)); } catch (ServletException e) { throw new IOException(e); } }
public void handleNormalRequest(HttpServletRequest request, HttpServletResponse response) throws Exception { try { framework.doCometSupport(AtmosphereRequestImpl.wrap(request), AtmosphereResponseImpl.wrap(response)); } catch (ServletException e) { throw new IOException(e); } }
void service(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { this.queryMap = getQueryMap(request.getQueryString()); framework.doCometSupport(AtmosphereRequestImpl.wrap(request), AtmosphereResponseImpl.wrap(response)); }
@Override public void invoke(ServletConfig config, ServletContext context, HttpServletRequest req, HttpServletResponse resp) throws IOException { if (AtmosphereUtils.useAtmosphere(req)) { try { framework.doCometSupport(AtmosphereRequestImpl.wrap(req), AtmosphereResponseImpl.wrap(resp)); } catch (ServletException e) { throw new IOException(e); } return; } super.invoke(config, context, req, resp); }
@Override public void invoke(ServletConfig config, ServletContext context, HttpServletRequest req, HttpServletResponse resp) throws IOException { if (AtmosphereUtils.useAtmosphere(req)) { try { framework.doCometSupport(AtmosphereRequestImpl.wrap(req), AtmosphereResponseImpl.wrap(resp)); } catch (ServletException e) { throw new IOException(e); } return; } super.invoke(config, context, req, resp); }
@Override public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { if (AtmosphereUtils.useAtmosphere(request)) { try { framework.doCometSupport(AtmosphereRequestImpl.wrap(request), AtmosphereResponseImpl.wrap(response)); baseRequest.setHandled(true); } catch (ServletException e) { throw new IOException(e); } return; } super.handle(target, baseRequest, request, response); } }
@Override public boolean handleRequest(VaadinSession session, VaadinRequest request, VaadinResponse response) throws IOException { if (!ServletHelper.isRequestType(request, RequestType.PUSH)) { return false; } if (request instanceof VaadinServletRequest) { if (atmosphere == null) { response.sendError(500, "Atmosphere initialization failed. No push available."); return true; } try { atmosphere.doCometSupport( AtmosphereRequestImpl .wrap((VaadinServletRequest) request), AtmosphereResponseImpl .wrap((VaadinServletResponse) response)); } catch (ServletException e) { // TODO PUSH decide how to handle throw new RuntimeException(e); } } else { throw new IllegalArgumentException( "Only VaadinServletRequests are supported"); } return true; }
@Override public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { if (AtmosphereUtils.useAtmosphere(request)) { try { framework.doCometSupport(AtmosphereRequestImpl.wrap(request), AtmosphereResponseImpl.wrap(response)); baseRequest.setHandled(true); } catch (ServletException e) { throw new IOException(e); } return; } super.handle(target, baseRequest, request, response); } }
public void handleNormalRequest(HttpServerExchange undertowExchange) throws Exception { HttpServletResponseImpl response = new HttpServletResponseImpl(undertowExchange, (ServletContextImpl)servletContext); HttpServletRequestImpl request = new HttpServletRequestImpl(undertowExchange, (ServletContextImpl)servletContext); ServletRequestContext servletRequestContext = new ServletRequestContext(((ServletContextImpl)servletContext) .getDeployment(), request, response, null); undertowExchange.putAttachment(ServletRequestContext.ATTACHMENT_KEY, servletRequestContext); try { framework.doCometSupport(AtmosphereRequestImpl.wrap(request), AtmosphereResponseImpl.wrap(response)); } catch (ServletException e) { throw new IOException(e); } }
public void handleNormalRequest(HttpServerExchange undertowExchange) throws Exception { HttpServletResponseImpl response = new HttpServletResponseImpl(undertowExchange, (ServletContextImpl)servletContext); HttpServletRequestImpl request = new HttpServletRequestImpl(undertowExchange, (ServletContextImpl)servletContext); ServletRequestContext servletRequestContext = new ServletRequestContext(((ServletContextImpl)servletContext) .getDeployment(), request, response, null); undertowExchange.putAttachment(ServletRequestContext.ATTACHMENT_KEY, servletRequestContext); try { framework.doCometSupport(AtmosphereRequestImpl.wrap(request), AtmosphereResponseImpl.wrap(response)); } catch (ServletException e) { throw new IOException(e); } }
/** * Weblogic specific comet based implementation. * * @param rrk * @return true if suspended * @throws java.io.IOException * @throws javax.servlet.ServletException */ protected boolean doRequest(RequestResponseKey rrk) throws IOException, ServletException { try { rrk.getRequest().getSession().setAttribute(WebLogicCometSupport.RRK, rrk); Action action = framework.doCometSupport(AtmosphereRequestImpl.wrap(rrk.getRequest()), AtmosphereResponseImpl.wrap(rrk.getResponse())); if (action.type() == Action.TYPE.SUSPEND) { if (action.timeout() == -1) { rrk.setTimeout(Integer.MAX_VALUE); } else { rrk.setTimeout((int) action.timeout()); } } return action.type() == Action.TYPE.SUSPEND; } catch (IllegalStateException ex) { logger.error("AtmosphereServlet.doRequest exception", ex); throw ex; } }