コード例 #1
0
 public synchronized boolean suspendContinuationIfNeeded() {
   if (!cont.isPending() && !resumedByApplication) {
     initialSuspend = false;
     cont.suspend(AsyncResponse.NO_TIMEOUT);
     return true;
   } else {
     return false;
   }
 }
コード例 #2
0
 private synchronized boolean doResumeFinal(Object response) {
   inMessage.getExchange().put(AsyncResponse.class, this);
   cont.setObject(response);
   resumedByApplication = true;
   if (!initialSuspend) {
     cont.resume();
   } else {
     initialSuspend = false;
   }
   return true;
 }
コード例 #3
0
 public synchronized void handleTimeout() {
   if (!resumedByApplication) {
     if (pendingTimeout != null) {
       setAsyncResponseOnExchange();
       cont.suspend(pendingTimeout);
       pendingTimeout = null;
     } else if (timeoutHandler != null) {
       timeoutHandler.handleTimeout(this);
     } else {
       cont.setObject(new ServiceUnavailableException());
     }
   }
 }
コード例 #4
0
 public synchronized Object getResponseObject() {
   Object obj = cont.getObject();
   if (!(obj instanceof Response) && !(obj instanceof Throwable)) {
     obj = Response.ok().entity(obj).build();
   }
   return obj;
 }
コード例 #5
0
 @Override
 public synchronized boolean setTimeout(long time, TimeUnit unit) throws IllegalStateException {
   if (isCancelledOrNotSuspended()) {
     return false;
   }
   setAsyncResponseOnExchange();
   long timeout = TimeUnit.MILLISECONDS.convert(time, unit);
   initialSuspend = false;
   if (!cont.isPending()) {
     cont.suspend(timeout);
   } else {
     pendingTimeout = timeout;
     cont.resume();
   }
   return true;
 }
コード例 #6
0
 @Override
 public synchronized boolean isSuspended() {
   if (cancelled || resumedByApplication) {
     return false;
   }
   return initialSuspend || cont.isPending();
 }
コード例 #7
0
 public void reset() {
   cont.reset();
 }