MCPcopy Create free account
hub / github.com/google/guice / scope

Method scope

core/src/com/google/inject/internal/Scoping.java:283–302  ·  view source on GitHub ↗

Scopes an internal factory.

(
      Key<T> key,
      InjectorImpl injector,
      InternalFactory<? extends T> creator,
      Object source,
      Scoping scoping)

Source from the content-addressed store, hash-verified

281
282 /** Scopes an internal factory. */
283 static <T> InternalFactory<? extends T> scope(
284 Key<T> key,
285 InjectorImpl injector,
286 InternalFactory<? extends T> creator,
287 Object source,
288 Scoping scoping) {
289
290 if (scoping.isNoScope()) {
291 return creator;
292 }
293
294 Scope scope = scoping.getScopeInstance();
295
296 // NOTE: SingletonScope relies on the fact that we are passing a
297 // ProviderToInternalFactoryAdapter here. If you change the type make sure to update
298 // SingletonScope as well.
299 Provider<T> scoped =
300 scope.scope(key, new ProviderToInternalFactoryAdapter<T>(injector, creator));
301 return new InternalFactoryToProviderAdapter<T>(scoped, source);
302 }
303
304 /**
305 * Replaces annotation scopes with instance scopes using the Injector's annotation-to-instance

Callers 5

visitMethod · 0.95
createMethod · 0.95

Calls 3

scopeMethod · 0.95
isNoScopeMethod · 0.80
getScopeInstanceMethod · 0.80

Tested by

no test coverage detected