At the moment, we use the @Inject annotation for only singleton classes. This is because the ApplicationContext class only registers singleton classes. These classes are later scanned and have the instances injected, of the objects that use the @Inject annotation.
Proposed Solution:
Have the non-singleton classes be able to use the @Inject annotation to inject the instances of classes that have been registered into the ApplicationContext.
Create a method in the ApplicationContext that will take in the non-singleton object that has the @Inject annotations. This should be part of the constructor of the non-singleton objecct. It should call the method in the ApplicationContext and pass itself as the parameter.
The ApplicationContext will scan this class and inject the instances for the objects using @Inject.
This is an example of how it can be accomplished.
Situation:
At the moment, we use the @Inject annotation for only singleton classes. This is because the ApplicationContext class only registers singleton classes. These classes are later scanned and have the instances injected, of the objects that use the @Inject annotation.
Proposed Solution:
Have the non-singleton classes be able to use the @Inject annotation to inject the instances of classes that have been registered into the ApplicationContext.
Reference:
https://flexion.slack.com/archives/C055XTF22B0/p1688582573819939
Food for Thought:
Create a method in the ApplicationContext that will take in the non-singleton object that has the @Inject annotations. This should be part of the constructor of the non-singleton objecct. It should call the method in the ApplicationContext and pass itself as the parameter. The ApplicationContext will scan this class and inject the instances for the objects using @Inject. This is an example of how it can be accomplished.