• 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 
21 import java.lang.annotation.Annotation;
22 
23 /**
24  * Visits each of the strategies used to scope an injection.
25  *
26  * @param <V> any type to be returned by the visit method. Use {@link Void} with
27  *     {@code return null} if no return type is needed.
28  * @since 2.0
29  */
30 public interface BindingScopingVisitor<V> {
31 
32   /**
33    * Visit an eager singleton or single instance. This scope strategy is found on both module and
34    * injector bindings.
35    */
visitEagerSingleton()36   V visitEagerSingleton();
37 
38   /**
39    * Visit a scope instance. This scope strategy is found on both module and injector bindings.
40    */
visitScope(Scope scope)41   V visitScope(Scope scope);
42 
43   /**
44    * Visit a scope annotation. This scope strategy is found only on module bindings. The instance
45    * that implements this scope is registered by {@link com.google.inject.Binder#bindScope(Class,
46    * Scope) Binder.bindScope()}.
47    */
visitScopeAnnotation(Class<? extends Annotation> scopeAnnotation)48   V visitScopeAnnotation(Class<? extends Annotation> scopeAnnotation);
49 
50   /**
51    * Visit an unspecified or unscoped strategy. On a module, this strategy indicates that the
52    * injector should use scoping annotations to find a scope. On an injector, it indicates that
53    * no scope is applied to the binding. An unscoped binding will behave like a scoped one when it
54    * is linked to a scoped binding.
55    */
visitNoScoping()56   V visitNoScoping();
57 }
58