tapestry activiti开发笔记

开发环境的准备:

eclipse: kapler

plugin: http://activiti.org/designer/update/

tapestry-activiti-0.0.1

tapestry-core: 5.4-beta-6

database:mysql5.5.29

activiti : 5.15.1

<dependency>
            <groupId>org.activiti</groupId>
            <artifactId>activiti-engine</artifactId>
            <version>5.15.1</version>
</dependency>
 <dependency>
            <groupId>org.codehaus.groovy</groupId>
            <artifactId>groovy-all</artifactId>
            <version>2.2.1</version>
  </dependency>

注解:因为tapestry-ioc-5.4和tapestry-activiti-0.0.1不兼容,所以参照重写自己的模块。

环境移置成功,直接copy源码,然后进行修正。 创建的数据库用activiti的下面脚本:

  1. activiti.mysql.create.identity.sql

  2. activiti.mysql55.create.engine.sql

  3. activiti.mysql55.create.history.sql

---------------------------------------------------------------------

使用注意点:

1)各个Service都是线程安全的,在自己框架中集成的时候可以做成单例模式

     在tapestry中,可以通过buildService的方式,最终通过依赖注入来管理各个Service。




需要解决的问题:

1)和业务表的关联及业务数据的保存

2)事务的控制

3)参数的传递

     参数在传递过程中,必须是可以系列化的(Serializable),否则activiti不给保存。(痛苦过)

     参数在各个task之间进行传递,task和processInstance之间的共享问题,范围问题,待查。

     process scope:

           作用:

           弊端:

     task scope :

          作用:

          弊端:

4)流程图当前状态的显示

 tapestry中显示成功,

待解决的问题点。

  • 图片中的标题内容部分丢失。

       如果在发布的时候,没有发布原始的流程图片,engine自动支持自动生成图片的功能?,这个会丢失内容。

       如果发布的时候也发布图片(deploy),一切显示正常。(不知道Activiti如何进行管理图片的

      自动生成图片功能,需要配置:

ProcessEngineConfiguration.setCreateDiagramOnDeploy(true);
本以为true的话,流程图显示出来后,能突出显示当前状态为Active的task(变红,获得焦点),但没有,需调查。


  • 突出显示流程图中当前task。

@Inject
private RepositoryService repositoryService;

public StreamResponse onChart() {
    return new StreamResponse() {
        public String getContentType() {
            return "image/png";
        }
        public InputStream getStream() throws IOException {
            try {
                ProcessDefinition processDefinition = repositoryService
                        .createProcessDefinitionQuery()
                        .processDefinitionKey("vacationRequest").singleResult();
                String diagramResourceName = processDefinition.getDiagramResourceName();
                return repositoryService.getResourceAsStream(
                    processDefinition.getDeploymentId(),
                    diagramResourceName);
            } catch (Exception ex) {
                throw new RuntimeException("Cannot read image file.", ex);
            }
        }
        public void prepareResponse(Response response) {
        }
    };
}

#tapestry的template文件中
<div>
    <img src="${chart}"/>
</div>

----------------------------------------------------------------------

RepositoryService的功能
1)发布ProcessDefinition到Activiti中,实际是存储到数据库中,同一个定义,有多个版本。

2)删除已经发布的ProcessDefinition。

3)发布流程对应的图片资源。


你可能感兴趣的:(tapestry activiti开发笔记)