I have the following class:
@Configuration
public class ActionsConfig {
private Map<ObjectType, List<Action>> map = new HashMap<>();
@Bean
public Action1 action1() {
return new Action1();
}
@Bean
public Action2 action2(){
return new Action2();
}
@Bean
public Action3 action3(){
return new Action3();
}
private void fillMap(){
//here I am filling my map
}
public Map<ObjectType, List<Action>> getMap(){
return this.map;
}
}
The classes Action1
, Action2
and Action3
implements a common Action
interface.
Than, inside my service, I autowire the ActionsConfig
class and get the map.
@Service
public class BasketService {
@Autowired
private ActionsConfig actionsConfig;
...
public void doSomething(){
...
actionsConfig.getMap()...
...
}
}
Is there a way to autowire just the map, and hence to use the values inside the map directly?