commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ted Husted <hus...@apache.org>
Subject Re: [Chain] examples XML file available?
Date Mon, 22 Sep 2003 02:32:47 GMT
Sgarlata Matt wrote:
 > I'm interested in possibly using the Chain package in some of my
 > projects and I was hoping I could get an example XML file to feed to
 > the Digester?  I don't need the Command classes associated with the
 > that, I'd just like to see an example so I don't have to file or
 > anything like reverse-engineer its structure from the ConfigRuleSet.

If you're looking for a simple test case, try this:

----

<?xml version="1.0" ?>
<chains>

     <command
         name="MyCommand"
         className="myApp.MyCommand" />

</chains>


----

package us_ok_deq_wqdata.command;

import org.apache.commons.chain.Context;
import org.apache.commons.chain.Command;

public class MyCommand implements Command {

     public MyCommand () {
         ;
     }

     public boolean execute(Context context) throws Exception {

         return true;

     }

}

----

If you're testing it from a servlet, from any method that has access to 
the request, you can try

Catalog catalog = 
request.getSession().getServletContext().getAttribute(Constants.CATALOG_ATTR);

to get a handle on the default catalog, and then

Context context = new BaseContext();
Command command = catalog.getCommand("MyCommand");
boolean result = command.execute(context);

to run the request.

 > If I play with the package some more and like it, I could provide a
 > DTD for the XML file and documentation for it.  That should save Craig
 > and Ted from some boring work :)

What might be helpful is a standalone ChainServlet that would load the 
configuration file, like the sample PlugIn does. (A HiveMind service 
might also be very cool.)

Right now, I'm loading it as a Struts PlugIn (and imagine Craig is too), 
but that wouldn't work for everyone.


Craig R. McClanahan wrote:
> There's another example in the CVS HEAD sources of Struts, where we are
> experimenting with building a replacement for the current RequestProcessor
> class to assemble the request processing pipeline:
> 
>   contrib/struts-chain/src/conf/chain-config.xml

Also in the Struts Contrib CVS is a PlugIn class. Problem is, other 
parts of that distribution are coupled to the Struts Nightly Build and 
won't compile under Struts 1.1 (namely the Constants.MODULE_CONFIG_KEY).

I'd like to move the Struts CatalogConfiguratorPlugIn to the Commons 
Chain distro and make it an optional compile, like JSF et al. That way, 
people could start using Chain with Struts 1.1 "out of the box".

Even if we could decouple the Contrib package from the Nightly Build, 
I'm thinking if we have these other optional packages here, we can also 
have one for Struts. So, the ComposableRequestProcessor would stay 
there, but the CatalogConfiguratorPlugIn would move here.

Does this sound all right?

-Ted.




Mime
View raw message