5555public interface InjectionManager {
5656
5757 /**
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
5959 * 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.
6161 *
6262 * @param name Name of the injection manager.
6363 * @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 {
6868 void initialize (String name , Object parent , Binder ... binders );
6969
7070 /**
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.
7296 */
7397 void shutdown ();
7498
7599 /**
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
77101 * factory object which will create the bean at the time of injection. {@code InjectionManager} is able to register a bean
78102 * represented by a class or direct instance.
79103 *
@@ -86,7 +110,7 @@ public interface InjectionManager {
86110 void register (Binding binding );
87111
88112 /**
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
90114 * direct bean or factory object which will create the bean at the time of injection. {@code InjectionManager} is able to
91115 * register a bean represented by a class or direct instance.
92116 *
@@ -99,7 +123,7 @@ public interface InjectionManager {
99123 void register (Iterable <Binding > descriptors );
100124
101125 /**
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
103127 * {@link Binding} or other binders which are installed together in tree-structure. This method will get all descriptors
104128 * bound in the given binder and register them in the order how the binders are installed together. In the tree structure,
105129 * the deeper on the left side will be processed first.
@@ -113,20 +137,26 @@ public interface InjectionManager {
113137 void register (Binder binder );
114138
115139 /**
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.
117144 *
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}.
119152 *
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.
125155 */
126- void register ( org . glassfish . hk2 . utilities . Binder ... binder );
156+ boolean isRegistrable ( Class <?> clazz );
127157
128158 /**
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
130160 * {@code create-class} method followed by the {@code inject-class} method followed by the {@code post-construct} method.
131161 * <p>
132162 * The object created is not managed by the injection manager.
@@ -234,7 +264,7 @@ public interface InjectionManager {
234264 <T > List <T > getAllInstances (Type contractOrImpl );
235265
236266 /**
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.
238268 * The object injected in this way will not be managed by HK2
239269 *
240270 * @param injectMe The object to be analyzed and injected into
@@ -251,7 +281,7 @@ public interface InjectionManager {
251281 void inject (Object injectMe , String classAnalyzer );
252282
253283 /**
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.
255285 *
256286 * @param preDestroyMe The object to preDestroy
257287 */
0 commit comments