• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2008 Google Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package com.google.inject.spi;
18 
19 import com.google.inject.Scope;
20 import java.lang.annotation.Annotation;
21 
22 /**
23  * Visits each of the strategies used to scope an injection.
24  *
25  * @param <V> any type to be returned by the visit method. Use {@link Void} with {@code return null}
26  *     if no return type is needed.
27  * @since 2.0
28  */
29 public interface BindingScopingVisitor<V> {
30 
31   /**
32    * Visit an eager singleton or single instance. This scope strategy is found on both module and
33    * injector bindings.
34    */
visitEagerSingleton()35   V visitEagerSingleton();
36 
37   /** Visit a scope instance. This scope strategy is found on both module and injector bindings. */
visitScope(Scope scope)38   V visitScope(Scope scope);
39 
40   /**
41    * Visit a scope annotation. This scope strategy is found only on module bindings. The instance
42    * that implements this scope is registered by {@link com.google.inject.Binder#bindScope(Class,
43    * Scope) Binder.bindScope()}.
44    */
visitScopeAnnotation(Class<? extends Annotation> scopeAnnotation)45   V visitScopeAnnotation(Class<? extends Annotation> scopeAnnotation);
46 
47   /**
48    * Visit an unspecified or unscoped strategy. On a module, this strategy indicates that the
49    * injector should use scoping annotations to find a scope. On an injector, it indicates that no
50    * scope is applied to the binding. An unscoped binding will behave like a scoped one when it is
51    * linked to a scoped binding.
52    */
visitNoScoping()53   V visitNoScoping();
54 }
55