public void release() { if (asyncResponder == null) { requestContext.release(); } } }
/** * Get a new reference for to currently running request scope context. This call * prevents automatic {@link RequestContext#release() release} of the scope * context once the task that runs in the scope has finished. * <p> * The returned scope context may be used to run additional task(s) in the * same request scope using one of the {@code #runInScope(RequestContext, ...)} methods. * </p> * <p> * Note that the returned context must be {@link RequestContext#release() * released} manually once not needed anymore to prevent memory leaks. * </p> * * @return currently active {@link RequestContext request scope context}. * @throws IllegalStateException in case there is no active request scope associated * with the current thread or if the request scope has * been already shut down. * @see #suspendCurrent() */ public RequestContext referenceCurrent() throws IllegalStateException { return current().getReference(); }
public void release() { if (asyncResponder == null) { requestContext.release(); } } }
/** * Get a new reference for to currently running request scope context. This call * prevents automatic {@link RequestContext#release() release} of the scope * context once the task that runs in the scope has finished. * <p> * The returned scope context may be used to run additional task(s) in the * same request scope using one of the {@code #runInScope(RequestContext, ...)} methods. * </p> * <p> * Note that the returned context must be {@link RequestContext#release() * released} manually once not needed anymore to prevent memory leaks. * </p> * * @return currently active {@link RequestContext request scope context}. * @throws IllegalStateException in case there is no active request scope associated * with the current thread or if the request scope has * been already shut down. * @see #suspendCurrent() */ public RequestContext referenceCurrent() throws IllegalStateException { return current().getReference(); }
/** * Releases the provided {@link RequestContext} to thread-local variable belonging to current request scope. * * @param context storage with request scoped objects. */ protected void release(RequestContext context) { context.release(); }
RequestContext referencedContext = context.getReference(); suspend(referencedContext); return referencedContext;
/** * Releases the provided {@link RequestContext} to thread-local variable belonging to current request scope. * * @param context storage with request scoped objects. */ protected void release(RequestContext context) { context.release(); }
RequestContext referencedContext = context.getReference(); suspend(referencedContext); return referencedContext;
@Override public void close() throws ProcessingException { try { context.close(); } finally { if (requestContext != null) { requestContext.release(); } } }
/** * Runs the {@link Runnable task} in the request scope initialized from the * {@link RequestContext scope context}. The {@link RequestContext * scope context} is NOT released by the method (this must be done explicitly). The * current thread might be already in any request scope and in that case the scope * will be changed to the scope defined by the {@link RequestContext scope * instance}. At the end of the method the request scope is returned to its original * state. * * @param context The request scope context from which the request scope will be initialized. * @param task Task to be executed. */ public void runInScope(RequestContext context, Runnable task) { final RequestContext oldContext = retrieveCurrent(); try { activate(context.getReference(), oldContext); Errors.process(task); } finally { release(context); resume(oldContext); } }
@Override public void close() throws ProcessingException { try { context.close(); } finally { if (requestContext != null) { requestContext.release(); } } }
/** * Runs the {@link Runnable task} in the request scope initialized from the * {@link RequestContext scope context}. The {@link RequestContext * scope context} is NOT released by the method (this must be done explicitly). The * current thread might be already in any request scope and in that case the scope * will be changed to the scope defined by the {@link RequestContext scope * instance}. At the end of the method the request scope is returned to its original * state. * * @param context The request scope context from which the request scope will be initialized. * @param task Task to be executed. */ public void runInScope(RequestContext context, Runnable task) { final RequestContext oldContext = retrieveCurrent(); try { activate(context.getReference(), oldContext); Errors.process(task); } finally { release(context); resume(oldContext); } }
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; }
/** * Runs the {@link Callable task} in the request scope initialized from the * {@link RequestContext scope context}. The {@link RequestContext * scope context} is NOT released by the method (this must be done explicitly). The * current thread might be already in any request scope and in that case the scope * will be changed to the scope defined by the {@link RequestContext scope * instance}. At the end of the method the request scope is returned to its original * state. * * @param context The request scope context from which the request scope will be initialized. * @param task Task to be executed. * @param <T> {@code task} result type. * @return result returned by the {@code task}. * @throws Exception Exception thrown by the {@code task}. */ public <T> T runInScope(RequestContext context, Callable<T> task) throws Exception { final RequestContext oldContext = retrieveCurrent(); try { activate(context.getReference(), oldContext); return Errors.process(task); } finally { release(context); resume(oldContext); } }
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; }
/** * Runs the {@link org.glassfish.jersey.internal.util.Producer task} in the request scope initialized * from the {@link RequestContext scope context}. * The {@link RequestContext scope context} is NOT released by the method (this * must be done explicitly). The current thread might be already in any request scope * and in that case the scope will be changed to the scope defined by the * {@link RequestContext scope context}. At the end of the method the request * scope is returned to its original state. * * @param context The request scope context from which the request scope will be initialized. * @param task Task to be executed. * @param <T> {@code task} result type. * @return result returned by the {@code task} */ public <T> T runInScope(RequestContext context, Producer<T> task) { final RequestContext oldContext = retrieveCurrent(); try { activate(context.getReference(), oldContext); return Errors.process(task); } finally { release(context); resume(oldContext); } }
@Override public void close() throws ProcessingException { try { context.close(); } finally { if (requestContext != null) { requestContext.release(); } } }
/** * Runs the {@link org.glassfish.jersey.internal.util.Producer task} in the request scope initialized * from the {@link RequestContext scope context}. * The {@link RequestContext scope context} is NOT released by the method (this * must be done explicitly). The current thread might be already in any request scope * and in that case the scope will be changed to the scope defined by the * {@link RequestContext scope context}. At the end of the method the request * scope is returned to its original state. * * @param context The request scope context from which the request scope will be initialized. * @param task Task to be executed. * @param <T> {@code task} result type. * @return result returned by the {@code task} */ public <T> T runInScope(RequestContext context, Producer<T> task) { final RequestContext oldContext = retrieveCurrent(); try { activate(context.getReference(), oldContext); return Errors.process(task); } finally { release(context); resume(oldContext); } }
requestScopeContext.release();
/** * Runs the {@link Callable task} in the request scope initialized from the * {@link RequestContext scope context}. The {@link RequestContext * scope context} is NOT released by the method (this must be done explicitly). The * current thread might be already in any request scope and in that case the scope * will be changed to the scope defined by the {@link RequestContext scope * instance}. At the end of the method the request scope is returned to its original * state. * * @param context The request scope context from which the request scope will be initialized. * @param task Task to be executed. * @param <T> {@code task} result type. * @return result returned by the {@code task}. * @throws Exception Exception thrown by the {@code task}. */ public <T> T runInScope(RequestContext context, Callable<T> task) throws Exception { final RequestContext oldContext = retrieveCurrent(); try { activate(context.getReference(), oldContext); return Errors.process(task); } finally { release(context); resume(oldContext); } }