struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Eddie Bush <>
Subject Re: preserve Forward order
Date Sat, 21 Sep 2002 16:50:35 GMT
Here's what I would do:
    - grab source from CVS
    - located the source for  (or is it
    - read up on the javadoc for the Plugin interface.

(You could just browse CVS over the web and find that file to examine, 
if you prefer.  I find having the full source handy for consultation is 
a big help at times though.)

It's *really* simple.  I think the most difficult part will be figuring 
out the digester and what you want your graph to look like.  Be sure you 
look at the digester package javadocs:  org.apache.commons.digester (I 
believe).  There's quite a long explaination of how to use the digester. 
 If you get stuck, I can possibly give you a pointer or two.  I haven't 
used it long, but I manage to get it to build heirarchys just fine 
(create this, set it's properties, add it to this other object ...)

A skelleton plugin might be:

-------------------------------------------------- BEGIN MyPlugin
import org.apache.struts.action.PlugIn;
import org.apache.struts.action.ActionServlet;
import org.apache.struts.config.ApplicationConfig;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import org.apache.commons.digester.Digester;
import org.xml.sax.SAXException;

import javax.servlet.ServletException;
import javax.servlet.UnavailableException;

import java.util.Collection;
import java.util.ArrayList;

public class MyPlugin implements PlugIn
  private Log log = LogFactory.getLog(MyPlugin.class);
  private ActionServlet servlet = null;
  private ApplicationConfig config = null;
  private String configFile;
  public MyPlugin()
  public void destroy()
    this.servlet = null;
    this.config = null;
  public void init(ActionServlet servlet, ApplicationConfig config)
  throws ServletException
    if (log.isTraceEnabled())
      log.trace("Initializing module configuration");
    this.servlet = servlet;
    this.config = config;
    Digester digester = new Digester();

    ... is = 
    catch (IOException ioe)
      log.fatal("IOException thrown while parsing config:  " + 
ioe.getMessage(), ioe);
      throw new UnavailableException("IOException thrown while parsing 
modules config");
    catch (SAXException saxe)
      log.fatal("SAXException thrown while parsing config:  " + 
saxe.getMessage(), saxe);
      throw new UnavailableException("SAXException thrown while parsing 
    if (log.isTraceEnabled())
      log.trace("Finished initializing module configuration");
  public java.lang.String getConfigFile()
    return configFile;
  public void setConfigFile(java.lang.String configFile)
    if (log.isTraceEnabled())
      log.trace("Setting configFile to " + configFile);

    this.configFile = configFile;
-------------------------------------------------- END MyPlugin

Billy Ng wrote:

>Good idea!  I won't go for hacking Struts either.  By the way, I heard you
>guys talking about plugin so many times (I know, I am a slower learner).
>Any web site I can look at.  I am very interested in learnig it.
>Billy Ng

Eddie Bush

To unsubscribe, e-mail:   <>
For additional commands, e-mail: <>

View raw message