command模式结合Spring ApplicationContextAWare接口获取ApplicationContext上下文

@Service("commandFactory")
public class CommandFactory implements ICommandFactory,ApplicationContextAware  {
 
private ApplicationContext applicationContext;
//private static Logger logger = LoggerFactory.getLogger(CommandFactory.class); 
/** 
* 功能描述:默认构造函数CommandFactory,
*/
public CommandFactory() {}
/** 
* 功能描述: 核心工厂返回真正的接口实例对象
* @method:getCommandTaskType
* @param huoguObject
* @return:IMiniAdviceService
*/
public IMiniAdviceService getCommandTaskType(HuoguObject huoguObject){
return (IMiniAdviceService) applicationContext.getBean(huoguObject.getTaskType());
}
@Override
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
this.applicationContext = applicationContext;
}
 
public ApplicationContext getApplicationContext() {
return applicationContext;
}
}
相关文章
相关标签/搜索