public static RequestScoper scopeRequest(Map<Key<?>, Object> seedMap) {
    Preconditions.checkArgument(
        null != seedMap, "Seed map cannot be null, try passing in Collections.emptyMap() instead.");

    // Copy the seed values into our local scope map.
    final Context context = new Context();
    Map<Key<?>, Object> validatedAndCanonicalizedMap =
        Maps.transformEntries(
            seedMap,
            new EntryTransformer<Key<?>, Object, Object>() {
              @Override
              public Object transformEntry(Key<?> key, Object value) {
                return validateAndCanonicalizeValue(key, value);
              }
            });
    context.map.putAll(validatedAndCanonicalizedMap);
    return new RequestScoper() {
      @Override
      public CloseableScope open() {
        checkScopingState(
            null == GuiceFilter.localContext.get(),
            "An HTTP request is already in progress, cannot scope a new request in this thread.");
        checkScopingState(
            null == requestScopeContext.get(),
            "A request scope is already in progress, cannot scope a new request in this thread.");
        return context.open();
      }
    };
  }
public static RequestScoper scopeRequest ( Map < Key < ? > , Object > seedMap ) { Preconditions . checkArgument ( null != seedMap , "Seed map cannot be null, try passing in Collections.emptyMap() instead." ) ; final Context context = new Context ( ) ; Map < Key < ? > , Object > validatedAndCanonicalizedMap = Maps . transformEntries ( seedMap , new EntryTransformer < Key < ? > , Object , Object > ( ) { @ Override public Object transformEntry ( Key < ? > key , Object value ) { return validateAndCanonicalizeValue ( key , value ) ; } } ) ; context . map . putAll ( validatedAndCanonicalizedMap ) ; return new RequestScoper ( ) { @ Override public CloseableScope open ( ) { checkScopingState ( null == GuiceFilter . localContext . get ( ) , "An HTTP request is already in progress, cannot scope a new request in this thread." ) ; checkScopingState ( null == requestScopeContext . get ( ) , "A request scope is already in progress, cannot scope a new request in this thread." ) ; return context . open ( ) ; } } ; }
Returns an object that will apply request scope to a block of code. This is not the same as the
HTTP request scope, but is used if no HTTP request scope is in progress. In this way, keys can
be scoped as @RequestScoped and exist in non-HTTP requests (for example: RPC requests) as well
as in HTTP request threads.

<p>The returned object will throw a {@link ScopingException} when opened if there is a request
scope already active on the current thread.

@param seedMap the initial set of scoped instances for Guice to seed the request scope with. To
seed a key with null, use {@code null} as the value.
@return an object that when opened will initiate the request scope
@since 4.1