shuber      2005/10/07 17:40:02 CEST

  Modified files:
    core                 jahia.iml 
    core/src/webapp/WEB-INF web.xml 
  Added files:
    core/src/java/org/jahia/bin HypersonicLauncherListener.java 
  Removed files:
    core/src/java/org/jahia/bin HypersonicLauncherServlet.java 
  Log:
  - Added compass files to IDEA project.
  - Modified HSQLDB launcher to be a context listener instead of a servlet so 
that it is sure it is shutdown after all the servlets are shutdown.
  
  Revision  Changes    Path
  1.17      +56 -0     jahia/core/jahia.iml
http://jahia.mine.nu:8080/cgi-bin/cvsweb.cgi/jahia/core/jahia.iml.diff?r1=1.16&r2=1.17&f=h
  1.1       +136 -0    
jahia/core/src/java/org/jahia/bin/HypersonicLauncherListener.java (new)
http://jahia.mine.nu:8080/cgi-bin/cvsweb.cgi/jahia/core/src/java/org/jahia/bin/HypersonicLauncherListener.java?rev=1.1&content-type=text/plain
  1.6       +0 -136    
jahia/core/src/java/org/jahia/bin/HypersonicLauncherServlet.java (dead)
http://jahia.mine.nu:8080/cgi-bin/cvsweb.cgi/jahia/core/src/java/org/jahia/bin/HypersonicLauncherServlet.java?rev=1.5&content-type=text/plain
  1.25      +36 -96    jahia/core/src/webapp/WEB-INF/web.xml
http://jahia.mine.nu:8080/cgi-bin/cvsweb.cgi/jahia/core/src/webapp/WEB-INF/web.xml.diff?r1=1.24&r2=1.25&f=h
  
  
  
  Index: jahia.iml
  ===================================================================
  RCS file: /home/cvs/repository/jahia/core/jahia.iml,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- jahia.iml 7 Oct 2005 14:08:00 -0000       1.16
  +++ jahia.iml 7 Oct 2005 15:40:01 -0000       1.17
  @@ -1205,6 +1205,42 @@
           <SOURCES />
         </library>
       </orderEntry>
  +    <orderEntry type="module-library">
  +      <library>
  +        <CLASSES>
  +          <root 
url="jar://$maven-rep$/compass/jars/compass-spring-0.6.0.jar!/" />
  +        </CLASSES>
  +        <JAVADOC />
  +        <SOURCES />
  +      </library>
  +    </orderEntry>
  +    <orderEntry type="module-library">
  +      <library>
  +        <CLASSES>
  +          <root 
url="jar://$maven-rep$/compass/jars/compass-core-0.6.0.jar!/" />
  +        </CLASSES>
  +        <JAVADOC />
  +        <SOURCES />
  +      </library>
  +    </orderEntry>
  +    <orderEntry type="module-library">
  +      <library>
  +        <CLASSES>
  +          <root 
url="jar://$maven-rep$/compass/jars/compass-vocabulary-0.6.0.jar!/" />
  +        </CLASSES>
  +        <JAVADOC />
  +        <SOURCES />
  +      </library>
  +    </orderEntry>
  +    <orderEntry type="module-library">
  +      <library>
  +        <CLASSES>
  +          <root url="jar://$maven-rep$/compass/jars/compass-gps-0.6.0.jar!/" 
/>
  +        </CLASSES>
  +        <JAVADOC />
  +        <SOURCES />
  +      </library>
  +    </orderEntry>
       <orderEntryProperties />
     </component>
     <component name="WebModuleBuildComponent">
  @@ -1354,6 +1390,26 @@
       </containerElement>
       <containerElement type="library" level="module">
         <attribute name="method" value="1" />
  +      <attribute name="URI" value="/WEB-INF/lib/compass-core-0.6.0.jar" />
  +      <url>jar://$maven-rep$/compass/jars/compass-core-0.6.0.jar!/</url>
  +    </containerElement>
  +    <containerElement type="library" level="module">
  +      <attribute name="method" value="1" />
  +      <attribute name="URI" value="/WEB-INF/lib/compass-gps-0.6.0.jar" />
  +      <url>jar://$maven-rep$/compass/jars/compass-gps-0.6.0.jar!/</url>
  +    </containerElement>
  +    <containerElement type="library" level="module">
  +      <attribute name="method" value="1" />
  +      <attribute name="URI" value="/WEB-INF/lib/compass-spring-0.6.0.jar" />
  +      <url>jar://$maven-rep$/compass/jars/compass-spring-0.6.0.jar!/</url>
  +    </containerElement>
  +    <containerElement type="library" level="module">
  +      <attribute name="method" value="1" />
  +      <attribute name="URI" 
value="/WEB-INF/lib/compass-vocabulary-0.6.0.jar" />
  +      
<url>jar://$maven-rep$/compass/jars/compass-vocabulary-0.6.0.jar!/</url>
  +    </containerElement>
  +    <containerElement type="library" level="module">
  +      <attribute name="method" value="1" />
         <attribute name="URI" value="/WEB-INF/lib/concurrent-1.3.4.jar" />
         <url>jar://$maven-rep$/concurrent/jars/concurrent-1.3.4.jar!/</url>
       </containerElement>
  
  
  
  Index: web.xml
  ===================================================================
  RCS file: /home/cvs/repository/jahia/core/src/webapp/WEB-INF/web.xml,v
  retrieving revision 1.24
  retrieving revision 1.25
  diff -u -r1.24 -r1.25
  --- web.xml   9 Sep 2005 12:48:06 -0000       1.24
  +++ web.xml   7 Oct 2005 15:40:02 -0000       1.25
  @@ -7,6 +7,38 @@
   <web-app>
       <display-name>jahia</display-name>
   
  +     <!--
  +    <context-param>
  +        <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
  +        <param-value>server</param-value>
  +    </context-param>
  +     -->
  +
  +    <context-param>
  +        <param-name>hsqldb.location</param-name>
  +        <param-value>/WEB-INF/var/dbdata/hsqldbjahia</param-value>
  +    </context-param>
  +
  +    <context-param>
  +        <param-name>hsqldb.port</param-name>
  +        <param-value>9001</param-value>
  +    </context-param>
  +
  +    <context-param>
  +        <param-name>hsqldb.silent</param-name>
  +        <param-value>true</param-value>
  +    </context-param>
  +
  +    <context-param>
  +        <param-name>hsqldb.trace</param-name>
  +        <param-value>false</param-value>
  +    </context-param>
  +
  +    <context-param>
  +        <param-name>jahia.config</param-name>
  +        <param-value>/WEB-INF/etc/config/jahia.properties</param-value>
  +    </context-param>
  +
       <!-- Display request URLs-->
       <filter>
           <filter-name>ESIHeaderFilter</filter-name>
  @@ -19,7 +51,7 @@
       <filter>
           <filter-name>NtlmHttpFilter</filter-name>
           
<filter-class>org.jahia.bin.filters.ntlm.NtlmHttpFilter</filter-class>
  -    
  +
           <init-param>
               <param-name>jcifs.smb.client.domain</param-name>
               <param-value>JAHIA</param-value>
  @@ -49,105 +81,13 @@
           <listener-class>org.jahia.bin.JahiaWebAppListener</listener-class>
       </listener>
   
  -     <!--
  -    <context-param>
  -        <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
  -        <param-value>server</param-value>
  -    </context-param>
  -     -->
  +    <listener>
  +        
<listener-class>org.jahia.bin.HypersonicLauncherListener</listener-class>
  +    </listener>
   
        <!-- Let's try to keep this list ordered by loading mode, so that it's
             easier to maintain, thank you -->
   
  -    <servlet>
  -      <servlet-name>hsqlLauncher</servlet-name>
  -      <servlet-class>org.jahia.bin.HypersonicLauncherServlet</servlet-class>
  -
  -      <init-param>
  -        <param-name>location</param-name>
  -        <param-value>/WEB-INF/var/dbdata/hsqldbjahia</param-value>
  -      </init-param>
  -
  -      <init-param>
  -        <param-name>port</param-name>
  -        <param-value>9001</param-value>
  -      </init-param>
  -
  -      <init-param>
  -        <param-name>silent</param-name>
  -        <param-value>true</param-value>
  -      </init-param>
  -
  -      <init-param>
  -        <param-name>trace</param-name>
  -        <param-value>false</param-value>
  -      </init-param>
  -
  -      <init-param>
  -        <param-name>jahia.config</param-name>
  -        <param-value>/WEB-INF/etc/config/jahia.properties</param-value>
  -      </init-param>
  -
  -                             <!-- lucene system property parameter -->
  -                             <!--
  -                             Lucene Property         System Property         
                                        Default Value
  -                             mergeFactor             
org.apache.lucene.mergeFactor                   10
  -                             minMergeDocs            
org.apache.lucene.minMergeDocs                  10
  -                             maxMergeDocs            
org.apache.lucene.maxMergeDocs                  Integer.MAX_VALUE
  -                             maxFieldLength          
org.apache.lucene.maxFieldLength                10000
  -                             COMMIT_LOCK_TIMEOUT 
org.apache.lucene.commitLockTimeout         10000 ms
  -                             WRITE_LOCK_TIMEOUT  
org.apache.lucene.writeLockTimeout          1000 ms
  -                             maxClauseCount          
org.apache.lucene.maxClauseCount                1024
  -                             lockDir                         
org.apache.lucene.lockDir                               the value of 
java.io.tmpdir system property
  -                             -->
  -        <init-param>
  -            <param-name>org.apache.lucene.mergeFactor</param-name>
  -            <param-value>10</param-value>
  -        </init-param>
  -        <init-param>
  -            <param-name>org.apache.lucene.minMergeDocs</param-name>
  -            <param-value>10</param-value>
  -        </init-param>
  -        <init-param>
  -            <param-name>org.apache.lucene.commitLockTimeout</param-name>
  -            <param-value>60000</param-value>
  -        </init-param>
  -        <init-param>
  -            <param-name>org.apache.lucene.writeLockTimeout</param-name>
  -            <param-value>6000</param-value>
  -        </init-param>
  -        <init-param>
  -            <param-name>org.apache.lucene.maxClauseCount</param-name>
  -            <param-value>10000</param-value>
  -        </init-param>
  -        <init-param>
  -            <param-name>org.apache.lucene.searchIndexRootDir</param-name>
  -            <param-value>/WEB-INF/var/search_indexes</param-value>
  -        </init-param>
  -        <init-param>
  -            <param-name>org.apache.lucene.localIndexing</param-name>
  -            <param-value>1</param-value> <!-- 1: allow local indexing, 0: do 
not index ( when sharing a same index directory in a clustered environment -->
  -        </init-param>
  -        <init-param>
  -            
<param-name>org.apache.lucene.backgroundIndexing.priority</param-name>
  -            <param-value>3</param-value> <!-- define the priority of 
indexation in background 1 = Thread.MIN_PRIORITY, 5 = Thread.NORM_PRIORITY, 10 
= Thread.MAX_PRIORITY -->
  -        </init-param>
  -        <init-param>
  -            
<param-name>org.apache.lucene.fileExtractionAbortTime</param-name>
  -            <param-value>120000</param-value> <!-- define the max delay of 
time after which, a file extraction is aborted ( to avoid CPU burst by infinite 
loop ) -->
  -        </init-param>
  -        <init-param>
  -            <param-name>org.apache.lucene.fieldRelevanceWeight</param-name>
  -            <param-value>1</param-value> <!-- define the weight of field 
relevance average by page -->
  -        </init-param>
  -        <init-param>
  -            <param-name>org.apache.lucene.pageHitRelevanceWeight</param-name>
  -            <param-value>3</param-value> <!-- define the weight of nb Hit by 
page -->
  -        </init-param>
  -
  -      <load-on-startup>1</load-on-startup>
  -    </servlet>
  -
     <servlet>
       <servlet-name>jetspeed</servlet-name>
       <servlet-class>org.jahia.bin.JahiaJetspeedServlet</servlet-class>
  
  
  
  Index: HypersonicLauncherListener.java
  ====================================================================
  package org.jahia.bin;
  
  import org.hsqldb.Server;
  import org.hsqldb.ServerConstants;
  
  import javax.servlet.http.HttpServlet;
  import javax.servlet.http.HttpServletRequest;
  import javax.servlet.http.HttpServletResponse;
  import javax.servlet.ServletContextListener;
  import javax.servlet.ServletContextEvent;
  import javax.servlet.ServletContext;
  
  import java.io.InputStream;
  import java.net.URL;
  import java.util.Properties;
  import java.lang.RuntimeException;
  import java.sql.Connection;
  import java.sql.DriverManager;
  import java.sql.Statement;
  import java.io.File;
  import java.io.FileInputStream;
  import java.io.FileNotFoundException;
  import java.io.IOException;
  
  public class HypersonicLauncherListener implements ServletContextListener {
  
      String args[] = new String[10];
      Thread serverThread;
      Server hsqldbServer;
      String dbLocation;
      String dbPortStr;
      String dbSilent;
      String dbTrace;
      String jahiaConfigFileName;
      boolean startHSQLServer = false;
  
      public void contextInitialized(ServletContextEvent servletContextEvent) {
  
          ServletContext servletContext = 
servletContextEvent.getServletContext();
  
          dbLocation = servletContext.getInitParameter("hsqldb.location");
          dbPortStr = servletContext.getInitParameter("hsqldb.port");
          dbSilent = servletContext.getInitParameter("hsqldb.silent");
          dbTrace = servletContext.getInitParameter("hsqldb.trace");
          jahiaConfigFileName = servletContext.getInitParameter("jahia.config");
  
          servletContext.log("dbLocation=" + dbLocation);
          String realPath = servletContext.getRealPath(dbLocation);
          servletContext.log("realPath = " + realPath);
  
          servletContext.log("jahia.config=" + jahiaConfigFileName);
          String realJahiaConfigFileName = 
servletContext.getRealPath(jahiaConfigFileName);
          File jahiaConfigFile = new File(realJahiaConfigFileName);
          if (jahiaConfigFile.exists()) {
              Properties jahiaConfigProps = new Properties();
              try {
                  jahiaConfigProps.load(new FileInputStream(jahiaConfigFile));
                  String startHSQLServerStr = 
jahiaConfigProps.getProperty("db_starthsqlserver");
                  if (startHSQLServerStr == null) {
                      startHSQLServerStr = "false";
                  }
                  startHSQLServer = 
Boolean.valueOf(startHSQLServerStr).booleanValue();
                  if (!startHSQLServer) {
                      servletContext.log("HSQL server will not be started.");
                      return;
                  }
  
              } catch (FileNotFoundException fnfe) {
                  servletContext.log("Problem finding file " + 
jahiaConfigFileName, fnfe);
              } catch (IOException ioe) {
                  servletContext.log("Problem while loading file " + 
jahiaConfigFileName, ioe);
              }
          }
  
          hsqldbServer = new Server();
          // hsqldbServer.setDatabaseName(0,"hsqldbjahia");
          hsqldbServer.setDatabasePath(0,"file:"+realPath);
          //hsqldbServer.setLogWriter(null);
          //hsqldbServer.setErrWriter(null);
          hsqldbServer.setNoSystemExit(true);
          hsqldbServer.setPort(Integer.parseInt(dbPortStr));
          hsqldbServer.setTrace(Boolean.valueOf(dbTrace).booleanValue());
          hsqldbServer.setSilent(Boolean.valueOf(dbSilent).booleanValue());
          servletContext.log("Starting HSQLDB server");
          hsqldbServer.start();
  
          startHSQLServer = true;
  
          // now let's wait until the database is ready.
          servletContext.log("Waiting for database to start...");
          boolean starting = true;
          while (starting) {
              Thread.yield();
              try {
                  Class.forName("org.hsqldb.jdbcDriver");
                  String url = "jdbc:hsqldb:hsql://127.0.0.1:" + dbPortStr;
                  Connection con = DriverManager.getConnection(url, "sa", "");
                  String sql = "COMMIT";
                  Statement stmt = con.createStatement();
                  stmt.executeUpdate(sql);
                  stmt.close();
                  starting = false;
              } catch (Exception e) {
                  starting = true;
              }
          }
      }
  
      public void contextDestroyed(ServletContextEvent servletContextEvent) {
          if (startHSQLServer) {
              ServletContext servletContext = 
servletContextEvent.getServletContext();
              kill(Integer.parseInt(dbPortStr), "sa", "");
              hsqldbServer.stop();
              servletContext.log("HSQLDB server stopping, waiting...");
              while (hsqldbServer.getState() != 
ServerConstants.SERVER_STATE_SHUTDOWN) {
                  // loop
              }
              servletContext.log("HSQLDB now properly shutdown.");
              startHSQLServer = false;
          }
      }
  
      private void kill (int port, String user, String password) {
          try {
              Class.forName("org.hsqldb.jdbcDriver");
              String url = "jdbc:hsqldb:hsql://127.0.0.1:" + port;
              Connection con = DriverManager.getConnection(url, user, password);
              String sql = "SHUTDOWN";
              Statement stmt = con.createStatement();
              stmt.executeUpdate(sql);
              stmt.close();
          } catch (Exception e) {
          }
      }
  
  }
  

Reply via email to