Hi,
we have many projects whose output is a single jar:

- two general framework projects;
- more than 8 specific functional projects, each focused on a particular functional 
area;

All those projects have a source structure like this:

|
|- java packages (struts action files plus some other not strictly related to struts)
|- xsl (our MVC views)
|- xml (our specific config files)
|- struts-config (struts-config.xml with only action mappings related to this 
functional project, so only related to those action files)

Each as a plug-in.

Then, we have many web-apps whose output is an installable war.
All those web-apps are made including some or all the jar described above.
Each web-app has one struts-config with the following sections:

- plug-in (an entry for each framework + functional jar)
- global exception
- global forward
- request-processor

We need to "merge" all these struts-config pieces at run-time (web-apps start-up), 
reading them from each jar, as "resource stream". For this reason, we cannot use the 
"comma-delimited list of "multiple struts-config files" feature of Struts 1.1.

What we made is to delegate each plug-in to "notify" his presence by calling, in a 
subclassed ActionServlet, a method with this signature:

- public void addStrutsConfigXML (Class callerClass, String prefix, String 
StrutsConfigXML)

This method was written copying some part of Struts ActionServlet's code.

Here is the main code (without any catch and other not important code):

    public void addStrutsConfigXML (Class callerClass, String prefix, String 
StrutsConfigXML) {

      ModuleConfig modConfig = null;

      if (prefix == "") {
        modConfig = (ModuleConfig) 
getServletContext().getAttribute(Globals.MODULE_KEY);
      } else {
        ModuleConfigFactory factoryObject = ModuleConfigFactory.createFactory();
        modConfig = factoryObject.createModuleConfig(prefix);
      }

      Digester digester = initConfigDigester();

      try {
        InputStream input = callerClass.getResourceAsStream(strutsConfigXML);
        if(input != null) {

          digester.push(modConfig);
          digester.parse(input);

          if (prefix != "") {
            getServletContext().setAttribute(Globals.MODULE_KEY + prefix, modConfig);
          }

        }

      }
    }


A tipical call is something like this, made in the init method of the plug-in:

-  ((MyActionServlet)servlet).addStrutsConfigXML(getClass(), "", 
"/struts_config/function1.xml");

We'd like not to subclass ActionServlet, but is really difficult to do something like 
this outside the ActionServlet hierarchy mainly 'cause of the call to 
"initConfigDigester()", that's obviously protected. 

The questions are:

- is there a way to do the same without subclassing ActionServlet?
- do you think is it reasonable to include a similar feature in the main source tree 
on CVS (dynamic read pieces of struts-config from jar files)?

Thanks,

Filippo Munafò

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

Reply via email to