Is there a better way to create objects using spring autowiring
or any other design patterns
?
I have 100 different types of events, I am trying to avoid repeating case
statement 100 times.
Is there a better way to create objects using spring autowiring
or any other design patterns
?
I have 100 different types of events, I am trying to avoid repeating case
statement 100 times.
Declare an ApplicationContext:
@Autowired
ApplicationContext context;
Then do an:
EventBean event = (EventBean) context.getBean(eventType);
You will have to name the event beans so the type matches their name.