论坛首页 Java企业应用论坛

针对iMatrix平台流程引擎事件处理之业务补偿分析

浏览 1832 次
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
作者 正文
   发表时间:2013-07-29   最后修改:2013-07-29

 

前面已经介绍了办理人设置和表单字段权限的原理,下面再看看iMatrix平台是怎样处理事件的?

 

流程属性中的业务补偿:

 

 

自己认为业务补偿也是属于事件的。

 

1 xml中的配置

 

<process … … … …>

 

… … … …

 

<extend>

 

… … … …

 

<expiation-setting>

 

      <set-type>http</set-type>

 

      <delete-instance>

 

/expense-report/delete-instance-expiation.htm

 

</delete-instance>

 

      <cancel-instance>

 

/expense-report/cancel-instance-expiation.htm

 

</cancel-instance>

 

      <task-jump>/expense-report/task-jump-expiation.htm</task-jump>

 

      <pause-instance/>

 

      <continue-instance/>

 

      <goback-task/>

 

    </expiation-setting>

 

</extend>

 

… … … …

 

</process>

 

任务退回配置的是spring bean名称,该bean需要实现的接口为com.norteksoft.wf.engine.client. ReturnTaskInterface。当在流程监控中删除、取消、暂停、继续实例时,做法基本一致,如下:

 

首先获得xml中配置的请求方式和请求的url;当请求方式是HTTP方式时,使用httpclient请求url;当请求方式是RESTful方式时,使用的是JerseyClient请求的。

 

WebUtil.java中的两种请求方式实现如下:

 

/**

 

     * 普通的http请求

 

     * @param url

 

     */

 

    publicstaticvoid getHttpConnection(String url,Long companyId,Long entityId,String systemCode){

 

       String resultUrl=SystemUrls.getBusinessPath(systemCode);

 

       if(PropUtils.isBasicSystem(resultUrl)){

 

           resultUrl = SystemUrls.getSystemUrl("imatrix");

 

       }

 

       log.info(" == system url : ["+resultUrl+"] == ");

 

       resultUrl = resultUrl + url+"?companyId="+companyId+"&entityId="+entityId;

 

       log.info(" == restlet url : ["+resultUrl+"] == ");

 

       HttpGet httpget = new HttpGet(resultUrl);

 

       HttpClient httpclient = new DefaultHttpClient();

 

       ResponseHandler<String> responseHandler = new BasicResponseHandler();

 

       try {

 

           httpclient.execute(httpget, responseHandler);

 

       } catch (ClientProtocolException e) {

 

           e.printStackTrace();

 

       } catch (IOException e) {

 

           e.printStackTrace();

 

       }

 

       httpclient.getConnectionManager().shutdown();

 

    }

 

 

 

/**

 

     * RESTful请求

 

     * @param url

 

     * @param companyId

 

     */

 

    publicstaticvoid restful(String url,Long companyId,Long entityId,String systemCode){

 

       ClientConfig config = new DefaultClientConfig();

 

       Client client = Client.create(config);

 

       String resultUrl = SystemUrls.getSystemUrl(systemCode);

 

       if(PropUtils.isBasicSystem(resultUrl)){

 

           resultUrl = SystemUrls.getSystemUrl("imatrix");

 

       }

 

       log.info(" == system url : ["+resultUrl+"] == ");

 

       resultUrl = resultUrl + url;

 

       log.info(" == restlet url : ["+resultUrl+"] == ");

 

       WebResource service = client.resource(resultUrl);

 

       ClientResponse cr = service

 

       .entity("companyId="+companyId+"&entityId="+entityId, MEDIA_TYPE)

 

       .accept(MEDIA_TYPE)

 

       .post(ClientResponse.class);

 

       if(cr != null) log.info(" =========== RESTful execute result : ["+cr.getEntity(String.class)+"] =========== ");

 

    }

 

 

 

  • 大小: 115 KB
论坛首页 Java企业应用版

跳转论坛:
Global site tag (gtag.js) - Google Analytics