Service层注入多个DAO实现的问题
AdminService.class中只有一个setDao方法
public void setDAO(ServiceDAO dao){
this.dao = dao
}
----------------------------------------------------
而我的ServiceDAO接口代码如下
public interface ServiceDAO {
public boolean hasAdmin(Object o);
public void listAllProduct();
public void listAllMessage();
public Object listAllNews();
public boolean publishProduct(Object o);
public boolean publishNews(Object o);
public boolean changeMyPassword(Object o);
public boolean editProduct(Object o);
public boolean editNews(Object o);
public boolean deleteProduct(Object o);
public boolean deleteMessage(Object o );
public boolean deleteNews(Object o );
public Object listProductsByPage(Object o);
public Object showAboutUs();
public boolean editAboutUs(Object o);
public boolean uploadManual(Object o);
}
---------------------------------------------------
包com.dao.impl有以下实现类
AdminLog.class
ChangePassword.class
DeleteMessage.class
..................
等等
---------------------------------------------------
那我要在Service层注入所有DAO的实现类时候应该怎么注入呢?
难道我要在service层上面定义多个dao实现。
然后在各自的setter方法上面加上
@Resource("dao1")
public void setDAO1(AdminLog dao1){
this.dao1 = dao1;
}
@Resource("dao2")
public void setDAO2(ChangePassword dao2){
this.dao2 = dao2;
}
------------------------------------------
这样就一点都没有灵活性了啊。。我是初次整合。。所以想请教大家。
详细指点一下我。谢谢哈
------解决方案--------------------
要注入几个Dao就写相关的几个set方法