Example, there is a Task.java object, and I have multiple instances of this object, and I need to store all those for other services to access globally. One possible way I acknowledge is to create a new class of those objects, suppose, Tasks.java
Tasks.java {
Task TaskA,
Task TaskB,
Task TaskC
}
And store this Tasks instance in Global Context. Is there a way we can store multiple instances of the same object in global contexts without creating a new class? One more way might be by using dependency injection in Java which I want to avoid. Or any other different better way to do this?
I have tried:
Contexts.globalContext().register(task);
where task is an instance of Task.java class. I want to store multiple instances of Task in this global Context.
You may want to look at classifier support at https://helidon.io/docs/latest/apidocs/io.helidon.common.context/io/helidon/common/context/Context.html#register(java.lang.Object,T)
Example of using the same at https://github.com/helidon-io/helidon/blob/bef4b1e3f7d11fc27fcbfd79bd326df43ed0bbe[…]xt/src/test/java/io/helidon/common/context/ListContextTest.java