} else if (cp != null && cp.getContinuation() != null) { final Continuation c = cp.getContinuation(); c.suspend(0); JaxwsServerHandler handler = new JaxwsServerHandler(c); ex.put(JaxwsServerHandler.class, handler);
public synchronized void suspendContinuation() { initialSuspend = false; cont.suspend(AsyncResponse.NO_TIMEOUT); }
private void suspendInvocation(String name, Continuation cont, long timeout) { try { cont.suspend(timeout); } finally { synchronized (suspended) { suspended.put(name, cont); suspended.notifyAll(); } } }
private void suspendInvocation(String name, Continuation cont, long timeout) { try { cont.suspend(timeout); } finally { synchronized (suspended) { suspended.put(name, cont); suspended.notifyAll(); } } }
private void suspendInvocation(final String name, Continuation cont) { //System.out.println("Suspending invocation for " + name); try { cont.suspend(500000); } finally { synchronized (suspended) { suspended.put(name, cont); } executor.execute(new Runnable() { public void run() { try { Thread.sleep(2000); } catch (InterruptedException ex) { // ignore } resumeRequest(name); } }); } }
private void suspendInvocation(final String name, Continuation cont) { //System.out.println("Suspending invocation for " + name); try { cont.suspend(500000); } finally { synchronized (suspended) { suspended.put(name, cont); } executor.execute(new Runnable() { public void run() { try { Thread.sleep(2000); } catch (InterruptedException ex) { // ignore } resumeRequest(name); } }); } }
public synchronized boolean suspendContinuationIfNeeded() { if (!resumedByApplication && !isDone() && !cont.isPending() && !cont.isResumed()) { cont.suspend(AsyncResponse.NO_TIMEOUT); initialSuspend = false; return true; } return false; }
@Override public synchronized void setTimeout(long time, TimeUnit unit) throws IllegalStateException { checkCancelled(); checkSuspended(); inMessage.getExchange().put(AsyncResponse.class, this); long timeout = TimeUnit.MILLISECONDS.convert(time, unit); initialSuspend = false; cont.suspend(timeout); }
private void suspendInvocation(final String name, Continuation cont) { //System.out.println("Suspending invocation for " + name); try { long timeout = "Fred".equals(name) ? 8000 : 4000; cont.suspend(timeout); } finally { synchronized (suspended) { suspended.put(name, cont); } if (!"Fred".equals(name)) { executor.execute(new Runnable() { public void run() { try { Thread.sleep(2000); } catch (InterruptedException ex) { // ignore } resumeRequest(name); } }); } } }
@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; }
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()); } } }
@Override public void writeTo(NioWriteEntity entity, Class<?> cls, Type t, Annotation[] anns, MediaType mt, MultivaluedMap<String, Object> headers, OutputStream os) throws IOException, WebApplicationException { Continuation cont = getContinuationProvider().getContinuation(); NioWriteListenerImpl listener = new NioWriteListenerImpl(cont, entity, os); Message m = JAXRSUtils.getCurrentMessage(); m.put(WriteListener.class, listener); // return the current thread to the pool cont.suspend(0); }
continuation.setObject(userObject); suspended = true; continuation.suspend(2000); } else { if (!suspended) {
public int doubleIt(int numberToDouble) throws DoubleItFault { Continuation continuation = getContinuation(numberToDouble); if (continuation == null) { throw new RuntimeException("Failed to get continuation"); } synchronized (continuation) { if (continuation.isNew()) { continuation.suspend(5000); } else { if (numberToDouble == 0) { throw new DoubleItFault("0 can't be doubled!"); } return numberToDouble * 2; } } // unreachable return 0; }
@Override public void handleMessage(Message message) throws Fault { ThrottleResponse rsp = manager.getThrottleResponse(getPhase(), message); if (rsp == null) { return; } message.getExchange().put(ThrottleResponse.class, rsp); if (rsp.getResponseCode() >= 300) { createOutMessage(message); message.getInterceptorChain().doInterceptStartingAt(message, OutgoingChainInterceptor.class.getName()); return; } long l = rsp.getDelay(); if (l > 0) { ContinuationProvider cp = message.get(ContinuationProvider.class); if (cp == null) { LOG.warning("No ContinuationProvider available, sleeping on current thread"); try { Thread.sleep(l); } catch (InterruptedException e) { //ignore } return; } Continuation c = cp.getContinuation(); c.suspend(l); } } private Message createOutMessage(Message inMessage) {
@Override public void handleMessage(Message message) throws Fault { ThrottleResponse rsp = manager.getThrottleResponse(getPhase(), message); if (rsp == null) { return; } message.getExchange().put(ThrottleResponse.class, rsp); if (rsp.getResponseCode() >= 300) { createOutMessage(message); message.getInterceptorChain().doInterceptStartingAt(message, OutgoingChainInterceptor.class.getName()); return; } long l = rsp.getDelay(); if (l > 0) { ContinuationProvider cp = message.get(ContinuationProvider.class); if (cp == null) { LOG.warning("No ContinuationProvider available, sleeping on current thread"); try { Thread.sleep(l); } catch (InterruptedException e) { //ignore } return; } Continuation c = cp.getContinuation(); c.suspend(l); } } private Message createOutMessage(Message inMessage) {
protected void copyUsingNio(InputStream is, OutputStream os, Continuation cont) { NioWriteListenerImpl listener = new NioWriteListenerImpl(cont, new NioWriteEntity(getNioHandler(is), null), new NioOutputStream(os)); Message m = JAXRSUtils.getCurrentMessage(); m.put(WriteListener.class, listener); cont.suspend(0); }
public SOAPMessage invoke(SOAPMessage request) { try { final MessageContext messageContext = ctx.getMessageContext(); ContinuationProvider contProvider = (ContinuationProvider) messageContext.get(ContinuationProvider.class.getName()); final Continuation continuation = contProvider.getContinuation(); if (continuation.isNew()) { continuation.suspend(5000); new Thread(new Runnable() { public void run() { try { continuation.resume(); } catch (Exception e) { e.printStackTrace(); } } }).start(); return null; } else if (!continuation.isResumed()) { continuation.reset(); throw new RuntimeException("time out"); } else { return resumeMessage(request); } } catch (SOAPFaultException e) { throw e; } }
if (continuation.suspend(-1)) { continuations.put(mn, continuation); throw new SuspendedInvocationException();