java service 服务_Java 服务任务(Java Service Task)

Java 服务任务(

java service task

)

描述

Java 服务任务是用于调用一个外部

Java

类。

图形符号

A service task is visualized as a rounded rectangle with a small gear icon in the top-left corner.

脚本任务的图形表示是在一个圆边矩形的左上角标一个齿轮图标。

XML表示

There are 4 ways of declaring how to invoke Java logic:

l

Specifying a class that implements JavaDelegate or ActivityBehavior

l

Evaluating an expression that resolves to a delegation object

l

Invoking a method expression

l

Evaluating a value expression

有以下四种调用Java

的声明方法

l

实现JavaDelegate

ActivitiBehavior

l

计算一个表达式用于解析一个授权对象

l

调用方法表达式

l

评估值表达式

To specify a class that is called during process execution, the fully qualified classname needs to be provided by the

'activiti:class'

attribute.

为了可以在流程运行调用类,需要用‘activiti:class

’属性指定一个全限定性类名。

See

for more details on how to use such a class.

It is also possible to use an expression that resolves to an object. This object must follow the same rules as objects that are created when the activiti:class attribute is used (see

).

有关如何使用这个类的详情请参阅 实现部分

也可以用一个表达式解析一个对象,当用属性activiti:class

解析对象时这个对象必须遵循对象产生的相同的规则。

Here, the delegateExpressionBean is a bean that implements the JavaDelegate interface, defined in for example the Spring container.

这里,

delegateExpressionBean

是一个实现了

JavaDelegate

接口,定义在

spring容器中的对象。

To specify a UEL method expression that should be evaluated, use attribute

activiti:expression

.

指定一个UEL

方法返回一个对象,用

activiti:expression

属性:

Method printMessage (without parameters) will be called on the named object called printer.

It's also possible to pass parameters with an method used in the expression.

Printer对象的

printMessage

方法会被调用。

也可以给表达式中的方法传递参数。

name="My Java Service Task"

activiti:expression="#{printer.printMessage(execution, myVar)}" />

Method printMessage will be called on the object named printer. The first parameter passed is the DelegateExecution, which is available in the expression context by default available as execution. The second parameter passed, is the value of the variable with name myVar in the current execution.

Printer的

printMessage()

方法将会被调用。第一个参数传递的是

DelegateExecution

类,它可以在表达式上下文得到。第二参数是在当前运行上下文中的变量

myVar

的值。

To specify a UEL value expression that should be evaluated, use attribute

activiti:expression

.

可以用activiti:expression

去指定一个

UEL

值表达式。

name="My Java Service Task"

activiti:expression="#{split.ready}" />

The getter method of property ready, getReady (without parameters), will be called on the named bean called split. The named objects are resolved in the execution's process variables and (if applicable) in the Spring context.

Split对象的

getReady()

方法将被调用,对象位于可以是运行的流程变量,也可以是

Spring

容器中的

bean

实现(Implementation)

To implement a class that can be called during process execution, this class needs to implement the

org.activiti.engine.delegate.JavaDelegate

interface and provide the required logic in the

execute

method. When process execution arrives at this particular step, it will execute this logic defined in that method and leave the activity in the default BPMN 2.0 way.

为了类可以在流程运行中被调用,这个类需要实现

org.activiti.engine.delegate.JavaDelegate

接口并且在

execute方法中提供所需的逻辑。当流程运行到达这个特殊的一步时,定义在方法中的逻辑将会被执行,之后以默认的

BPMN 2.0

方式退出。

Let's create for example a Java class that can be used to change a process variable String to uppercase.

This class needs to implement the

org.activiti.engine.delegate.JavaDelegate

interface,

which requires us to implement the

execute(DelegateExecution)

method.

It's this operation that will be called by the engine and which needs to contain the business logic.

Process instance information such as process variables and other can be accessed and manipulated

through the

interface (click on the link for a detailed Javadoc of its operations).

分享到:

18e900b8666ce6f233d25ec02f95ee59.png

72dd548719f0ace4d5f9bca64e1d7715.png

2012-10-31 10:52

浏览 3814

评论

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值