Andrew Hill wrote:

<snip>
For the other usage, where people have trouble creating a finely-grained
business API, there's a new Chain package in the Commons sandbox that
can help. This package makes it easy to chain together arbitrary units
of work, so that you can do things like create a "move" command by
chaining a "copy" command to a "delete" command -- and still use "copy"
or "delete" on their own.
</snip>

Interesting. Sounds a lot like something I banged together the other day - a
thing I unimaginatevly called the "steplib" as its a library for configuring
steps to be executed.

Basically the units of work are classes that extend the Step class which
defines a begin() & end() method that one overrides. Steps are organised
into a tree, and can have children. If a steps begin() returns true the
children are executed, and if a steps end() (executed after children are
executed) returns true then the step is repeated. The step classes are
stateless in a similar manner to actions and servlets, etc... and are
configured in xml files which I read with digester the first time a
particluar sequence is requested, and reuse for all subsequent requests for
that sequence.

I did make a StepAction class that will execute a tree of steps (that
subclass ActionStep heheh) for an action, though actually that was an
afterthought and Im not using it much yet! The primary reason I built this
thing was for use as a view rendering technology (Im allergic to JSP and
prefer to decorate org.w3c.dom.Document trees (ahhh random access to my
xhtml. Oh joy :->)...) as I wanted a better way to configure a sequence of
more fine-grained DOM decorators.

Heres an example that does a listview table thingy:

 <stamp id="stamp" mode="get" name="userRowStamp" remove="true">
   <iterate exposeName="user" beanName="users" beanScope="request">
     <log text="UserId:" name="user" property="userId" scope="request"/>
     <stamp id="userTable" mode="put" name="userRowStamp" remove="false">
       <populate id="userTable" name="user"/>
       <rewrite id="userLink" forward="userEdit" paramId="userId"
paramName="user" property="userId"/>
       <attribute id="userCheckbox" attribute="value" name="user"
property="userId"/>
       <equals empty="true" name="user" property="roles">
         <stamp id="roles_value" mode="get" remove="true"/>
       </equals>
       <equals not="true" empty="true" name="user" property="roles">
         <stamp id="roles_br" mode="get" remove="true"/>
       </equals>
       <attribute id="stamp" attribute="id" remove="true" recurse="true"/>
     </stamp>
   </iterate>
 </stamp>

Of course for an action step sequence the steps could do such things as
"copy" or "delete".


Given your bent towards playing with "executable XML" here, you might want to take a serious look at the Jelly project as well.

http://jakarta.apache.org/commons/jelly/

It incorporates the notion of using an expression language very similar to JSTL 1.0 and JSTP 2.0, instead of the clunky XML things like the <logic:equals> and <logic:iterate> tags provide. The result is much more succinct scripts that can leverage all the power of the underlying expressions for conditionals, iterations, and so on.

Building a Struts action that invokes a Jelly script with a specified name is an exercize left for the reader (but it's really easy).

Craig



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to