咖啡兔流程执行逻辑分析



1,如:前台页面:流程管理->模型工作区菜单:
请求url:/workflow/model/list
web容器根据"/workflow/model/list"路径映射到DispatcherServlet(url-pattern为"/workflow/model/")进行处理

2,DispatcherServlet将"/workflow/model"路径映射到名字为"/workflow/model"的Bean进行处理,即ModelController,
package me.kafeitu.demo.activiti.web.workflow;

import java.io.ByteArrayInputStream;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;
import org.activiti.bpmn.converter.BpmnXMLConverter;
import org.activiti.bpmn.model.BpmnModel;
import org.activiti.editor.constants.ModelDataJsonConstants;
import org.activiti.editor.language.json.converter.BpmnJsonConverter;
import org.activiti.engine.RepositoryService;
import org.activiti.engine.repository.Deployment;
import org.activiti.engine.repository.Model;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;

/**
 * 流程模型控制器
 *
 * @author henryyan
 */
@Controller
@RequestMapping(value = "/workflow/model")
public class ModelController {

    protected Logger logger = LoggerFactory.getLogger(getClass());

    @Autowired
    RepositoryService repositoryService;

    /**
     * 模型列表
     */
    @RequestMapping(value = "list")
    public ModelAndView modelList() {
        ModelAndView mav = new ModelAndView("workflow/model-list");
        List list = repositoryService.createModelQuery().list();
        mav.addObject("list", list);
        return mav;
    }

3,Model(ModelAndView的逻辑视图名)的list方法处理后,返回一个ModelAndView给DispatcherServlet,对应到具体页面/WEB-INF/views/workflow/model-list.jsp

4,Jst1View(/WEB-INF/views/workflow/model-list.jsp)将页面渲染,将传入的模型数据list在视图中展示出来;

5,返回控制权给DispatcherServlet,由DispatcherServlet返回响应给用户,完成一个请求;




你可能感兴趣的:(javaweb)