Return-Path: Delivered-To: apmail-jakarta-commons-dev-archive@apache.org Received: (qmail 80871 invoked from network); 19 Nov 2001 06:54:48 -0000 Received: from unknown (HELO nagoya.betaversion.org) (192.18.49.131) by daedalus.apache.org with SMTP; 19 Nov 2001 06:54:48 -0000 Received: (qmail 27090 invoked by uid 97); 19 Nov 2001 06:54:55 -0000 Delivered-To: qmlist-jakarta-archive-commons-dev@jakarta.apache.org Received: (qmail 27030 invoked by uid 97); 19 Nov 2001 06:54:54 -0000 Mailing-List: contact commons-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Jakarta Commons Developers List" Reply-To: "Jakarta Commons Developers List" Delivered-To: mailing list commons-dev@jakarta.apache.org Received: (qmail 27019 invoked by uid 97); 19 Nov 2001 06:54:54 -0000 Date: 19 Nov 2001 06:40:17 -0000 Message-ID: <20011119064017.34885.qmail@icarus.apache.org> From: craigmcc@apache.org To: jakarta-commons-sandbox-cvs@apache.org Subject: cvs commit: jakarta-commons-sandbox/workflow/src/java/org/apache/commons/workflow/core LoadStep.java package.html X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N craigmcc 01/11/18 22:40:17 Modified: workflow/src/java/org/apache/commons/workflow/core LoadStep.java package.html Log: That's enough documentation for one night ... Revision Changes Path 1.3 +19 -9 jakarta-commons-sandbox/workflow/src/java/org/apache/commons/workflow/core/LoadStep.java Index: LoadStep.java =================================================================== RCS file: /home/cvs/jakarta-commons-sandbox/workflow/src/java/org/apache/commons/workflow/core/LoadStep.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- LoadStep.java 2001/09/20 02:13:55 1.2 +++ LoadStep.java 2001/11/19 06:40:17 1.3 @@ -1,7 +1,7 @@ /* - * $Header: /home/cvs/jakarta-commons-sandbox/workflow/src/java/org/apache/commons/workflow/core/LoadStep.java,v 1.2 2001/09/20 02:13:55 craigmcc Exp $ - * $Revision: 1.2 $ - * $Date: 2001/09/20 02:13:55 $ + * $Header: /home/cvs/jakarta-commons-sandbox/workflow/src/java/org/apache/commons/workflow/core/LoadStep.java,v 1.3 2001/11/19 06:40:17 craigmcc Exp $ + * $Revision: 1.3 $ + * $Date: 2001/11/19 06:40:17 $ * * ==================================================================== * @@ -75,13 +75,15 @@ *

Supported Attributes:

*
    *
  • name - The fully qualified name of the Java class - * to be loaded.
  • + * to be loaded. If not specified, the top of the evaluation stack + * is popped, converted to a String (if necessary), and used as the + * name of the class to be loaded. *
  • thread - Should the class be loaded from the current * Thread's context class loader? (Default is to load from the same * class loader that loaded this class).
  • *
* - * @version $Revision: 1.2 $ $Date: 2001/09/20 02:13:55 $ + * @version $Revision: 1.3 $ $Date: 2001/11/19 06:40:17 $ * @author Craig R. McClanahan */ @@ -200,10 +202,15 @@ throw new StepException ("No thread context class loader is available"); + // Calculate the name of the class to be loaded + String className = getName(); + if (className == null) + className = context.pop().toString(); + // Load the specified class Class clazz = null; try { - clazz = classLoader.loadClass(name); + clazz = classLoader.loadClass(className); } catch (Throwable t) { throw new StepException ("Exception from loadClass()", t, this); @@ -225,10 +232,13 @@ sb.append(" id=\""); sb.append(getId()); sb.append("\""); + } + if (getName() != null) { + sb.append(" name=\""); + sb.append(getName()); + sb.append("\""); } - sb.append(" name=\""); - sb.append(getName()); - sb.append("\" thread=\""); + sb.append(" thread=\""); sb.append(getThread()); sb.append("\"/>"); return (sb.toString()); 1.4 +204 -26 jakarta-commons-sandbox/workflow/src/java/org/apache/commons/workflow/core/package.html Index: package.html =================================================================== RCS file: /home/cvs/jakarta-commons-sandbox/workflow/src/java/org/apache/commons/workflow/core/package.html,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- package.html 2001/11/19 04:56:49 1.3 +++ package.html 2001/11/19 06:40:17 1.4 @@ -28,6 +28,13 @@ </base:activity> +

NOTE - It is not required that you use the XML +syntax, processed with a Digester, to initialize the Steps associated with +each Activity. However, this usage is very convenient, and is likely to be +the most common case, so the Steps are documented from that perspective. To +use the underlying implementation classes directly, see the Javadocs for each +Step implementation class, just as you would for any other Java class.

+
[core:and] [core:call] @@ -81,13 +88,13 @@ bean return non-null String values. Otherwise, control will be transferred (via the core:goto Step) to the Step labelled notOk.

  -  <core:and step="ok">
  +  <core:and step="ok">
       <core:descriptor xpath="address/street1"/>
       <core:descriptor xpath="address/city"/>
       <core:descriptor xpath="address/state"/>
       <core:descriptor xpath="address/zipCode"/>
  -  </core:and>
  -  <core:goto step="notOk">
  +  </core:and>
  +  <core:goto step="notOk"/>
   
@@ -100,6 +107,13 @@ Activity executes an core:exit Step, or the last defined Step in the Activity has been executed.

+

The core:call element recognizes the following attributes: +

    +
  • id - Optional identifier of this Step, which can be used + as the destination for control transfers. If specified, must be unique + within the current Activity.
  • +
+

In the example below, the activity property of the process bean is assumed to return an instance of Activity that is to be executed to accomplish a portion of a business process. This allows @@ -108,23 +122,147 @@ <core:get> <core:descriptor xpath="process/activity"/> </core:get> - <core:call> + <core:call/> + + + + +

core:construct

+ +

The core:construct Step creates a new object of the specified +class, and pushes it onto the stack. The specified class, and the optional +argument(s) to the constructor, are defined by the nested +core:descriptor elements.

+ +

The core:construct element recognizes the following attributes: +

    +
  • id - Optional identifier of this Step, which can be used + as the destination for control transfers. If specified, must be unique + within the current Activity.
  • +
+ +

At least one nested core:descriptor element is required, although +more than one are allowed. They are interpreted as follows:

+
    +
  • The first descriptor must identify an object of type + java.lang.Class, representing the Class of the object to be + created. For script readability, you can use core:class as an + alias for core:descriptor in the first nested descriptor, + but it is interpreted identically.
  • +
  • Any subsequent descriptors represent arguments to the constructor, in the + order they are defined on the constructor itself. The + workflow engine will attempt to find a matching constructor on the + specified class (throwing an exception if none can be found), and will + then use that constructor to instantiate a new instance. +
+ +

FIXME - Currently, this Step does not correctly recognize +constructors that accept primitive argument types.

+ +

In the example below, it is assumed that the top item on the evaluation +stack is an instance of java.lang.Class, produced by some +unspecified previous processing. This class has a constructor that takes +two arguments - a java.util.Map and a +java.lang.String - that are returned by appropriate bean +properties.

+
  +  <core:construct>
  +    <core:class/>   <-- Top item is a Class -->
  +    <core:descriptor xpath="foo/map" type="java.util.Map"/>
  +    <core:descriptor xpath="bar/string"/>
  +  </core:construct>
  +
+ + + +

core:duplicate

+ +

The core:duplicate Step peeks at the top value on the evaluation +stack and pushes another copy of it onto the stack. This is useful in +scenarios where you execute Steps that consume items from the stack, but you +wish to maintain a reference to the top object.

+ +

The core:duplicate element recognizes the following attributes: +

    +
  • id - Optional identifier of this Step, which can be used + as the destination for control transfers. If specified, must be unique + within the current Activity.
  • +
+ +

In the example below, the script wants to display the top item on the +stack (for debugging purposes) without consuming it.

+
  +  <core:duplicate/>
  +  <io:display>
  +    <io:descriptor/>   <-- Consumes top stack item -->
  +  </io:display>
   
+ +

core:exit

+ +

The core:exit Step causes execution of the current Activity to be +completed, just as if the last Step in the Activity had been executed. If this +Activity was executed as the result of a core:call +invocation, control will resume with the next Step in the calling Activity. +Otherwise, the Context.execute() call from the application will +return control to the calling application.

+ +

The core:exit element recognizes the following attributes: +

    +
  • id - Optional identifier of this Step, which can be used + as the destination for control transfers. If specified, must be unique + within the current Activity.
  • +
+ + + +

core:get

+ -

construct

+ +

core:goto

-

duplicate

-

exit

+ +

core:invoke

-

get

-

goto

+ +

core:load

+ +

The core:load Step causes the specified +java.lang.Class to be loaded, and the corresponding +Class object pushed onto the top of the execution stack. +The name of the class to be loaded can be specified either statically +or dynamically.

+ +

The core:load element recognizes the following attributes: +

    +
  • id - Optional identifier of this Step, which can be used + as the destination for control transfers. If specified, must be unique + within the current Activity.
  • +
  • name - Fully qualified name of the Java class to be + loaded. If not specified, the top of the evaluation stack will be + popped, converted to a String (if necessary), and used as the name of + the Class to be loaded.
  • +
  • thread - Boolean attribute that determines whether the + class should be loaded from the current Thread's context class loader + if set to true. By default, the class is loaded from the + same class loader that loaded the LoadStep implementation + class.
  • +
-

invoke

+

In the example below, the java.util.Date class is loaded, and +a new Date instance is constructed using the zero-arguments +constructor and pushed on to the evaluation stack.

+
  +  <core:load name="java.util.Date"/>
  +  <core:construct>
  +    <core:descriptor/>   <-- Consumes top item from the stack -->
  +  </core:construct>
  +
-

load

core:notAnd

@@ -158,15 +296,16 @@ be transferred (via the core:goto Step) to the Step labelled notEmpty.

  -  <core:notAnd step="empty">
  +  <core:notAnd step="empty">
       <core:descriptor xpath="address/street1"/>
       <core:descriptor xpath="address/city"/>
       <core:descriptor xpath="address/state"/>
       <core:descriptor xpath="address/zipCode"/>
  -  </core:and>
  -  <core:goto step="notEmpty">
  +  </core:notAnd>
  +  <core:goto step="notEmpty"/>
   
+

core:notOr

@@ -199,13 +338,13 @@ control will be transferred (via the core:goto Step) to the Step labelled ok.

  -  <core:and step="notOk">
  +  <core:notOr step="notOk">
       <core:descriptor xpath="address/street1"/>
       <core:descriptor xpath="address/city"/>
       <core:descriptor xpath="address/state"/>
       <core:descriptor xpath="address/zipCode"/>
  -  </core:and>
  -  <core:goto step="ok">
  +  </core:notOr>
  +  <core:goto step="ok"/>
   
@@ -239,23 +378,42 @@ Otherwise, control will be transferred (via the core:goto Step) to the Step labelled notSelected.

  -  <core:or step="selected">
  +  <core:or step="selected">
       <core:descriptor xpath="options/red"/>
       <core:descriptor xpath="options/blue"/>
       <core:descriptor xpath="options/green"/>
       <core:descriptor xpath="options/white"/>
     </core:or>
  -  <core:goto step="notSelected">
  +  <core:goto step="notSelected"/>
   
+ + +

core:pop

+ + + +

core:put

+ + + +

core:remove

-

pop

-

put

+ +

core:string

-

remove

+

The core:string Step pushes the specified literal String value +onto the top of the evaluation stack.

-

string

+

The core:string element recognizes the following attributes: +

    +
  • id - Optional identifier of this Step, which can be used + as the destination for control transfers. If specified, must be unique + within the current Activity.
  • +
  • value - The literal String value to be pushed.
  • +
+

core:suspend

@@ -278,6 +436,13 @@ on the next call to Context.execute(), without the calling application needing to be aware of the nesting.

+

The core:suspend element recognizes the following attributes: +

    +
  • id - Optional identifier of this Step, which can be used + as the destination for control transfers. If specified, must be unique + within the current Activity.
  • +
+

In the following example, it is assumed that you are using the Workflow system in an MVC-style framework, which uses RequestDispatcher.forward() to pass control to the resource @@ -288,14 +453,27 @@ navigation links as well).

     <web:forward page="/page-1.jsp"/>
  -  <core:suspend/>
  +  <core:suspend/>
     ... process first input request ...
     <web:forward page="/page=2.jsp"/>
  -  <core:suspend/>
  +  <core:suspend/>
     ... process second input request ...
   
+ + + +

core:swap

+ +

The core:swap Step swaps the top two items on the evaluation +stack. This can be useful when previous processing has generated items on the +stack that are not in the desired order for future processing.

-

swap

+

The core:swap element recognizes the following attributes: +

    +
  • id - Optional identifier of this Step, which can be used + as the destination for control transfers. If specified, must be unique + within the current Activity.
  • +
-- To unsubscribe, e-mail: For additional commands, e-mail: