luehe       2004/04/12 15:05:49

  Modified:    webapps/manager/WEB-INF/classes/org/apache/catalina/manager
                        ManagerServlet.java
  Log:
  Fixed Bugzilla 28272 ("Deploy manager command should use context.xml
  from war file"):
  
  Added support for embedded META-INF/context.xml, as mentioned in
  manager-howto.html. If present, META-INF/context.xml is used only if
  neither "path" nor "config" params have been specified for the "deploy"
  action.
  
  Revision  Changes    Path
  1.17      +46 -4     
jakarta-tomcat-catalina/webapps/manager/WEB-INF/classes/org/apache/catalina/manager/ManagerServlet.java
  
  Index: ManagerServlet.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat-catalina/webapps/manager/WEB-INF/classes/org/apache/catalina/manager/ManagerServlet.java,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- ManagerServlet.java       27 Feb 2004 14:59:07 -0000      1.16
  +++ ManagerServlet.java       12 Apr 2004 22:05:49 -0000      1.17
  @@ -22,6 +22,7 @@
   import java.io.File;
   import java.io.FileInputStream;
   import java.io.FileOutputStream;
  +import java.io.FileNotFoundException;
   import java.io.InputStream;
   import java.io.IOException;
   import java.io.PrintWriter;
  @@ -764,8 +765,12 @@
                           config + "'");
                   }
               } else {
  -                log("install: Installing web application at '" + path +
  -                    "' from '" + war + "'");
  +                if (path != null && path.length() > 0) {
  +                    log("install: Installing web application at '" + path +
  +                        "' from '" + war + "'");
  +                } else {
  +                    log("install: Installing web application from '" + war + "'");
  +                }
               }
           }
   
  @@ -826,6 +831,44 @@
               }
   
               if (path == null || path.length() == 0) {
  +                if (deployer.isDeployXML()) {
  +                    // Use embedded META-INF/context.xml if present
  +                    URL contextXml = null;
  +                    InputStream stream = null;
  +                    try {
  +                        String contextWar = war;
  +                        if (war.startsWith("file:")) {
  +                            if (war.endsWith(".war")) {
  +                                contextWar = "jar:" + war + "!/";
  +                            } else {
  +                                contextWar = war + '/';
  +                            }
  +                        }
  +                        contextXml = new URL(contextWar +
  +                                             "META-INF/context.xml");
  +                        stream = contextXml.openStream();
  +                        // WAR contains META-INF/context.xml resource - install
  +                        deployer.install(new URL(contextWar));
  +                        return;
  +                    } catch (FileNotFoundException fnfe) {
  +                     // No META-INF/context.xml resource - keep going
  +                    } catch (Throwable t) {
  +                        log("ManagerServlet.configure[" + contextXml + "]", t);
  +                        writer.println(sm.getString("managerServlet.exception",
  +                                                    t.toString()));
  +                        return;
  +                    } finally {
  +                        if (stream != null) {
  +                            try {
  +                                stream.close();
  +                            } catch (Throwable t) {
  +                                // do nothing
  +                            }
  +                        }
  +
  +                    }
  +                }
  +
                   int end = war.length();
                   String filename = war.toLowerCase();
                   if (filename.endsWith("!/")) {
  @@ -1642,6 +1685,5 @@
           }
           return true;
       }
  -
   
   }
  
  
  

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

Reply via email to