I want to automatically detect and install subapplications, instead of 
hand editing the web.xml file. (It's hard to "patch" with ant).

So I wrote a plugin, that looks up instances with getResourcePaths() and 
installs them with initApplicationConfig().

But this method is protected. I can probably make a custom build to 
avoid this, but I'm interested to know why is it protected? Is there a 
better way to programmatically initialize sub applications?

public class SubAppConfig implements PlugIn {

     static Category cat = Category.getInstance(SubAppConfig.class.getName());  

     /**
      * The debugging detail level for this plugin.
      */
     private int debug = 0;

     public int getDebug() {
         return (this.debug);
     }

     public void setDebug(int debug) {
         this.debug = debug;
     }

     /**
      * The parent directory where we look for sub-application 
configurations.
      */
     private String pathname = "/WEB-INF";

     public String getPathname() {
         return (this.pathname);
     }

     public void setPathname(String pathname) {
         this.pathname = pathname;
     }

     public void destroy() { }

     public synchronized void init(ApplicationConfig config) throws 
ServletException {

         ActionServlet servlet = config.getServlet();

         try {
             Set resourcePaths = 
servlet.getServletContext().getResourcePaths(pathname);

             Iterator it = resourcePaths.iterator();
             while (it.hasNext()) {
                 String path = (String) it.next();
                 if (path.indexOf("-struts-config.xml") != -1) {
                     String prefix = 
path.substring(path.indexOf("-struts-config.xml"));
                     cat.debug("found prefix: " + prefix + ", path: " + 
path);
                     servlet.initApplicationConfig(prefix, path); //hmm, 
protected...
                 }
             }

         } catch (Exception e) {
             servlet.log("Error while configuring sub applications; ", e);
             throw new UnavailableException("Unable to configure sub 
applications.");
         }
     }
}


-- 
-Torgeir


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

Reply via email to