Actiiviti业务流程引擎:扩展REST API

时间:2016-10-12 08:01:05

标签: java-ee activiti

我想创建一些新的REST资源。例如,列出工作流程中的所有下一个可能任务。

我想创建自己的战争,可以部署在Glassfish 4中。(payara)。

我需要什么样的代表?如何创建新的端点网址?

3 个答案:

答案 0 :(得分:0)

Activiti REST应用程序是使用Spring MVC编写的。默认情况下,org.activiti.rest.service.api是组件扫描的(参见https://github.com/Activiti/Activiti/blob/master/modules/activiti-rest/src/test/java/org/activiti/rest/DispatcherServletConfiguration.java#L25)。

因此,如果您将自定义类与适当的Spring MVC注释放在同一个包中,那么您就拥有了一个自定义端点,您可以在其中实现所需的内容。

没有必要为此更改war文件,您只需确保新类位于应用程序的类路径中。

答案 1 :(得分:0)

Activiti 只是一个jar,社区提供了很多API来解决它。但你可以使用Spring在activiti周围编写自己的逻辑。基本上它使用DB来处理/转移任何其他工作流程所做的状态。所以首先提供一个DB并在其中填充必要的模式/表。接下来选择你的UI(我强烈推荐AngularJS是最近使用过的框架之一)。将您的架构定义为您的UI与Activiti交互的方式。要注意,它会花费很多时间

答案 2 :(得分:0)

Rangalo,

以下是您的Rest端点示例。

package com.bp3.tupac.rest;

import com.bp3.tupac.service.ServiceException;
import com.bp3.tupac.service.InfoService;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping(value = "/tupac")
public class VersionRestController {

    /**
     * @return Some stuff
     * @throws ServiceException
     */
    @RequestMapping(value = "/info",
        produces = MediaType.APPLICATION_JSON_VALUE,
        method = RequestMethod.GET
    )
    public InfoService.Info getTupacInfo() throws ServiceException {
        try {
            return new InfoService().getTupacInfo();
        } catch (Exception e) {
            throw new ServiceException("Failure getting Tupac info....dog", e);
        }
    }
}

现在,您需要确保应用程序配置已设置为在组件扫描中包含此程序包。 为此,请将包添加到DispatcherServletConfiguration类中的组件扫描指令。

@Configuration
@ComponentScan(existing packages, "com.bp3.tupac.rest"})

之后,您应该可以调用路径:http://host:port/context/tupac/info

找出谁杀了图帕克。

希望这会有所帮助。 格雷格

相关问题