I have a list of gaming rooms which is created by Spring. Each rooms corresponds some rules (which is enum), and the code is:
@Bean
List<Room> rooms() {
return Arrays.stream(Rules.values())
.map(rule -> new Room(rule))
.collect(Collectors.toList());
}
But now I need the rooms to be @Beans
too: I want Spring to process @EventListener
annotation in them. However, I don't want to declare them manually in config as the Rules
enum can be updated in the future. How can I solve this problem? Thanks.