comparison src/org/eclipse/jetty/server/AsyncContinuation.java @ 917:1fc8ee20cb18

remove doSuspend
author Franklin Schmidt <fschmidt@gmail.com>
date Sun, 09 Oct 2016 03:23:55 -0600
parents b9aa175d9a29
children 7b62446899c6
comparison
equal deleted inserted replaced
916:4de7f6e9c453 917:1fc8ee20cb18
338 } 338 }
339 } 339 }
340 } 340 }
341 341
342 /* ------------------------------------------------------------ */ 342 /* ------------------------------------------------------------ */
343 /* (non-Javadoc)
344 * @see javax.servlet.ServletRequest#suspend(long)
345 */
346 private void doSuspend(final ServletContext context,
347 final ServletRequest request,
348 final ServletResponse response)
349 {
350 synchronized (this)
351 {
352 switch(_state)
353 {
354 case __DISPATCHED:
355 case __REDISPATCHED:
356 _resumed=false;
357 _expired=false;
358
359 if (_event==null || request!=_event.getSuppliedRequest() || response != _event.getSuppliedResponse() || context != _event.getServletContext())
360 _event=new AsyncEventState(context,request,response);
361 else
362 {
363 _event._dispatchContext=null;
364 _event._pathInContext=null;
365 }
366 _state=__ASYNCSTARTED;
367 List<AsyncListener> recycle=_lastAsyncListeners;
368 _lastAsyncListeners=_asyncListeners;
369 _asyncListeners=recycle;
370 if (_asyncListeners!=null)
371 _asyncListeners.clear();
372 break;
373
374 default:
375 throw new IllegalStateException(this.getStatusString());
376 }
377 }
378
379 if (_lastAsyncListeners!=null)
380 {
381 for (AsyncListener listener : _lastAsyncListeners)
382 {
383 try
384 {
385 listener.onStartAsync(_event);
386 }
387 catch(Exception e)
388 {
389 LOG.warn("",e);
390 }
391 }
392 }
393 }
394
395 /* ------------------------------------------------------------ */
396 /** 343 /**
397 * Signal that the HttpConnection has finished handling the request. 344 * Signal that the HttpConnection has finished handling the request.
398 * For blocking connectors, this call may block if the request has 345 * For blocking connectors, this call may block if the request has
399 * been suspended (startAsync called). 346 * been suspended (startAsync called).
400 * @return true if handling is complete, false if the request should 347 * @return true if handling is complete, false if the request should
964 { 911 {
965 dispatch(); 912 dispatch();
966 } 913 }
967 914
968 915
969
970 /* ------------------------------------------------------------ */
971 protected void startAsync(final ServletContext context,
972 final ServletRequest request,
973 final ServletResponse response)
974 {
975 synchronized (this)
976 {
977 _responseWrapped=!(response instanceof Response);
978 doSuspend(context,request,response);
979 if (request instanceof HttpServletRequest)
980 {
981 _event._pathInContext = URIUtil.addPaths(((HttpServletRequest)request).getServletPath(),((HttpServletRequest)request).getPathInfo());
982 }
983 }
984 }
985
986 /* ------------------------------------------------------------ */
987 protected void startAsync()
988 {
989 _responseWrapped=false;
990 _continuation=false;
991 doSuspend(_connection.getRequest().getServletContext(),_connection.getRequest(),_connection.getResponse());
992 }
993
994
995 /* ------------------------------------------------------------ */
996 /**
997 * @see Continuation#suspend()
998 */
999 public void suspend(ServletResponse response)
1000 {
1001 _continuation=true;
1002 _responseWrapped=!(response instanceof Response);
1003 doSuspend(_connection.getRequest().getServletContext(),_connection.getRequest(),response);
1004 }
1005
1006 /* ------------------------------------------------------------ */
1007 /**
1008 * @see Continuation#suspend()
1009 */
1010 public void suspend()
1011 {
1012 _responseWrapped=false;
1013 _continuation=true;
1014 doSuspend(_connection.getRequest().getServletContext(),_connection.getRequest(),_connection.getResponse());
1015 }
1016
1017 /* ------------------------------------------------------------ */ 916 /* ------------------------------------------------------------ */
1018 /** 917 /**
1019 * @see org.eclipse.jetty.continuation.Continuation#getServletResponse() 918 * @see org.eclipse.jetty.continuation.Continuation#getServletResponse()
1020 */ 919 */
1021 public ServletResponse getServletResponse() 920 public ServletResponse getServletResponse()