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/webapp cocoon.xconf
Date Fri, 07 Sep 2001 14:30:10 GMT
dims        01/09/07 07:30:10

  Modified:    .        database.properties
               src/org/apache/cocoon cocoon.roles
               webapp   cocoon.xconf
  Added:       lib      hsqldb-1.61.jar
               src/org/apache/cocoon/components/hsqldb ServerImpl.java
  Removed:     lib      hsqldb.jar
  Log:
  Ability to run HSQLDB Server as a Cocoon Component. Now we can run Cocoon samples out of
the box with relying on the @install.war@ filter in database.properties file.
  
  Revision  Changes    Path
  1.2       +1 -1      xml-cocoon2/database.properties
  
  Index: database.properties
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/database.properties,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- database.properties	2001/05/09 20:49:26	1.1
  +++ database.properties	2001/09/07 14:30:09	1.2
  @@ -2,7 +2,7 @@
   database-driver=org.hsqldb.jdbcDriver
   
   # Specify the URL for the Database
  -database-url=jdbc:hsqldb:${install.war}/cocoon/WEB-INF/db/cocoondb
  +database-url=jdbc:hsqldb:hsql://localhost:9002
   
   # Specify the user id
   database-user=sa
  
  
  
  1.1                  xml-cocoon2/lib/hsqldb-1.61.jar
  
  	<<Binary file>>
  
  
  1.21      +4 -0      xml-cocoon2/src/org/apache/cocoon/cocoon.roles
  
  Index: cocoon.roles
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/org/apache/cocoon/cocoon.roles,v
  retrieving revision 1.20
  retrieving revision 1.21
  diff -u -r1.20 -r1.21
  --- cocoon.roles	2001/09/05 11:56:26	1.20
  +++ cocoon.roles	2001/09/07 14:30:10	1.21
  @@ -96,6 +96,10 @@
          shorthand="store-janitor"
          default-class="org.apache.cocoon.components.store.StoreJanitorImpl"/>
   
  + <role name="org.apache.cocoon.components.hsqldb.Server"
  +       shorthand="hsqldb-server"
  +       default-class="org.apache.cocoon.components.hsqldb.ServerImpl"/>
  +
    <role name="org.apache.cocoon.components.profiler.Profiler"
          shorthand="profiler"
          default-class="org.apache.cocoon.components.profiler.SimpleProfiler"/>
  
  
  
  1.1                  xml-cocoon2/src/org/apache/cocoon/components/hsqldb/ServerImpl.java
  
  Index: ServerImpl.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.configuration.Configurable;
  import org.apache.avalon.framework.configuration.Configuration;
  import org.apache.avalon.framework.configuration.ConfigurationException;
  import org.apache.avalon.framework.context.Context;
  import org.apache.avalon.framework.context.ContextException;
  import org.apache.avalon.framework.context.Contextualizable;
  import org.apache.avalon.framework.logger.AbstractLoggable;
  import org.apache.avalon.framework.parameters.Parameters;
  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;
  import java.util.ArrayList;
  
  /**
   * This class runs an instance of HSQLDB Server.
   *
   * @author <a href="mailto:dims@yahoo.com">Davanum Srinivas</a>
   */
  public class ServerImpl extends AbstractLoggable implements Configurable,
                                                                    Contextualizable,
                                                                    ThreadSafe,
                                                                    Runnable {
    /** Arguments for running the server */
    private String arguments[] = new String[8];
  
    /** Check if the server has already been started */
    private boolean started = false;
  
    /**
     * Initialize the ServerImpl.
     * A few options can be used :
     * <UL>
     *  <LI>port = port where the server is listening</LI>
     *  <LI>silent = display all queries</LI>
     *  <LI>trace = print JDBC trace messages</LI>
     * </UL>
     */
    public void configure(Configuration conf) throws ConfigurationException {
      this.getLogger().debug("Configure ServerImpl");
  
      Parameters params = Parameters.fromConfiguration(conf);
  
      arguments[0] = "-port";
      arguments[1] = params.getParameter("port","9002");
      arguments[2] = "-silent";
      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 */
    public void contextualize(Context context) throws ContextException {
      org.apache.cocoon.environment.Context ctx =
          (org.apache.cocoon.environment.Context) context.get(Constants.CONTEXT_ENVIRONMENT_CONTEXT);
      try {
          arguments[6] = "-database";
          arguments[7] = new File(ctx.getRealPath("/WEB-INF/db")).getCanonicalPath();
          arguments[7] += File.separator + "cocoondb";
          getLogger().debug("database is " + arguments[7]);
      } catch (MalformedURLException e) {
          getLogger().error("MalformedURLException - Could not get database directory ", e);
      } catch (IOException e) {
          getLogger().error("IOException - Could not get database directory ", e);
      }
    }
  
    /** Run the server */
    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);
      }
    }
  }
  
  
  1.32      +12 -0     xml-cocoon2/webapp/cocoon.xconf
  
  Index: cocoon.xconf
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/webapp/cocoon.xconf,v
  retrieving revision 1.31
  retrieving revision 1.32
  diff -u -r1.31 -r1.32
  --- cocoon.xconf	2001/09/05 11:56:27	1.31
  +++ cocoon.xconf	2001/09/07 14:30:10	1.32
  @@ -18,6 +18,18 @@
     <parser class="org.apache.cocoon.components.parser.XercesParser"/>
     -->
   
  +  <!-- HSQLDB Server for samples. Comment this section out if you don't care about the
samples.
  +        port   : number      port where the server is listening
  +        silent : true/false  display all queries
  +        trace  : true/false  display JDBC trace messages
  +  -->
  +  <hsqldb-server class="org.apache.cocoon.components.hsqldb.ServerImpl" 
  +                 pool-max="1" pool-min="1">
  +     <parameter name="port" value="9002"/>
  +     <parameter name="silent" value="true"/>
  +     <parameter name="trace" value="false"/>
  +  </hsqldb-server>
  +
     <!-- Storing:
          maxobjects: Indicates how many objects will be hold in the cache.
                      When the number of maxobjects has been reached. The
  
  
  

----------------------------------------------------------------------
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