NutzCN Logo
问答 activit的流程引擎bean管理
发布于 2327天前 作者 tanoak10 1587 次浏览 复制 上一个帖子 下一个帖子
标签: nutzwk

processEngineConfiguration 完了之后好像没有放到IOC里面管理

    private void initActiviti(NutConfig config) {
        log.info("Activiti Init Start...");
        ProcessEngineConfigurationImpl processEngineConfiguration = config.getIoc().get(null, "processEngineSpec");

        // 使用系统角色及用户替换工作流的用户及用户组
        List<SessionFactory> list = new ArrayList<>();
        CustomGroupEntityManagerFactory customGroupManagerFactory = new CustomGroupEntityManagerFactory();
        customGroupManagerFactory.setGroupEntityManager(new CustomGroupEntityManager());
        CustomUserEntityManagerFactory customUserEntityManagerFactory = new CustomUserEntityManagerFactory();
        customUserEntityManagerFactory.setUserEntityManager(new CustomUserEntityManager());
        list.add(customGroupManagerFactory);
        list.add(customUserEntityManagerFactory);
        processEngineConfiguration.setCustomSessionFactories(list);
        //添加任务监听

        Map<Object, Object> beans = new HashMap<>();
        ProxyTaskListener proxyTaskListener = new ProxyTaskListener();
        List<TaskListener> taskListeners = new ArrayList<>();
        TaskCategoryTaskListener t1 = new TaskCategoryTaskListener();
        taskListeners.add(t1);
        proxyTaskListener.setTaskListeners(taskListeners);
        beans.put("customTaskListener", proxyTaskListener);
        processEngineConfiguration.setBeans(beans);
        List<BpmnParseHandler> customDefaultBpmnParseHandlers = new ArrayList<>();
        ProxyUserTaskBpmnParseHandler bpmnParseHandler = new ProxyUserTaskBpmnParseHandler();
        bpmnParseHandler.setUseDefaultUserTaskParser(true);
        bpmnParseHandler.setTaskListenerId("customTaskListener");
        customDefaultBpmnParseHandlers.add(bpmnParseHandler);
        processEngineConfiguration.setCustomDefaultBpmnParseHandlers(customDefaultBpmnParseHandlers);
        processEngineConfiguration.setBpmnParser(new CustomBpmnParser());
        //UUID
        processEngineConfiguration.setIdGenerator(new StrongUuidGenerator());

        ProcessEngine processEngine = config.getIoc().get(ProcessEngine.class);
        log.info("Activiti Init End::" + processEngine.getName());

    }
6 回复

Ioc接口有个addBean方法,也许是你需要的东西

没有找到addbean哦,大佬

nutz版本多少

Maven: org.nutz:nutz:1.r.63-SNAPSHOT

版本低了点, 换个写法

((Ioc2)ioc).getIocContext().save("app", "名字", new ObjectProxy(需要代理的对象));
添加回复
请先登陆
回到顶部