我有一个豆子:
public class StatusPollingFilter extends AbstractDiscovery implements UserTester
定义为 :
<bean
id="statusPollingFilter"
class="com.xxxxx.yyyyyyy.zzz.StatusPollingFilter">
<property
name="evoDao"
ref="evoDaoFacade">
</property>
它加载正常,如日志所示:
2013-03-07 11:30:14,703 INFO DefaultListableBeanFactory [RunJSPModule] - Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@14966cc: defining beans [org.springframework.aop.config.internalAutoProxyCreator,org.springframework.transaction.config.internalTransactionAdvisor,tilesConfigurer,viewResolver,urlMapping,discovery,statu
sPollingFilter,
当我尝试将其用作:
TopoObject topoobj = evoDao.getTopoObjectDao().findById(topoId);
evoDao 是完成这项工作的主要人员:类 AbstractDiscovery 为:
//Reference to the DAO facade, for accessing the database via hibernate.
protected EvoTAMDAOFacade evoDao;
问题? 因为我扩展了 AbstractDiscovery,所以我认为我可以访问 evoDao 并像往常一样使用它来获取我的 Dao,但似乎不是——我哪里出错了?为什么找不到道?
EvoTAMDAOFacade 被注入到 AbstractDiscovery 中:
/**
* DI method for accessing the DAO facade for accessing the
* database via hibernate.
* @param dao
*/
public void setEvoDao(EvoTAMDAOFacade dao)
{
this.evoDao = dao;
}
getTopoObjectDao() 在注入的 EvoTAMDAOFacade 中定义为:
public TopoObjectDAO getTopoObjectDao()
{
return this.topoObjectDao;
}
AbstractDiscovery 定义为:
public abstract class AbstractDiscovery implements Discovery
例外是:
[07 Mar 2013 11:42:24:353] POLL: Exception while getting obj during status update java.lang.NullPointerException 162.109.37.114 at:
java.lang.NullPointerException
另一个Q?statusPollFilter 在多个对象的调度程序中作为线程运行 - 我实际上不确定我是否应该将其定义为单例 bean,但如果我不这样做,我如何访问 Dao?
在此先感谢您的帮助。