Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How To Access Spring Bean name?

@Named("myUniqueName") 
public class ReportDashboardDao implements DashboardDAO{ 
//STUFF 
}

how can i access the string inside @Named tag when i am injecting DashboardDAO like this :

@Named
public class DshboardDaoConsumer(){

@Inject List<DashboardDAO> dashboardDAO;
//STUFF
} 
like image 602
MoienGK Avatar asked Dec 15 '22 20:12

MoienGK


1 Answers

Use a Map instead

@Inject 
Map<String, DashboardDao> dashBoardDaos;

This will inject a Map with bean names as keys and daos as values.

Of course, you could also read the annotation value from class instances.

like image 127
Jose Luis Martin Avatar answered Dec 17 '22 09:12

Jose Luis Martin