Done. Please try it when you get a chance.

-- dims

--- giacomo <[EMAIL PROTECTED]> wrote:
> On 7 Sep 2001 [EMAIL PROTECTED] wrote:
> 
> > dims        01/09/07 07:30:10
> >
> <snip/>
> >
> >   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.
> >
> <snip/>
> >
> 
> I'd suggest to implement Startable as well and start the Thread in the
> start method. This will have the advantage to even stop the thread in
> the needed stop method which make it confirm better to the Avalon
> lifecycle.
> 
> Giacomo
> 
> >   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:[EMAIL PROTECTED]";>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:     [EMAIL PROTECTED]
> > To unsubscribe, e-mail:          [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
> >
> >
> >
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, email: [EMAIL PROTECTED]
> 


=====
Davanum Srinivas, JNI-FAQ Manager
http://www.jGuru.com/faq/JNI

__________________________________________________
Do You Yahoo!?
Get email alerts & NEW webcam video instant messaging with Yahoo! Messenger
http://im.yahoo.com

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

Reply via email to