cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject cvs commit: xml-cocoon2/src/org/apache/cocoon/components/hsqldb Server.java ServerImpl.java
Date Sat, 08 Sep 2001 16:20:38 GMT
dims        01/09/08 09:20:38

  Modified:    src/org/apache/cocoon Cocoon.java
               src/org/apache/cocoon/components/hsqldb ServerImpl.java
  Added:       src/org/apache/cocoon/components/hsqldb Server.java
  Log:
  - Implement Avalon Startable interface in ServerImpl
  - Added a new Server interface
  
  Note: maybe we should rename the package org.apache.cocoon.components.hsqldb as org.apache.cocoon.components.server?
  
  Revision  Changes    Path
  1.26      +13 -1     xml-cocoon2/src/org/apache/cocoon/Cocoon.java
  
  Index: Cocoon.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/org/apache/cocoon/Cocoon.java,v
  retrieving revision 1.25
  retrieving revision 1.26
  diff -u -r1.25 -r1.26
  --- Cocoon.java	2001/09/08 11:45:49	1.25
  +++ Cocoon.java	2001/09/08 16:20:38	1.26
  @@ -24,6 +24,7 @@
   import org.apache.avalon.framework.context.Contextualizable;
   import org.apache.avalon.framework.logger.AbstractLoggable;
   import org.apache.avalon.framework.thread.ThreadSafe;
  +import org.apache.cocoon.components.hsqldb.Server;
   import org.apache.cocoon.components.language.generator.CompiledComponent;
   import org.apache.cocoon.components.language.generator.ProgramGenerator;
   import org.apache.cocoon.components.parser.Parser;
  @@ -57,7 +58,7 @@
    * @author <a href="mailto:fumagalli@exoffice.com">Pierpaolo Fumagalli</a>
(Apache Software Foundation, Exoffice Technologies)
    * @author <a href="mailto:stefano@apache.org">Stefano Mazzocchi</a>
    * @author <a href="mailto:leo.sutic@inspireinfrastructure.com">Leo Sutic</a>
  - * @version CVS $Revision: 1.25 $ $Date: 2001/09/08 11:45:49 $
  + * @version CVS $Revision: 1.26 $ $Date: 2001/09/08 16:20:38 $
    */
   public class Cocoon 
           extends AbstractLoggable 
  @@ -219,6 +220,17 @@
           getLogger().debug("Sitemap location = " + this.sitemapFileName);
           getLogger().debug("Checking sitemap reload = " + this.checkSitemapReload);
           getLogger().debug("Reloading sitemap asynchron = " + this.reloadSitemapAsynchron);
  +
  +        // Start the database server
  +        Server server = null;
  +        try {
  +            getLogger().debug("Starting database server");
  +            server = (Server) this.componentManager.lookup(Server.ROLE);
  +        } catch (Exception e){
  +            getLogger().error("Error starting database server",e);
  +        } finally {
  +            this.componentManager.release(server);
  +        }
       }
   
       /** Dump System Properties */
  
  
  
  1.2       +26 -19    xml-cocoon2/src/org/apache/cocoon/components/hsqldb/ServerImpl.java
  
  Index: ServerImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/org/apache/cocoon/components/hsqldb/ServerImpl.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ServerImpl.java	2001/09/07 14:30:10	1.1
  +++ ServerImpl.java	2001/09/08 16:20:38	1.2
  @@ -7,6 +7,7 @@
    *****************************************************************************/
   package org.apache.cocoon.components.hsqldb;
   
  +import org.apache.avalon.framework.activity.Startable;
   import org.apache.avalon.framework.configuration.Configurable;
   import org.apache.avalon.framework.configuration.Configuration;
   import org.apache.avalon.framework.configuration.ConfigurationException;
  @@ -18,8 +19,6 @@
   import org.apache.avalon.framework.thread.ThreadSafe;
   import org.apache.cocoon.Constants;
   
  -import org.hsqldb.Server;
  -
   import java.io.File;
   import java.io.IOException;
   import java.net.MalformedURLException;
  @@ -30,10 +29,11 @@
    *
    * @author <a href="mailto:dims@yahoo.com">Davanum Srinivas</a>
    */
  -public class ServerImpl extends AbstractLoggable implements Configurable,
  +public class ServerImpl extends AbstractLoggable implements Server, Configurable,
                                                                     Contextualizable,
                                                                     ThreadSafe,
  -                                                                  Runnable {
  +                                                                  Runnable,
  +                                                                  Startable {
     /** Arguments for running the server */
     private String arguments[] = new String[8];
   
  @@ -60,13 +60,6 @@
       arguments[3] = params.getParameter("silent","true");
       arguments[4] = "-trace";
       arguments[5] = params.getParameter("trace","false");
  -
  -    Thread server = new Thread(this);
  -    this.getLogger().debug("Intializing hsqldb server thread");
  -    server.setPriority(Thread.currentThread().getPriority());
  -    server.setDaemon(true);
  -    server.setName("hsqldb server");
  -    server.start();
     }
   
     /** Contextualize this class */
  @@ -84,15 +77,29 @@
           getLogger().error("IOException - Could not get database directory ", e);
       }
     }
  +
  +  /** Start the server */
  +  public void start() {
  +      Thread server = new Thread(this);
  +      this.getLogger().debug("Intializing hsqldb server thread");
  +      server.setPriority(Thread.currentThread().getPriority());
  +      server.setDaemon(true);
  +      server.setName("hsqldb server");
  +      server.start();
  +  }
   
  -  /** Run the server */
  +  /** Stop the server */
  +  public void stop() {
  +  }
  +
     public void run() {
  -    if(!started) {
  -        started = true;
  -        getLogger().debug("HSQLDB Server arguments are as follows:");
  -        for(int i=0;i<8;i++)
  -            getLogger().debug(i + " : " + arguments[i]);
  -        Server.main(arguments);
  -    }
  +      if(!started) {
  +          started = true;
  +          getLogger().debug("HSQLDB Server arguments are as follows:");
  +          for(int i=0;i<8;i++) {
  +              getLogger().debug(i + " : " + arguments[i]);
  +          }
  +          org.hsqldb.Server.main(arguments);
  +      }
     }
   }
  
  
  
  1.1                  xml-cocoon2/src/org/apache/cocoon/components/hsqldb/Server.java
  
  Index: Server.java
  ===================================================================
  /*****************************************************************************
   * Copyright (C) The Apache Software Foundation. All rights reserved.        *
   * ------------------------------------------------------------------------- *
   * This software is published under the terms of the Apache Software License *
   * version 1.1, a copy of which has been included  with this distribution in *
   * the LICENSE file.                                                         *
   *****************************************************************************/
  package org.apache.cocoon.components.hsqldb;
  
  import org.apache.avalon.framework.component.Component;
  
  /**
   *
   * @author <a href="mailto:dims@yahoo.org">Davanum Srinivas</a>
   * @version CVS $Revision: 1.1 $ $Date: 2001/09/08 16:20:38 $
   */
  public interface Server extends Component {
      String ROLE = "org.apache.cocoon.components.hsqldb.Server";
  }
  
  
  

----------------------------------------------------------------------
In case of troubles, e-mail:     webmaster@xml.apache.org
To unsubscribe, e-mail:          cocoon-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: cocoon-cvs-help@xml.apache.org


Mime
View raw message