KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > google > inject > binder > LinkedBindingBuilder


1 /**
2  * Copyright (C) 2006 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.binder;
18
19 import com.google.inject.Key;
20 import com.google.inject.Provider;
21 import com.google.inject.TypeLiteral;
22
23 /**
24  * Links a binding to another binding or an instance.
25  *
26  * @author crazybob@google.com (Bob Lee)
27  */

28 public interface LinkedBindingBuilder<T> extends ScopedBindingBuilder {
29
30   /**
31    * Binds to another binding with the specified type.
32    */

33   ScopedBindingBuilder to(Class JavaDoc<? extends T> implementation);
34
35   /**
36    * Binds to another binding with the specified type.
37    */

38   ScopedBindingBuilder to(TypeLiteral<? extends T> implementation);
39
40   /**
41    * Binds to another binding with the specified key.
42    */

43   ScopedBindingBuilder to(Key<? extends T> targetKey);
44
45   /**
46    * Binds to the given instance. The Injector will automatically inject the
47    * members of this instance when it is first created. See {@link
48    * com.google.inject.Injector#injectMembers(Object)}.
49    */

50   void toInstance(T instance);
51
52   /**
53    * Binds to instances generated by the given Provider. The Injector will
54    * automatically inject the members of this provider instance when it is first
55    * created. See {@link com.google.inject.Injector#injectMembers(Object)}.
56    */

57   ScopedBindingBuilder toProvider(Provider<? extends T> provider);
58
59   /**
60    * Binds to instances from the provider bound to the given provider type.
61    */

62   ScopedBindingBuilder toProvider(
63       Class JavaDoc<? extends Provider<? extends T>> providerType);
64
65   /**
66    * Binds to instances from the provider bound to the given key.
67    */

68   ScopedBindingBuilder toProvider(
69       Key<? extends Provider<? extends T>> providerKey);
70 }
71
Popular Tags