commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From craig...@apache.org
Subject cvs commit: jakarta-commons-sandbox/workflow/src/java/org/apache/commons/workflow/core LoadStep.java package.html
Date Mon, 19 Nov 2001 06:40:17 GMT
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 @@
    * <p>Supported Attributes:</p>
    * <ul>
    * <li><strong>name</strong> - The fully qualified name of the Java class
  - *     to be loaded.</li>
  + *     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.</li>
    * <li><strong>thread</strong> - 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).</li>
    * </ul>
    *
  - * @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 @@
     &lt;/base:activity&gt;
   </pre>
   
  +<p><em>NOTE</em> - It is <strong>not</strong> 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.</p>
  +
   <div align="center">
   [<a href="#core:and">core:and</a>]
   [<a href="#core:call">core:call</a>]
  @@ -81,13 +88,13 @@
   bean return non-null String values.  Otherwise, control will be transferred
   (via the <em>core:goto</em> Step) to the Step labelled <code>notOk</code>.</p>
   <pre>
  -  &lt;core:and step="ok"&gt;
  +  <strong>&lt;core:and step="ok"&gt;</strong>
       &lt;core:descriptor xpath="address/street1"/&gt;
       &lt;core:descriptor xpath="address/city"/&gt;
       &lt;core:descriptor xpath="address/state"/&gt;
       &lt;core:descriptor xpath="address/zipCode"/&gt;
  -  &lt;/core:and&gt;
  -  &lt;core:goto step="notOk"&gt;
  +  <strong>&lt;/core:and&gt;</strong>
  +  &lt;core:goto step="notOk"/&gt;
   </pre>
   
   <a name="core:call"></a>
  @@ -100,6 +107,13 @@
   Activity executes an <a href="#core:exit">core:exit</a> Step, or the last
   defined Step in the Activity has been executed.</p>
   
  +<p>The <em>core:call</em> element recognizes the following attributes:
  +<ul>
  +<li><strong>id</strong> - Optional identifier of this Step, which can
be used
  +    as the destination for control transfers.  If specified, must be unique
  +    within the current Activity.</li>
  +</ul>
  +
   <p>In the example below, the <code>activity</code> property of the
   <code>process</code> 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 @@
     &lt;core:get&gt;
       &lt;core:descriptor xpath="process/activity"/&gt;
     &lt;/core:get&gt;
  -  &lt;core:call&gt;
  +  <strong>&lt;core:call/&gt;</strong>
  +</pre>
  +
  +
  +<a name="core:construct"></a>
  +<h3>core:construct</h3>
  +
  +<p>The <em>core:construct</em> 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
  +<a href="core:descriptor">core:descriptor</a> elements.</p>
  +
  +<p>The <em>core:construct</em> element recognizes the following attributes:
  +<ul>
  +<li><strong>id</strong> - Optional identifier of this Step, which can
be used
  +    as the destination for control transfers.  If specified, must be unique
  +    within the current Activity.</li>
  +</ul>
  +
  +<p>At least one nested <em>core:descriptor</em> element is required,
although
  +more than one are allowed.  They are interpreted as follows:</p>
  +<ul>
  +<li>The <strong>first</strong> descriptor must identify an object of
type
  +    <code>java.lang.Class</code>, representing the Class of the object to be
  +    created.  For script readability, you can use <code>core:class</code> as
an
  +    alias for <code>core:descriptor</code> in the first nested descriptor,
  +    but it is interpreted identically.</li>
  +<li>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.
  +</ul>
  +
  +<p><strong>FIXME</strong> - Currently, this Step does not correctly recognize
  +constructors that accept primitive argument types.</p>
  +
  +<p>In the example below, it is assumed that the top item on the evaluation
  +stack is an instance of <code>java.lang.Class</code>, produced by some
  +unspecified previous processing.  This class has a constructor that takes
  +two arguments - a <code>java.util.Map</code> and a
  +<code>java.lang.String</code> - that are returned by appropriate bean
  +properties.</p>
  +<pre>
  +  <strong>&lt;core:construct&gt;</strong>
  +    &lt;core:class/&gt;   &lt;-- Top item is a Class --&gt;
  +    &lt;core:descriptor xpath="foo/map" type="java.util.Map"/&gt;
  +    &lt;core:descriptor xpath="bar/string"/&gt;
  +  <strong>&lt;/core:construct&gt;</strong>
  +</pre>
  +
  +
  +<a name="core:duplicate"></a>
  +<h3>core:duplicate</h3>
  +
  +<p>The <em>core:duplicate</em> 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.</p>
  +
  +<p>The <em>core:duplicate</em> element recognizes the following attributes:
  +<ul>
  +<li><strong>id</strong> - Optional identifier of this Step, which can
be used
  +    as the destination for control transfers.  If specified, must be unique
  +    within the current Activity.</li>
  +</ul>
  +
  +<p>In the example below, the script wants to display the top item on the
  +stack (for debugging purposes) without consuming it.</p>
  +<pre>
  +  <strong>&lt;core:duplicate/&gt;</strong>
  +  &lt;io:display&gt;
  +    &lt;io:descriptor/&gt;   &lt;-- Consumes top stack item --&gt;
  +  &lt;/io:display&gt;
   </pre>
   
  +<a name="core:exit"></a>
  +<h3>core:exit</h3>
  +
  +<p>The <em>core:exit</em> 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 <a href="#core:call">core:call</a>
  +invocation, control will resume with the next Step in the calling Activity.
  +Otherwise, the <code>Context.execute()</code> call from the application will
  +return control to the calling application.</p>
  +
  +<p>The <em>core:exit</em> element recognizes the following attributes:
  +<ul>
  +<li><strong>id</strong> - Optional identifier of this Step, which can
be used
  +    as the destination for control transfers.  If specified, must be unique
  +    within the current Activity.</li>
  +</ul>
  +
  +
  +<a name="core:get"></a>
  +<h3>core:get</h3>
  +
   
  -<h3>construct</h3>
  +<a name="core:goto"></a>
  +<h3>core:goto</h3>
   
  -<h3>duplicate</h3>
   
  -<h3>exit</h3>
  +<a name="core:invoke"></a>
  +<h3>core:invoke</h3>
   
  -<h3>get</h3>
   
  -<h3>goto</h3>
  +<a name="core:load"></a>
  +<h3>core:load</h3>
  +
  +<p>The <em>core:load</em> Step causes the specified
  +<code>java.lang.Class</code> to be loaded, and the corresponding
  +<code>Class</code> object pushed onto the top of the execution stack.
  +The name of the class to be loaded can be specified either statically
  +or dynamically.</p>
  +
  +<p>The <em>core:load</em> element recognizes the following attributes:
  +<ul>
  +<li><strong>id</strong> - Optional identifier of this Step, which can
be used
  +    as the destination for control transfers.  If specified, must be unique
  +    within the current Activity.</li>
  +<li><strong>name</strong> - 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.</li>
  +<li><strong>thread</strong> - Boolean attribute that determines whether
the
  +    class should be loaded from the current Thread's context class loader
  +    if set to <code>true</code>.  By default, the class is loaded from the
  +    same class loader that loaded the <code>LoadStep</code> implementation
  +    class.</li>
  +</ul>
   
  -<h3>invoke</h3>
  +<p>In the example below, the <code>java.util.Date</code> class is loaded,
and
  +a new <code>Date</code> instance is constructed using the zero-arguments
  +constructor and pushed on to the evaluation stack.</p>
  +<pre>
  +  <strong>&lt;core:load name="java.util.Date"/&gt;</strong>
  +  &lt;core:construct&gt;
  +    &lt;core:descriptor/&gt;   &lt;-- Consumes top item from the stack --&gt;
  +  &lt;/core:construct&gt;
  +</pre>
   
  -<h3>load</h3>
   
   <a name="notAnd"></a>
   <h3>core:notAnd</h3>
  @@ -158,15 +296,16 @@
   be transferred (via the <em>core:goto</em> Step) to the Step labelled
   <code>notEmpty</code>.</p>
   <pre>
  -  &lt;core:notAnd step="empty"&gt;
  +  <strong>&lt;core:notAnd step="empty"&gt;</strong>
       &lt;core:descriptor xpath="address/street1"/&gt;
       &lt;core:descriptor xpath="address/city"/&gt;
       &lt;core:descriptor xpath="address/state"/&gt;
       &lt;core:descriptor xpath="address/zipCode"/&gt;
  -  &lt;/core:and&gt;
  -  &lt;core:goto step="notEmpty"&gt;
  +  <strong>&lt;/core:notAnd&gt;</strong>
  +  &lt;core:goto step="notEmpty"/&gt;
   </pre>
   
  +
   <a name="core:notOr"></a>
   <h3>core:notOr</h3>
   
  @@ -199,13 +338,13 @@
   control will be transferred (via the <em>core:goto</em> Step)
   to the Step labelled <code>ok</code>.</p>
   <pre>
  -  &lt;core:and step="notOk"&gt;
  +  <strong>&lt;core:notOr step="notOk"&gt;</strong>
       &lt;core:descriptor xpath="address/street1"/&gt;
       &lt;core:descriptor xpath="address/city"/&gt;
       &lt;core:descriptor xpath="address/state"/&gt;
       &lt;core:descriptor xpath="address/zipCode"/&gt;
  -  &lt;/core:and&gt;
  -  &lt;core:goto step="ok"&gt;
  +  <strong>&lt;/core:notOr&gt;</strong>
  +  &lt;core:goto step="ok"/&gt;
   </pre>
   
   
  @@ -239,23 +378,42 @@
   Otherwise, control will be transferred (via the <em>core:goto</em> Step) to
   the Step labelled <code>notSelected</code>.</p>
   <pre>
  -  &lt;core:or step="selected"&gt;
  +  <strong>&lt;core:or step="selected"&gt;</strong>
       &lt;core:descriptor xpath="options/red"/&gt;
       &lt;core:descriptor xpath="options/blue"/&gt;
       &lt;core:descriptor xpath="options/green"/&gt;
       &lt;core:descriptor xpath="options/white"/&gt;
     &lt;/core:or&gt;
  -  &lt;core:goto step="notSelected"&gt;
  +  <strong>&lt;core:goto step="notSelected"/&gt;</strong>
   </pre>
  +
  +<a name="core:pop"></a>
  +<h3>core:pop</h3>
  +
  +
  +<a name="core:put"></a>
  +<h3>core:put</h3>
  +
  +
  +<a name="core:remove"></a>
  +<h3>core:remove</h3>
   
  -<h3>pop</h3>
   
  -<h3>put</h3>
  +<a name="core:string"></a>
  +<h3>core:string</h3>
   
  -<h3>remove</h3>
  +<p>The <em>core:string</em> Step pushes the specified literal String
value
  +onto the top of the evaluation stack.</p>
   
  -<h3>string</h3>
  +<p>The <em>core:string</em> element recognizes the following attributes:
  +<ul>
  +<li><strong>id</strong> - Optional identifier of this Step, which can
be used
  +    as the destination for control transfers.  If specified, must be unique
  +    within the current Activity.</li>
  +<li><strong>value</strong> - The literal String value to be pushed.</li>
  +</ul>
   
  +
   <a name="core:suspend"></a>
   <h3>core:suspend</h3>
   
  @@ -278,6 +436,13 @@
   on the next call to <code>Context.execute()</code>, without the calling
   application needing to be aware of the nesting.</p>
   
  +<p>The <em>core:suspend</em> element recognizes the following attributes:
  +<ul>
  +<li><strong>id</strong> - Optional identifier of this Step, which can
be used
  +    as the destination for control transfers.  If specified, must be unique
  +    within the current Activity.</li>
  +</ul>
  +
   <p>In the following example, it is assumed that you are using the Workflow
   system in an MVC-style framework, which uses
   <code>RequestDispatcher.forward()</code> to pass control to the resource
  @@ -288,14 +453,27 @@
   navigation links as well).</p>
   <pre>
     &lt;web:forward page="/page-1.jsp"/&gt;
  -  &lt;core:suspend/&gt;
  +  <strong>&lt;core:suspend/&gt;</strong>
     ... process first input request ...
     &lt;web:forward page="/page=2.jsp"/&gt;
  -  &lt;core:suspend/&gt;
  +  <strong>&lt;core:suspend/&gt;</strong>
     ... process second input request ...
   </pre>
  +
  +
  +<a name="core:swap"></a>
  +<h3>core:swap</h3>
  +
  +<p>The <em>core:swap</em> 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.</p>
   
  -<h3>swap</h3>
  +<p>The <em>core:swap</em> element recognizes the following attributes:
  +<ul>
  +<li><strong>id</strong> - Optional identifier of this Step, which can
be used
  +    as the destination for control transfers.  If specified, must be unique
  +    within the current Activity.</li>
  +</ul>
   
   
   <div align="center">
  
  
  

--
To unsubscribe, e-mail:   <mailto:commons-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.org>


Mime
View raw message