Ejemplo n.º 1
0
 public synchronized boolean suspendContinuationIfNeeded() {
   if (!cont.isPending() && !resumedByApplication) {
     initialSuspend = false;
     cont.suspend(AsyncResponse.NO_TIMEOUT);
     return true;
   } else {
     return false;
   }
 }
Ejemplo n.º 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;
 }
Ejemplo n.º 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());
     }
   }
 }
Ejemplo n.º 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;
 }
Ejemplo n.º 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;
 }
Ejemplo n.º 6
0
 @Override
 public synchronized boolean isSuspended() {
   if (cancelled || resumedByApplication) {
     return false;
   }
   return initialSuspend || cont.isPending();
 }
Ejemplo n.º 7
0
 public void reset() {
   cont.reset();
 }