Returning Singleton beans depending on input in Spring
Clash Royale CLAN TAG #URR8PPP Returning Singleton beans depending on input in Spring Let's say I have the following: @Component @NoArgsConstructor public class ToolFactory { public Tool getTool(String type) { return StaticToolProvider.getTool(type); } } If the tools can be screwdriver, hammer, or wrench, I want Spring to create Singleton beans for each, and return them when getTool() is called. I believe @Provides @Singleton would do this in Guice, but how could I do it here? getTool() @Provides @Singleton give details. what you want to do – sajib 6 mins ago I will only ever return a screwdriver, hammer, or wrench, but I don't want new prototype beans returned for every call. I only want 3 beans to only ever be created, but I want them created as getTool() is called, or the existing Si...