在NB中集成了uflo正常,现在问题是是nutz的注入对象转化为AsSpringBean的问题,在spring4.2.3中:
/**
* 容器初始化时,初始化Spring Mvc的Ioc容器,并放入ServletContext
*/
public void contextInitialized(ServletContextEvent sce) {
applicationContext = new XmlWebApplicationContext();
applicationContext.setServletContext(sce.getServletContext());
applicationContext.setConfigLocation(configLocation);
applicationContext.refresh();
appContext.getComboIocLoader().addLoader(new SpringIocLoader2(applicationContext, getSpringBeanNames().toArray(new String[0])));
sce.getServletContext().setAttribute("spring." + selfName, applicationContext);
// 登记所有标注了@AsSpringBean的对象到spring ioc
Ioc ioc = appContext.getIoc();
for (String name : ioc.getNamesByAnnotation(AsSpringBean.class)) {
applicationContext.getBeanFactory().registerSingleton(name, ioc.get(null, name));
}
}
这个applicationContext.refresh();执行后,uflo中
下面这段代码执行,就是把所有bean转化成spring后缓存起来
@Override
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
handerMap=new HashMap<String,Set<String>>();
handerMap.put(NodeEventHandler.class.getSimpleName(), applicationContext.getBeansOfType(NodeEventHandler.class).keySet());
handerMap.put(ProcessEventHandler.class.getSimpleName(), applicationContext.getBeansOfType(ProcessEventHandler.class).keySet());
handerMap.put(DecisionHandler.class.getSimpleName(), applicationContext.getBeansOfType(DecisionHandler.class).keySet());
handerMap.put(AssignmentHandler.class.getSimpleName(), applicationContext.getBeansOfType(AssignmentHandler.class).keySet());
handerMap.put(ConditionHandler.class.getSimpleName(), applicationContext.getBeansOfType(ConditionHandler.class).keySet());
handerMap.put(ActionHandler.class.getSimpleName(), applicationContext.getBeansOfType(ActionHandler.class).keySet());
handerMap.put(ForeachHandler.class.getSimpleName(), applicationContext.getBeansOfType(ForeachHandler.class).keySet());
handerMap.put(ReminderHandler.class.getSimpleName(), applicationContext.getBeansOfType(ReminderHandler.class).keySet());
handerMap.put(CountersignHandler.class.getSimpleName(), applicationContext.getBeansOfType(CountersignHandler.class).keySet());
handerMap.put(TaskListener.class.getSimpleName(), applicationContext.getBeansOfType(TaskListener.class).keySet());
Set<String> set=new HashSet<String>();
for(FormTemplateProvider provider:applicationContext.getBeansOfType(FormTemplateProvider.class).values()){
set.add(provider.getFormTemplate());
}
handerMap.put(FormTemplateProvider.class.getSimpleName(), set);
}
后面再加入新的bean后:
for (String name : ioc.getNamesByAnnotation(AsSpringBean.class)) {
applicationContext.getBeanFactory().registerSingleton(name, ioc.get(null, name));
}
uflo中这个缓存方法没有再执行,导致nutz注入转化的bean在uflo中找不到!看这个问题是否是我的理解错误还是可以调整下