tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From amy...@apache.org
Subject cvs commit: jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/core StandardHostDeployer.java StandardServer.java
Date Tue, 20 Aug 2002 23:09:18 GMT
amyroh      2002/08/20 16:09:18

  Modified:    catalina/src/share/org/apache/catalina/core
                        StandardHostDeployer.java StandardServer.java
  Log:
  Change install(String contextPath, URL war, String configFile) method
  to actually save context info to the configuration file you specify.
  
  Revision  Changes    Path
  1.4       +11 -4     jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/core/StandardHostDeployer.java
  
  Index: StandardHostDeployer.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/core/StandardHostDeployer.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- StandardHostDeployer.java	2 Aug 2002 01:37:43 -0000	1.3
  +++ StandardHostDeployer.java	20 Aug 2002 23:09:18 -0000	1.4
  @@ -75,10 +75,12 @@
   import org.apache.catalina.Container;
   import org.apache.catalina.Context;
   import org.apache.catalina.Deployer;
  +import org.apache.catalina.Engine;
   import org.apache.catalina.Globals;
   import org.apache.catalina.Lifecycle;
   import org.apache.catalina.LifecycleException;
   import org.apache.catalina.LifecycleListener;
  +import org.apache.catalina.core.StandardServer;
   import org.apache.catalina.startup.ContextRuleSet;
   import org.apache.catalina.startup.NamingRuleSet;
   import org.apache.catalina.util.StringManager;
  @@ -344,6 +346,11 @@
               host.fireContainerEvent(PRE_INSTALL_EVENT, context);
               host.addChild(context);
               host.fireContainerEvent(INSTALL_EVENT, context);
  +
  +            // save context info into configFile
  +            Engine engine = (Engine)host.getParent();
  +            StandardServer server = (StandardServer) engine.getService().getServer();
  +            server.storeContext(context);
           } catch (Exception e) {
               host.log(sm.getString("standardHost.installError", contextPath),
                        e);
  
  
  
  1.5       +61 -4     jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/core/StandardServer.java
  
  Index: StandardServer.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/core/StandardServer.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- StandardServer.java	14 Aug 2002 19:36:17 -0000	1.4
  +++ StandardServer.java	20 Aug 2002 23:09:18 -0000	1.5
  @@ -803,6 +803,63 @@
       }
   
   
  +    /**
  +     * Write the configuration information for <code>Context</code>
  +     * out to the specified configuration file.
  +     *
  +     * @exception InstanceNotFoundException if the managed resource object
  +     *  cannot be found
  +     * @exception MBeanException if the initializer of the object throws
  +     *  an exception, or persistence is not supported
  +     * @exception RuntimeOperationsException if an exception is reported
  +     *  by the persistence mechanism
  +     */
  +    public synchronized void storeContext(Context context) throws Exception {
  +
  +        String configFile = context.getConfigFile();
  +
  +        if (configFile != null) {
  +            File config = new File(configFile);
  +            if (!config.isAbsolute()) {
  +                config = new File(System.getProperty("catalina.base"),
  +                                        configFile);
  +            }
  +
  +            // Open an output writer for the new configuration file
  +            PrintWriter writer = null;
  +            try {
  +                writer = new PrintWriter(new FileWriter(config));
  +            } catch (IOException e) {
  +                if (writer != null) {
  +                    try {
  +                        writer.close();
  +                    } catch (Throwable t) {
  +                        ;
  +                    }
  +                }
  +                throw (e);
  +            }
  +
  +            writer.print("<Context");
  +            storeAttributes(writer, context);
  +            writer.println("</Context>");
  +
  +            // Flush and close the output file
  +            try {
  +                writer.flush();
  +            } catch (Exception e) {
  +                throw (e);
  +            }
  +            try {
  +                writer.close();
  +            } catch (Exception e) {
  +                throw (e);
  +            }
  +        }
  +
  +    }
  +
  +
       // -------------------------------------------------------- Private Methods
   
   
  
  
  

--
To unsubscribe, e-mail:   <mailto:tomcat-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:tomcat-dev-help@jakarta.apache.org>


Mime
View raw message