osworkflow api 之 util

 

com.opensymphony.workflow.util

 

Interfaces 

Validatable

public void validate() throws InvalidWorkflowDescriptorException;

WorkflowListener

public void stateChanged(WorkflowEntry entry) throws RemoteException, WorkflowException;

WorkflowLocalListener

public void stateChanged(WorkflowEntry entry) throws WorkflowException;

XMLizable

    public static final String INDENT = "  ";

 

    //~ Methods

 

    public void writeXML(PrintWriter writer, int indent);

大致可以看得出,最后这个接口是用来写xml的,indent代表缩进量。

我真服气作者写注释这方面了,不管api还是源码上注释真少。里面就一个小例子,好多功能标签也没用过,带一大堆测试case,又不把jar包弄全。哎!是不是灵活就都这样啊!其实好多都看不懂!我faint

Classes

AllowOwnerOfStepCondition

这个类实现Condition接口。包含一个方法passesCondition* Checks owner of "stepId" in args and compares to current user

大致是做这样的事情:

1、  获取stepid

2、  通过workflowstore寻找findHistorySteps

3、  hisotrystep中找与上面的获得到的stepid想匹配的项,

 if (((step.getOwner() != null) && (context.getCaller() != null)) && context.getCaller().equals(step.getOwner())) {

                return true;

}

 上面的step指的是historysteps中的某一个(通过iterator获得),而context是通过WorkflowContext context = (WorkflowContext) transientVars.get("context");获得到的,两者进行比较,来返回boolean

AllowOwnerOnlyCondition这个类实现Condition接口。包含一个方法passesCondition

大致做这样的事情:

 

AllowOwnerOfStepCondition一样。

* Simple utility condition that returns true if the owner is the caller. Looks at

ALL current steps unless a stepId is given in the optional argument "stepId".

1、  获取stepid

2、  WorkflowContext context = (WorkflowContext) transientVars.get("context");

WorkflowEntry entry = (WorkflowEntry) transientVars.get("entry");

WorkflowStore store = (WorkflowStore) transientVars.get("store");

List currentSteps = store.findCurrentSteps(entry.getId());可以看出这里获取的是当前的step,上面的类获取的history的。

3、  stepid=0和!=0两种情况。

4、  if ((step.getOwner() != null) && context.getCaller().equals(step.getOwner())) {

                    return true;

  }

判断ownercaller是否一致。

如在例子程序中在stepid1的情况下这样使用的:

<condition type="class">

<arg name="class.name">com.opensymphony.workflow.util.AllowOwnerOnlyCondition</arg>

</condition>

DenyOwnerCondition

* Simple utility condition that returns false if the owner is the caller. Looks at

ALL current steps unless a stepId is given in the optional argument "stepId".

实现接口和方法与上同。

可以很好理解,这个就不多说了。

OSUserGroupCondition

* Simple utility class that uses OSUser to determine if the caller is in

the required argument "group".

实现接口和方法与上同。

这个类是用来判断caller是否在参数设置的group中的。

里面代码很简单。

StatusCondition

* Simple utility condition that returns true if the current step's status is

 * the same as the required argument "status". Looks at ALL current steps unless

a stepId is given in the optional argument "stepId".

实现接口和方法与上同。

判断当前的stepstatus是否与需要要求的status一致。

其他细节略,代码很好懂。

MostRecentOwner

 

实现FunctionProvider接口,包含一个execute方法。

1、  String stepIdString = (String) args.get("stepId");先从参数列表获得stepidstring,这是一个以“,”分隔的字符串。下面以一个变量名为stepidslist进行存储此stepidstring

2、  WorkflowStore store = (WorkflowStore) transientVars.get("store");

List historySteps = store.findHistorySteps(entry.getId());

3、  historySteps中进行迭代处理

4、  if (stepIds.contains(String.valueOf(step.getStepId())) && TextUtils.stringSet(step.getOwner())) {

                transientVars.put("mostRecentOwner", step.getOwner());

 

               break;

            }

这部分功能主要是判断stepids是否包含historysteps中的某一个。而TextUtilsoscore这个jar包的代码,暂时还没下源码(只能通过cvs获得),我试过,但是,没成功。

 

Caller

实现FunctionProvider接口,包含一个execute方法。

    public void execute(Map transientVars, Map args, PropertySet ps) {

        WorkflowContext context = (WorkflowContext) transientVars.get("context");

        transientVars.put("caller", context.getCaller());

    }

这个没什么讲的,就是把供以后调用的caller

EJBInvoker

JMSMessage

LogRegisters

实现Register接口,包含registerVariable方法

在内部通过osworkflow+”.”+workflowname+”.”+”workflowid”作为参数传递给logfacotry。最终是由commons.logging.logfactory产生log对象返回。

ScheduleJob

这个类在上面的timer的时候提到过的。

它实现FunctionProvider

ScheduleJob是一个FunctionProiver,因此具有execute方法。在该方法执行期间,ScheduleJob将会读取这些配置参数,创建好job实例(实际上是一个JobDetail实例)和trigger实例,然后启动schedule

主要作用就是在一个quartzschedule一个job在未来一段时间内执行一或多次。下面这些参数是必须具备的:

* <ul>

 *  <li> triggerId - the id of the trigger function defined in the XML workflow

 *  <li> jobName - the name to be given to the job

 *  <li> triggerName - the name to be given to the trigger

 *  <li> groupName - the group given to both the job and the trigger

* </ul>

下面这些参数是可选的:

<ul>

 *  <li> username – 用来在未来时间内执行function的系统帐户,如果这个值没有指定那么将会从WorkflowContext.getCaller()中取得值来使用。

 *  <li> password – 系统帐户的密码。

 *  <li> local – 如果设置为true,一个LocalWorkflowJob 生效,否则就是需要具备soap支持了。不设置此项即WorkflowJob

*  <li> jobClass – 实现job 的类,在没有指定的情况下默认是WorkflowJob ,如果localtrue,则默认为LocalWorkflowJob

*  <li>schedulerName – 一个已存在的scheduler的名字

 *  <li>schdulerStart – 如果设置为true,则如果它还没启动则自动启动。

 *  <li>txHack –如果在运行事务之时你得到锁,设置此为true 默认为false

* </ul>

如果你想使用一个cron trigger,下面这些就是必须的了。

* <ul>

 *  <li> cronExpression – 如名

 * </ul>

如果只是使用一个简单的trigger,下面这些是可选的。

* <ul>

*  <li> startOffset – 从现在的时间开始的偏移量,以ms(毫秒)为单位,默认是0

*  <li> endOffset -从现在的时间开始的偏移量,以ms(毫秒)为单位,默认是无限大。

 *  <li> repeat – 重复次数。默认为0,可以设置为REPEAT_INDEFINITELY

 *  <li> repeatDelay – 在各个repeats之间的时间间隔。默认是0

 * </ul>

这个类的作用就是根据上面设置的这些参数进行调度job

 

UnscheduleJob

* Unschedules a job that was scheduled previously. Accepts the following arguments:

 *Unschedule一个job(预先scheduled过的。)接受下面这些参数。

 * <ul>

 *  <li>triggerName – 先前scheduled过的trigger name

 *  <li>groupName - 先前scheduled过的group name

 *  <li>schedulerName – 已存的scheduler的名字。(可选)

 *  <li>txHack – 可选,默认false

 * </ul>

 

 

ScriptVariableParser

这个类作用就是解析带有“.”的表达式 ${caller}这样表达式的。将其中的变量取出来返回。

 

SendEmail

实现FunctionProvider。发送邮件类。

WebWorkExecutor

实现FunctionProvider,执行WebWork功能,当老的actioncontext处于finished时候进行restore。进行如下转换过程:

* <ul>

 *  <li>inputs -> ActionContext#parameters</li>

 *  <li>variables -> ActionContext#session</li>

 *  <li>args -> ActionContext#application</li>

*</ul>

* <ul>

 *  <li><b>action.name</b> - the actionName to ask from the ActionFactory</li>

 * </ul>

这部分没弄明白。

WebWorkValidator

实现Validator

WorkflowStateHelper

只有一个getPossibleStates方法,获取当前state的可能下一状态,如created的下一状态则提示为activated

XWorkExecutor

执行一个Xworkfunction

* <ul>

 *  <li>inputs -> ActionContext#parameters</li>

 *  <li>variables -> ActionContext#session</li>

 *  <li>args -> ActionContext#application</li>

 * </ul>

 * <p>

 *

 * <ul>

 *  <li><b>action.name</b> - the actionName to ask from the ActionProxy</li>

 *  <li><b>namespace</b> - the namespace to ask from the ActionProxy</li>

 * </ul>

 

没弄懂。

 

 欢迎大家教我不会的,互相学习。yun15291li@hotmail.com

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值