Activiti User Guide -- Activit 用户指南 Part08

BPMN 2.0 constructs

BPMN 2.0 构件

Custom extensions

自定义扩展

The BPMN 2.0 standard is a good thing for all parties involved. End-users don't suffer from a vendor lock-in that comes by depending on a proprietary solution. Frameworks, and particularly open-source frameworks such as Activiti, can implement a solution that has the same (and often better implemented) features as those of a big vendor. Due to the BPMN 2.0 standard, the transition from such a big vendor solution towards Activiti is an easy and smooth path.

BPMN2.0标准对于每一个参与方都是一个很好的标准。最终用户也不需要绑定某个厂商的私有解决方案。一个框架,特别是开源框架,如Activiti,可以实现同样(通常会更好)和那些大厂商所提供功能。基于BPMN2.0标准,你可以非常容易而且可以平滑的由大厂商所提供的解决方案迁移到Activiti

 

The downside of a standard however, is the fact that it is always the result of many discussions and compromises between different companies (and often visions). As a developer reading the BPMN 2.0 XML of a process definition, sometimes it feels like certain constructs or way to do things are too cumbersome. Since Activiti puts ease of development as a top-priority, we introduced something called the'Activiti BPMN extensions'. These 'extensions' are new constructs or ways to simplify certain constructs, that are not in the BPMN 2.0 specification.

对于标准来说不利的一面那就是,标准通常是厂商之间协商和折中的一种方案(通常是对标准的愿景)。作为一个开发人员阅读BPMN2.0流程定义XML时,经常发现某些构件或做事的方式是很笨重的。因此,Activit把易于开发作为最高优先级,接下来我们会介绍一些被称之为'Activiti BPMN extensions'的东东。这些扩展构件在BPMN2.0标准中是不存在的,它们有些是新的构件,有些是对既有构件的简化。

 

Although the BPMN 2.0 specification clearly states that it was made for custom extension, we make sure that:

尽管BPMN2.0标准明确的表示可以进行自定义扩展,但是我们还是确保:

  • The prerequisite of such a custom extension is that there always must be a simple transformation to the standard way of doing things. So when you decide to use a custom extension, you don't have to be afraid that there is no way back.
  • 自定义扩展的先决条件就是:自定义扩展必须可以经由简单转换就可以使用标准的方法来实现。所以当你觉得了使用了自定义扩展,也不需要担心没有回头路;
  • When using a custom extension, this is always clearly indicated by giving the new XML element, attribute, etc. the activiti:namespace prefix.
  • 当你使用自定义扩展,通常会使用新的XML元素、属性等来清晰的表示这是一个扩展,通常使用activiti:前缀来表示。
  • The goal of these extensions is to eventually push them back into a next version of the BPMN specification, or at least trigger a discussion that can lead to a revision of that specific BPMN construct.
  • 扩展构件的目标是最终是将这些扩展加入下一版本的BPMN标准中,或者至少可以引发关于BPMN下一个版本修订的讨论。

So whether you want to use a custom extension or not, is completely up to you. Several factors will influence this decision (graphical editor usage, company policy, etc.). We only provide them since we believe that some points in the standard can be done simpler or more efficient. Feel free to give us (positive and/or negative) feedback on our extensions, or to post new ideas for custom extensions. Who knows, some day your idea might pop up in the specification!.

使用或者不使用自定义扩展,都完全取决于你。许多因素都会影响你的决定(图形编辑器的用法,公司策略等)。我们只是提供这些自定义扩展,因为我们相信标准在某些方面可以做的更简单一点,更有效率一点。你可以将你使用我们自定义的扩展感受(好的方面/不好的方面)告诉我们,也可以将你的在自定义扩展方面的好的点子告诉我们。谁知道,或许某一天你的点子就会加入到标准中。

Events

事件(Event)

Events are used to model something that happens during the lifetime process. Events are always visualized as a circle. In BPMN 2.0, there exist two main event categories: catching or throwing event.

事件(Event)用来为发生在流程生命周期某些东东进行建模。事件(Event)常常使用圆来表示。在BPMN2.0中存在两类主要事件:catching事件和throwing事件。

  • Catching: when process execution arrives in the event, it will wait for a trigger to happen. The type of trigger is defined by the inner icon or the type declaration in the XML. Catching events are visually differentiated from a throwing event by the inner icon that is not filled (i.e. it is white).
  • Catching: 当流程执行到该类事件时,流程将等待一个触发的发生。触发器的类型通常使用内部图标来表示,或者在XML中声明。Catching事件与throwing事件内部图标是不同的,内部是没有被填充的(也就是说是空白的)。
  • Throwing: when process execution arrives in the event, a trigger is fired. The type of trigger is defined by the inner icon or the type declaration in the XML. Throwing events are visually differentiated from a catching event by the inner icon that is filled with black.
  • Throwing: 当流程执行到该类事件时,就会触发一个触发器。触发器的类型通常使用内部图标来表示,或者在XML中声明。Throwing事件与catching事件内部图标是不同的,内部使用黑色进行填充。

Start events

启动事件

A start event indicates where a process starts. The type of start event (process starts on arrival of message, on specific time intervals, etc.), defining how the process is started is shown as a small icon in the visual representation of the event. In the XML representation, the type is given by the declaration of a sub-element.

一个启动事件表示一个流程的起始点。启动事件的类型(当一个消息到达后启动、在特定时间间隔启动等)定义了流程如何启动,在可视化表示中使用小图标进行区分,在XML表示中使用子元素进行区分。

 

Start events are always catching: conceptually the event is (at any time) waiting until a certain trigger happens.

启动事件就是catching事件:因为事件(总是)等待一个特定的触发器发生。

 

In a start event, following activiti-specific properties can be specified:

对于启动事件,下面列出了可以被赋值的activiti属性:

  • form: references to a form template that users have to fill out to supply the information to start a new process instance. More information can be found in Chapter 8, Task Forms. Example:
  • form:表示一个表单模板,该表单模板在流程启动时可以让用户填写相应的信息。更多的信息可以参考Chapter 8, Task Forms。例如:

 

<startEvent id="request" activiti:form="org/activiti/examples/taskforms/request.form" />
 
  • initiator: identifies the variable name in which the authenticated user id will be stored when the process is started. Example:
  • initiator: 设置一个变量名称,用来存储流程启动者的id。例如:

<startEvent id="request" activiti:initiator="initiator" />
      The authenticated user must be set with the method IdentityService.setAuthenticatedUserId(String) in a try-finally block like this:

使用IdentityService.setAuthenticatedUserId(String)来设置验证用户信息时,必须使用try-finally包围,像下面一样:

try {
  identityService.setAuthenticatedUserId("bono");
  runtimeService.startProcessInstanceByKey("someProcessKey");
} finally {
  identityService.setAuthenticatedUserId(null);
}
 

This code is baked into the Activiti Explorer application. So it works in combination with Chapter 8, Task Forms

这段代码已经整合到Activiti Explorer应用中了。因此它可以和Chapter 8, Task Forms整合使用。

 

None start event

None start event

Description

描述

A 'none' start event technically means that the trigger for starting the process instance is unspecified. This means that the engine cannot anticipate when the process instance must be started. The none start event is used when the process instance is started through the API by calling one of the startProcessInstanceByXXX methods.

None start event 从技术的角度上来讲就是表示触发流程启动的触发器没有被指定。也就是说流程引擎不能够预测到流程实例何时被启动。None start event一般是通过调用startProcessInstanceByXXX  API函数来启动一个流程实例。

ProcessInstance processInstance = runtimeService.startProcessInstanceByXXX();
Note:  a subprocess (currently not yet implemented) always has a none start event.

注意:子流程(现在还没有支持)通常是含有一个none start event

Graphical notation

图形符号

A none start event is visualized as a circle with no inner icon (i.e. no trigger type).

None start event使用一个没有内部图标的圆来表示(也就是说没有指定触发器类型)

 

XML representation

XML 表示

The XML representation of a none start event is the normal start event declaration, without any sub-element (other start event types all have a sub-element declaring the type).

None start evnetXML表示就是普通的start event表示,没有子元素(其他start event都有一个子元素用来表示类型)。

<startEvent id="start" name="my start event" />

 

End events

结束事件

An end event signifies the end (of a path) of a (sub)process. An end event is always throwing. This means that when process execution arrives in the end event, a result is thrown. The type of result is depicted by the inner black icon of the event. In the XML representation, the type is given by the declaration of a sub-element.

一个结束事件通常意味着一个(子)流程结束,或者(子)流程的一个路径结束。结束事件就是一个throwing事件。也就是说当流程执行到一个结束事件时,一个result就会被抛出。result 的类型使用内部黑图标进行表示。在XML中则是通过子元素进行表示。

None end event

None end event

Description

描述

A 'none' end event means that the result thrown when the event is reached is unspecified. As such, the engine will not do anything extra besides ending the current path of execution.

None end event意味着在流程结束时,抛出的result是没有被指定的。也就是说,流程引擎除了把当前执行流程结束掉之外不做任何其它事情。

Graphical notation

图形符号

A none end event is visualized as a circle with a thick border with no inner icon (no result type).

None end event 使用一个厚边框的圆表示,圆内部没有图标(也就是说没有指定result类型)。

 

XML representation

XML 表示

The XML representation of a none end event is the normal end event declaration, without any sub-element (other end event types all have a sub-element declaring the type).

None end eventXML表示就是普通的end eventXML表示,没有子元素(其它end event则包含一个用来指示类型的子元素)。

<!--EndFragment--> family�a;�Z��n�font-family:Arial;color:black; mso-font-kerning:0pt'>的类型使用内部黑图标进行表示。在 XML 中则是通过子元素进行表示。

 

None end event

None end event

Description

描述

A 'none' end event means that the result thrown when the event is reached is unspecified. As such, the engine will not do anything extra besides ending the current path of execution.

None end event意味着在流程结束时,抛出的result是没有被指定的。也就是说,流程引擎除了把当前执行流程结束掉之外不做任何其它事情。

Graphical notation

图形符号

A none end event is visualized as a circle with a thick border with no inner icon (no result type).

None end event 使用一个厚边框的圆表示,圆内部没有图标(也就是说没有指定result类型)。

<endEvent id="end" name="my end event" />
 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
首先,Activity是Android系统中的四大组件之一,可以用于显示View。Activity是一个与用记交互的系统模块,几乎所有的Activity都是和用户进行交互的,但是如果这样就能说Activity主要是用来显示View就不太正确了。 在深入了解Activity之前,我们先要知道一下MVC设计模式,在JAVAEE 中MVC设计模式已经很经典了,而且分的也比较清晰了,但是在Android中,好多人对MVC在Android开发中的应用不是很清楚,下面我就先来介绍一下MVC在Android开发中的应用: M(Model 模型):Model是应用程序的主体部分,所有的业务逻辑都应该写在这里,在Android中Model层与JavaEE中的变化不大,如:对数据库的操作,对网络等的操作都放在该层(但不是说它们都放在同一个包中,可以分开放,但它们统称为Model层)。 V(View 视图):是应用程序中负责生成用户界面的部分,也是在整个MVC架构中用户唯一可以看到的一层,接收用户输入,显示处理结果;在Android应用中一般采用XML文件里德界面的描述,使用的时候可以非常方便的引入,当然也可以使用JavaScript+Html等方式作为View。 C(Controller控制层)android的控制层的重任就要落在众多的activity的肩上了,所以在这里就要建议大家不要在activity中写太多的代码,尽量能过activity交割Model业务逻辑层处理。 好了,在介绍过Android应用开发中的MVC架构后,我们就可以很明确的知道,在Android中Activity主要是用来做控制的,它可以选择要显示的View,也可以从View中获取数据然后把数据传给Model层进行处理,最后再来显示出处理结果。 介绍过Activity的主要作用后,那么我们就要详细说一下Activity了。 Activity生命周期图 Activity 的生命周期是被以下的函数控制的。 public class Activity extends ApplicationContext { protected void onCreate(Bundle icicle); protected void onStart(); protected void onRestart(); protected void onResume(); protected void onFreeze(Bundle outIcicle); protected void onPause(); protected void onStop(); protected void onDestroy(); } onCreate(Bundle) 函数是你进行初始化的地方,这个也是执行 setContentView(View)函数的地方,setContentView(View)函数可以传入一个由XML 编制的UI界面,可以使UI和具体实现完全分离。 onPause()函数是处理用户离开当前 Activity 的地方。更重要的是,任何在当前 Activity中的任何改变都要在这个函数中提交。 Activity有四种状态: 活动状态,当Activity处于Stack(栈)顶时,就是手机当前的现实屏幕,这是 Activity就 处于activity或者运行状态。 运行但是失去焦点,当Activity还处于运行状态时,但是屏幕是有另外一个Activity 处于文档处于焦点状态,当前的Activity就处于pause。 停止,当Activity被另一个Activity完全覆盖的时候,就被停止了,其实就是虽然在 运行,但是用户却看不见。 结束,当Activity处于pause或者stop时,系统可以结束 Activity,回收资源,这 是Activity就是处于结束状态了。 处于结束状态的是Activity,如果要使用户可见,只要重启才可以。 Activity的响应时间 当前Activity所在的线程为主线程,它的响应时间为5秒,如果在当前运行的Activity中进行耗时的操作且响应时间起过5秒,那么程序就会报ANR错误。所以,这也是不建议在Activity中写太多复杂代码的原因之一。 当然,有些代码只能写在Activity中,不然就运行不了(它们不是生命周期方法),比如你想要获得android系统或者硬件一的些信息,就必须在Activity中写出来,如果单独写一个工具类获得不了。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值