Jakarta CDI - Two "Singletons" of the same class
I'm new to injection frameworks. And my question is a contradiction in itself, but - hypothetically - is it possible to have CDI inject exactly 2 different instances of the same class throughout my code? Two singletons of one class so to speak? And if yes, what would the annotations look like? Producing two different @Named instances with @Produces methods? ---- edit ---- Here is what I came up with: @Singleton public final class StartupBean { @Inject StartupBean(SomeManager someManager) { // nothing happening here } @Produces @Named("fooObject") public MyImplementation produceFooObject() { re
0 upvotes
View original discussion ↗
Comments
Sign in or sign up to comment and upvote.
No comments yet.