I have a abstract class AbstractService
which has a reference to AbstractDAO
class AbstractService{
protected AbstractDAO abstractDAO;
}
AbstractService
will be extended by actual service classes like ServiceClassA
, ServiceClassB
etc,
and AbstractDAO
will be extended by DaoClassA
, DaoClassB
etc.
Depending upon which class is extending AbstractService
, abstractDAO
should be an instance of DaoClassA
, DaoClassB
etc
I can achieve this by having the abstractDAO setter in the extending class like
class ServiceClassA{
@Autowired
@Qualifier("daoClassA")
public void setAbstractDAO(AbstractDAO abstractDAO) {
super.abstractDAO = abstractDAO;
}
}
Is there any way to have the setter setAbstractDAO
in AbstractService
class itself
and abstractDAO
gets Autowired depending upon the subclass maybe wth SPEL+Qualifier etc
We dont want to use any XML configuration for this