@Override public void run() { responder.runtime.requestScope.runInScope(requestContext, new Runnable() { @Override public void run() { try { requestScopeListener.resume(foreignScopeInstance, responder.runtime.injectionManager); final Response response = producer.call(); if (response != null) { resume(response); } } catch (final Throwable t) { resume(t); } } }); } });
@Override public void run() { responder.runtime.requestScope.runInScope(requestContext, new Runnable() { @Override public void run() { try { requestScopeListener.resume(foreignScopeInstance, responder.runtime.injectionManager); final Response response = producer.call(); if (response != null) { resume(response); } } catch (final Throwable t) { resume(t); } } }); } });
private boolean cancel(final Value<Response> responseValue) { synchronized (stateLock) { if (cancelled) { return true; } if (state != SUSPENDED) { return false; } state = RESUMED; cancelled = true; } responder.runtime.requestScope.runInScope(requestContext, new Runnable() { @Override public void run() { try { requestScopeListener.resume(foreignScopeInstance, responder.runtime.injectionManager); final Response response = responseValue.get(); responder.process(new ContainerResponse(responder.processingContext.request(), response)); } catch (final Throwable t) { responder.process(t); } } }); return true; }
private boolean cancel(final Value<Response> responseValue) { synchronized (stateLock) { if (cancelled) { return true; } if (state != SUSPENDED) { return false; } state = RESUMED; cancelled = true; } responder.runtime.requestScope.runInScope(requestContext, new Runnable() { @Override public void run() { try { requestScopeListener.resume(foreignScopeInstance, responder.runtime.injectionManager); final Response response = responseValue.get(); responder.process(new ContainerResponse(responder.processingContext.request(), response)); } catch (final Throwable t) { responder.process(t); } } }); return true; }
private Future<?> submit(final ExecutorService executor, final Runnable task) { return executor.submit(() -> requestScope.runInScope(task)); }
private Future<?> submit(final ExecutorService executor, final Runnable task) { return executor.submit(() -> requestScope.runInScope(task)); }
private Future<?> submit(final ExecutorService executor, final Runnable task) { return executor.submit(() -> requestScope.runInScope(task)); }
private <T> T runInScopeIfPossible(Producer<T> producer) { if (scope != null && requestContext != null) { return scope.runInScope(requestContext, producer); } else { return producer.call(); } } }
private <T> T runInScopeIfPossible(Producer<T> producer) { if (scope != null && requestContext != null) { return scope.runInScope(requestContext, producer); } else { return producer.call(); } } }
private boolean resume(final Runnable handler) { synchronized (stateLock) { if (state != SUSPENDED) { return false; } state = RESUMED; } try { responder.runtime.requestScope.runInScope(requestContext, handler); } finally { requestContext.release(); } return true; }
private boolean resume(final Runnable handler) { synchronized (stateLock) { if (state != SUSPENDED) { return false; } state = RESUMED; } try { responder.runtime.requestScope.runInScope(requestContext, handler); } finally { requestContext.release(); } return true; }
private <T> T runInScopeIfPossible(Producer<T> producer) { if (scope != null && requestContext != null) { return scope.runInScope(requestContext, producer); } else { return producer.call(); } } }
@Override public Response invoke() throws ProcessingException, WebApplicationException { final ClientRuntime runtime = request().getClientRuntime(); final RequestScope requestScope = runtime.getRequestScope(); return requestScope.runInScope( (Producer<Response>) () -> new InboundJaxrsResponse(runtime.invoke(requestForCall(requestContext)), requestScope)); }
@Override public Response invoke() throws ProcessingException, WebApplicationException { final ClientRuntime runtime = request().getClientRuntime(); final RequestScope requestScope = runtime.getRequestScope(); return requestScope.runInScope( (Producer<Response>) () -> new InboundJaxrsResponse(runtime.invoke(requestForCall(requestContext)), requestScope)); }
@Override public Response invoke() throws ProcessingException, WebApplicationException { final ClientRuntime runtime = request().getClientRuntime(); final RequestScope requestScope = runtime.getRequestScope(); return requestScope.runInScope( (Producer<Response>) () -> new InboundJaxrsResponse(runtime.invoke(requestForCall(requestContext)), requestScope)); }
@Override public <T> T invoke(final GenericType<T> responseType) throws ProcessingException, WebApplicationException { if (responseType == null) { throw new IllegalArgumentException(LocalizationMessages.RESPONSE_TYPE_IS_NULL()); } final ClientRuntime runtime = request().getClientRuntime(); final RequestScope requestScope = runtime.getRequestScope(); //noinspection Duplicates return requestScope.runInScope(() -> { try { return translate(runtime.invoke(requestForCall(requestContext)), requestScope, responseType); } catch (final ProcessingException ex) { if (ex.getCause() instanceof WebApplicationException) { throw (WebApplicationException) ex.getCause(); } throw ex; } }); }
@Override public <T> T invoke(final GenericType<T> responseType) throws ProcessingException, WebApplicationException { if (responseType == null) { throw new IllegalArgumentException(LocalizationMessages.RESPONSE_TYPE_IS_NULL()); } final ClientRuntime runtime = request().getClientRuntime(); final RequestScope requestScope = runtime.getRequestScope(); //noinspection Duplicates return requestScope.runInScope(() -> { try { return translate(runtime.invoke(requestForCall(requestContext)), requestScope, responseType); } catch (final ProcessingException ex) { if (ex.getCause() instanceof WebApplicationException) { throw (WebApplicationException) ex.getCause(); } throw ex; } }); }
@Override public <T> T invoke(final Class<T> responseType) throws ProcessingException, WebApplicationException { if (responseType == null) { throw new IllegalArgumentException(LocalizationMessages.RESPONSE_TYPE_IS_NULL()); } final ClientRuntime runtime = request().getClientRuntime(); final RequestScope requestScope = runtime.getRequestScope(); //noinspection Duplicates return requestScope.runInScope(() -> { try { return translate(runtime.invoke(requestForCall(requestContext)), requestScope, responseType); } catch (final ProcessingException ex) { if (ex.getCause() instanceof WebApplicationException) { throw (WebApplicationException) ex.getCause(); } throw ex; } }); }
@Override public <T> T invoke(final Class<T> responseType) throws ProcessingException, WebApplicationException { if (responseType == null) { throw new IllegalArgumentException(LocalizationMessages.RESPONSE_TYPE_IS_NULL()); } final ClientRuntime runtime = request().getClientRuntime(); final RequestScope requestScope = runtime.getRequestScope(); //noinspection Duplicates return requestScope.runInScope(() -> { try { return translate(runtime.invoke(requestForCall(requestContext)), requestScope, responseType); } catch (final ProcessingException ex) { if (ex.getCause() instanceof WebApplicationException) { throw (WebApplicationException) ex.getCause(); } throw ex; } }); }
@Override public <T> T invoke(final Class<T> responseType) throws ProcessingException, WebApplicationException { if (responseType == null) { throw new IllegalArgumentException(LocalizationMessages.RESPONSE_TYPE_IS_NULL()); } final ClientRuntime runtime = request().getClientRuntime(); final RequestScope requestScope = runtime.getRequestScope(); //noinspection Duplicates return requestScope.runInScope(() -> { try { return translate(runtime.invoke(requestForCall(requestContext)), requestScope, responseType); } catch (final ProcessingException ex) { if (ex.getCause() instanceof WebApplicationException) { throw (WebApplicationException) ex.getCause(); } throw ex; } }); }