55
55
public interface InjectionManager {
56
56
57
57
/**
58
- * This will initialize the {@code InjectionManager} and underlying DI provider. The method may get the array of binders to
58
+ * Initializes {@code InjectionManager} and underlying DI provider. The method may get the array of binders to
59
59
* register {@link Binding} them during initialization process. {@code name} and {@code parent} are not required parameters
60
- * and can be null without the initialization exception.
60
+ * and can be {@code null} without the initialization exception.
61
61
*
62
62
* @param name Name of the injection manager.
63
63
* @param parent Parent object of the underlying DI provider on which new injection manager should be dependent. A specific
@@ -68,12 +68,36 @@ public interface InjectionManager {
68
68
void initialize (String name , Object parent , Binder ... binders );
69
69
70
70
/**
71
- * This will shutdown the entire injection manager and underlying DI provider along with injected executors and schedulers.
71
+ * Initializes {@code InjectionManager} and underlying DI provider. The method may get the array of binders to
72
+ * register {@link Binding} them during initialization process. {@code parent} is not required parameters and can be
73
+ * {@code null} without the initialization exception.
74
+ *
75
+ * @param parent Parent object of the underlying DI provider on which new injection manager should be dependent. A specific
76
+ * DI provider checks whether the parent object is in the proper type of underlying service storage or
77
+ * a proper implementation of {@link InjectionManager}.
78
+ * @param binders Binders with descriptions to include them during initialization process.
79
+ */
80
+ default void initialize (Object parent , Binder ... binders ) {
81
+ initialize (null , parent , binders );
82
+ }
83
+
84
+ /**
85
+ * Initializes {@code InjectionManager} and underlying DI provider. The method may get the array of binders to
86
+ * register {@link Binding} them during initialization process.
87
+
88
+ * @param binders Binders with descriptions to include them during initialization process.
89
+ */
90
+ default void initialize (Binder ... binders ) {
91
+ initialize (null , null , binders );
92
+ }
93
+
94
+ /**
95
+ * Shuts down the entire {@link InjectionManager}and underlying DI provider along with injected executors and schedulers.
72
96
*/
73
97
void shutdown ();
74
98
75
99
/**
76
- * This will register one bean represented using fields in the provided descriptor. The final bean can be direct bean or
100
+ * Registers one bean represented using fields in the provided descriptor. The final bean can be direct bean or
77
101
* factory object which will create the bean at the time of injection. {@code InjectionManager} is able to register a bean
78
102
* represented by a class or direct instance.
79
103
*
@@ -86,7 +110,7 @@ public interface InjectionManager {
86
110
void register (Binding binding );
87
111
88
112
/**
89
- * This will register a collection of beans represented using fields in the provided descriptors. The final bean can be
113
+ * Registers a collection of beans represented using fields in the provided descriptors. The final bean can be
90
114
* direct bean or factory object which will create the bean at the time of injection. {@code InjectionManager} is able to
91
115
* register a bean represented by a class or direct instance.
92
116
*
@@ -99,7 +123,7 @@ public interface InjectionManager {
99
123
void register (Iterable <Binding > descriptors );
100
124
101
125
/**
102
- * This will register beans which are included in {@link Binder}. {@code Binder} can contains all descriptors extending
126
+ * Registers beans which are included in {@link Binder}. {@code Binder} can contains all descriptors extending
103
127
* {@link Binding} or other binders which are installed together in tree-structure. This method will get all descriptors
104
128
* bound in the given binder and register them in the order how the binders are installed together. In the tree structure,
105
129
* the deeper on the left side will be processed first.
@@ -113,20 +137,26 @@ public interface InjectionManager {
113
137
void register (Binder binder );
114
138
115
139
/**
116
- * Register a HK2 Binder.
140
+ * Registers a provider. An implementation of the {@link InjectionManager} should test whether the type of the object can be
141
+ * registered using the method {@link #isRegistrable(Class)}. Then a caller has an certainty that the instance of the tested
142
+ * class can be registered in {@code InjectionManager}. If {@code InjectionManager} is not able to register the provider
143
+ * then {@link IllegalArgumentException} is thrown.
117
144
*
118
- * For compatibility reasons only, to be removed.
145
+ * @param provider object that can be registered in {@code InjectionManager}.
146
+ * @throws IllegalArgumentException provider cannot be registered.
147
+ */
148
+ void register (Object provider );
149
+
150
+ /**
151
+ * Tests whether the provided {@code clazz} can be registered by the implementation of the {@link InjectionManager}.
119
152
*
120
- * @param binder collection of descriptors.
121
- * @see ClassBinding
122
- * @see InstanceBinding
123
- * @see SupplierClassBinding
124
- * @see SupplierInstanceBinding
153
+ * @param clazz type that is tested whether is registrable by the implementation of {@code InjectionManager}.
154
+ * @return {@code true} if the {@code InjectionManager} is able to register this type.
125
155
*/
126
- void register ( org . glassfish . hk2 . utilities . Binder ... binder );
156
+ boolean isRegistrable ( Class <?> clazz );
127
157
128
158
/**
129
- * This method creates , injects and post-constructs an object with the given class. This is equivalent to calling the
159
+ * Creates , injects and post-constructs an object with the given class. This is equivalent to calling the
130
160
* {@code create-class} method followed by the {@code inject-class} method followed by the {@code post-construct} method.
131
161
* <p>
132
162
* The object created is not managed by the injection manager.
@@ -234,7 +264,7 @@ public interface InjectionManager {
234
264
<T > List <T > getAllInstances (Type contractOrImpl );
235
265
236
266
/**
237
- * This will analyze the given object and inject into its fields and methods.
267
+ * Analyzes the given object and inject into its fields and methods.
238
268
* The object injected in this way will not be managed by HK2
239
269
*
240
270
* @param injectMe The object to be analyzed and injected into
@@ -251,7 +281,7 @@ public interface InjectionManager {
251
281
void inject (Object injectMe , String classAnalyzer );
252
282
253
283
/**
254
- * This will analyze the given object and call the preDestroy method. The object given will not be managed by bean manager.
284
+ * Analyzes the given object and call the preDestroy method. The object given will not be managed by bean manager.
255
285
*
256
286
* @param preDestroyMe The object to preDestroy
257
287
*/
0 commit comments