Tabnine Logo
RequestScope.runInScope
Code IndexAdd Tabnine to your IDE (free)

How to use
runInScope
method
in
org.glassfish.jersey.process.internal.RequestScope

Best Java code snippets using org.glassfish.jersey.process.internal.RequestScope.runInScope (Showing top 20 results out of 315)

origin: jersey/jersey

  @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);
        }
      }
    });
  }
});
origin: jersey/jersey

  @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);
        }
      }
    });
  }
});
origin: jersey/jersey

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;
}
origin: jersey/jersey

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;
}
origin: jersey/jersey

private Future<?> submit(final ExecutorService executor, final Runnable task) {
  return executor.submit(() -> requestScope.runInScope(task));
}
origin: jersey/jersey

private Future<?> submit(final ExecutorService executor, final Runnable task) {
  return executor.submit(() -> requestScope.runInScope(task));
}
origin: org.glassfish.jersey.core/jersey-client

private Future<?> submit(final ExecutorService executor, final Runnable task) {
  return executor.submit(() -> requestScope.runInScope(task));
}
origin: jersey/jersey

  private <T> T runInScopeIfPossible(Producer<T> producer) {
    if (scope != null && requestContext != null) {
      return scope.runInScope(requestContext, producer);
    } else {
      return producer.call();
    }
  }
}
origin: jersey/jersey

  private <T> T runInScopeIfPossible(Producer<T> producer) {
    if (scope != null && requestContext != null) {
      return scope.runInScope(requestContext, producer);
    } else {
      return producer.call();
    }
  }
}
origin: jersey/jersey

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;
}
origin: jersey/jersey

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;
}
origin: org.glassfish.jersey.core/jersey-client

  private <T> T runInScopeIfPossible(Producer<T> producer) {
    if (scope != null && requestContext != null) {
      return scope.runInScope(requestContext, producer);
    } else {
      return producer.call();
    }
  }
}
origin: jersey/jersey

@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));
}
origin: jersey/jersey

@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));
}
origin: org.glassfish.jersey.core/jersey-client

@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));
}
origin: jersey/jersey

@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;
    }
  });
}
origin: jersey/jersey

@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;
    }
  });
}
origin: jersey/jersey

@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;
    }
  });
}
origin: jersey/jersey

@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;
    }
  });
}
origin: org.glassfish.jersey.core/jersey-client

@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;
    }
  });
}
org.glassfish.jersey.process.internalRequestScoperunInScope

Javadoc

Runs the Runnable in the new request scope. 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 RequestContext. At the end of the method the request scope is returned to its original state. The newly created RequestContext will be implicitly released at the end of the method call except the task will call RequestScope#suspendCurrent.

Popular methods of RequestScope

  • current
  • referenceCurrent
    Get a new reference for to currently running request scope instance. This call prevents automatic Re
  • retrieveCurrent
  • <init>
  • activate
    Stores the provided RequestContext to thread-local variable belonging to current request scope.
  • createContext
    Creates a new instance of the RequestContext. This instance can be then used to run task in the requ
  • release
    Releases the provided RequestContext to thread-local variable belonging to current request scope.
  • resume
    Resumes the provided RequestContext to thread-local variable belonging to current request scope.
  • createInstance
    Creates a new instance of the RequestScope.Instance. This instance can be then used to run task in t
  • isActive
  • resumeCurrent
  • setCurrent
  • resumeCurrent,
  • setCurrent,
  • shutdown,
  • suspend

Popular in Java

  • Start an intent from android
  • onCreateOptionsMenu (Activity)
  • onRequestPermissionsResult (Fragment)
  • getExternalFilesDir (Context)
  • GridLayout (java.awt)
    The GridLayout class is a layout manager that lays out a container's components in a rectangular gri
  • Window (java.awt)
    A Window object is a top-level window with no borders and no menubar. The default layout for a windo
  • Hashtable (java.util)
    A plug-in replacement for JDK1.5 java.util.Hashtable. This version is based on org.cliffc.high_scale
  • StringTokenizer (java.util)
    Breaks a string into tokens; new code should probably use String#split.> // Legacy code: StringTo
  • JCheckBox (javax.swing)
  • Table (org.hibernate.mapping)
    A relational table
  • Top PhpStorm plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now