Function in OSWORKFLOW [original]

xiaoxiao2021-03-06  68

Second, the function in the workflow

OsWorkflow supports the following functions:

1. Java-based functions (based on Java-based function)

Java-based functions must be implemented in a com.opensymphony.workflow.functionProvider interface. This interface has only one function --execute, this function has three parameters

--Transientvars Map

TransientVars Map: It is called when the client code calls workflow.doAction (). This parameter can make functions of different behavior based on different inputs of users.

This parameter also contains some special variables, which is very helpful for access to Workflow. It also contains all the variables configured in Registers and the following two special variables: entry (com.opensymphony.workflow.spi.workflowntry) and context (com.opensymphony.workflow.workflowcontext).

--The Args Map

ARGS Map is a MAP of the tag included in all tags. These parameters are String types. This means that this is $ {somevar} The parameters defined in the tag will be mapped to "this is [contents of somevar] string in the Arg Map. .

--Propertyset

The propertyset contains all persistent variables in the Workflow instance.

Java-based function is suitable for the following types:

(1) Class

For a class of functions, the class loader must know the name of the class to which your function belongs. This can be accomplished by class.name parameters:

com.acme.foofunction

The message is $ {message}

(2) JNDI

JNDI functions are like classifiers. The only difference between JNDI functions must be existed in the JNDI tree, here you need JNDI.Location parameters:

java: / foofunction

The message is $ {message}

(3) Remote-EJB

Remote EJBS can be used as a function in OSWORKFLOW. EJB's remote interface must expand com.opensymphony.workflow.functionProviderRemote, here you need EJB.Location parameters:

java: / comp / env / fooejb

The message is $ {message}

(4) Local-EJB

The local EJBS is different from the remote EJBS that local EJBS is to expand the com.opensymphony.workflow.functionProvider interface, for example:

java: / comp / env / fooejb

The message is $ {message}

2. Beanshell Functions

OsWorkflow supports Beanshell as a scripting language. To http://www.beanshell.org/, you can get more beanshell information.

The type of Beanshell function must be specified as beanshell, but also a parameter, the name is Script. The value of this parameter is actually the Script to be executed, for example:

System.out.println ("Hello, World!");

There is always three variables, entry, context, and store in the expression. The Entry variable is an object that implements the com.opensymphony.workflow.spi.workflowntry interface, which represents the Workflow instance. The Context variable is an object of the com.opensymphony.workflow.workflowcontext type, which allows the beanshell function to roll back the transaction or determine the name of the caller. The Store variable is an object of the com.opensymphony.workflow.workflowstore type, which allows the function to access the Workflow persistent storage area.

Like the Java-based function above, use three variables TransientVars, Args, and PropertySet, for example:

PropertySet.SetString ("World", "Earth");

System.out.println ("Hello," PropertySet.getstring ("world"));

The output of these two Scripts is "Hello, Earth". This is because the variables stored in the Propertyset are persisted to use the function in the Workflow later.

3. BSF Functions (Perlscript, Vbscript, JavaScript)

OsWorkflow also supports a function of Bean Scripting Framework. BSF is an IBM AlphaWorks team project that allows common Script language, such as VBScript, Perlscript, Python, and JavaScript run in a generic environment. This means that in OSWORKFLOW you can write your function with any language supported by BSF:

foo.pl

0

0

Print $ bsf-> lookupbean ("propertyset"). GetString ("foo");

The above code will get PropertySet, then printed the value of the object of Key as FOO. The same variable in the BEANSHELL function can be obtained in your BSF SCRIPT code. For how to get variables in your own language, please read the BSF user manual.

4. Utility Functions

OsWorkflow itself comes with some very practical tool functions, which implements the com.opensymphony.workflow.functionProvider interface. For more detailed information, read the Javadoc documentation of these tools. Below is a brief description of each function, you can find all classes in the com.opensymphony.workflow.util package.

(1) Caller

Set the persistent variable Caller with the executor name of the current action.

(2) Webworchxecutor

Perform a webwork function and store an old ActionContext at the end of the action.

(3) EJBINVOKER

Call an EJB Session Bean method.

(4) JMSMessage

Send a TextMessage to a JMStopic or Queue.

(5) MOSTRECENTOWNER

Set the persistent variable MOSTRECENTOWNER with the name of the owner of the recently specified steps. Optional feature can set the variable to Nothing when there is any person, or return an internal error.

(6) Schedulejob

You can schedule a TRIGGER function to perform at a certain time. At the same time support CRON expressions and simple repeat / delay counts.

(7) UnschduleJob

Delete a ScheduleJob and all Triggers functions with it. It turns very useful in the status of Workflow and you no longer want ScheduleJob to perform it.

(8) Sendemail

Send an email to one or more users.

转载请注明原文地址:https://www.9cbs.com/read-119795.html

New Post(0)