cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r491810 - in /cocoon/trunk/blocks/cocoon-hsqldb/cocoon-hsqldb-impl: ./ src/main/java/org/apache/cocoon/components/hsqldb/ src/main/resources/META-INF/cocoon/avalon/ src/main/resources/META-INF/cocoon/spring/ src/main/resources/org/
Date Tue, 02 Jan 2007 15:11:42 GMT
Author: cziegeler
Date: Tue Jan  2 07:11:41 2007
New Revision: 491810

URL: http://svn.apache.org/viewvc?view=rev&rev=491810
Log:
Remove dependencies to avalon and cocoon core

Added:
    cocoon/trunk/blocks/cocoon-hsqldb/cocoon-hsqldb-impl/src/main/resources/META-INF/cocoon/spring/
    cocoon/trunk/blocks/cocoon-hsqldb/cocoon-hsqldb-impl/src/main/resources/META-INF/cocoon/spring/cocoon-hsqldb-block.xml
  (with props)
Removed:
    cocoon/trunk/blocks/cocoon-hsqldb/cocoon-hsqldb-impl/src/main/resources/META-INF/cocoon/avalon/cocoon-hsqldb.xconf
    cocoon/trunk/blocks/cocoon-hsqldb/cocoon-hsqldb-impl/src/main/resources/org/
Modified:
    cocoon/trunk/blocks/cocoon-hsqldb/cocoon-hsqldb-impl/pom.xml
    cocoon/trunk/blocks/cocoon-hsqldb/cocoon-hsqldb-impl/src/main/java/org/apache/cocoon/components/hsqldb/Server.java
    cocoon/trunk/blocks/cocoon-hsqldb/cocoon-hsqldb-impl/src/main/java/org/apache/cocoon/components/hsqldb/ServerImpl.java
    cocoon/trunk/blocks/cocoon-hsqldb/cocoon-hsqldb-impl/status.xml

Modified: cocoon/trunk/blocks/cocoon-hsqldb/cocoon-hsqldb-impl/pom.xml
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-hsqldb/cocoon-hsqldb-impl/pom.xml?view=diff&rev=491810&r1=491809&r2=491810
==============================================================================
--- cocoon/trunk/blocks/cocoon-hsqldb/cocoon-hsqldb-impl/pom.xml (original)
+++ cocoon/trunk/blocks/cocoon-hsqldb/cocoon-hsqldb-impl/pom.xml Tue Jan  2 07:11:41 2007
@@ -37,19 +37,18 @@
   <dependencies>
     <dependency>
       <groupId>org.apache.cocoon</groupId>
-      <artifactId>cocoon-core</artifactId>
-      <version>2.2.0-M3-SNAPSHOT</version>
+      <artifactId>cocoon-spring-configurator</artifactId>
+      <version>1.0.0-SNAPSHOT</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.cocoon</groupId>
+      <artifactId>cocoon-thread-impl</artifactId>
+      <version>1.0.0-SNAPSHOT</version>
     </dependency>
     <dependency>
       <groupId>hsqldb</groupId>
       <artifactId>hsqldb</artifactId>
       <version>1.8.0.7</version>
-    </dependency>
-    <dependency>
-      <groupId>javax.servlet</groupId>
-      <artifactId>servlet-api</artifactId>
-      <version>2.4</version>
-      <scope>provided</scope>
     </dependency>
   </dependencies>
 </project>

Modified: cocoon/trunk/blocks/cocoon-hsqldb/cocoon-hsqldb-impl/src/main/java/org/apache/cocoon/components/hsqldb/Server.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-hsqldb/cocoon-hsqldb-impl/src/main/java/org/apache/cocoon/components/hsqldb/Server.java?view=diff&rev=491810&r1=491809&r2=491810
==============================================================================
--- cocoon/trunk/blocks/cocoon-hsqldb/cocoon-hsqldb-impl/src/main/java/org/apache/cocoon/components/hsqldb/Server.java
(original)
+++ cocoon/trunk/blocks/cocoon-hsqldb/cocoon-hsqldb-impl/src/main/java/org/apache/cocoon/components/hsqldb/Server.java
Tue Jan  2 07:11:41 2007
@@ -17,10 +17,10 @@
 package org.apache.cocoon.components.hsqldb;
 
 /**
- *
+ * @deprecated This interface will be removed in upcoming versions as it is unused.
  * @version $Id$
  */
 public interface Server  {
-    
+
     String ROLE = Server.class.getName();
 }

Modified: cocoon/trunk/blocks/cocoon-hsqldb/cocoon-hsqldb-impl/src/main/java/org/apache/cocoon/components/hsqldb/ServerImpl.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-hsqldb/cocoon-hsqldb-impl/src/main/java/org/apache/cocoon/components/hsqldb/ServerImpl.java?view=diff&rev=491810&r1=491809&r2=491810
==============================================================================
--- cocoon/trunk/blocks/cocoon-hsqldb/cocoon-hsqldb-impl/src/main/java/org/apache/cocoon/components/hsqldb/ServerImpl.java
(original)
+++ cocoon/trunk/blocks/cocoon-hsqldb/cocoon-hsqldb-impl/src/main/java/org/apache/cocoon/components/hsqldb/ServerImpl.java
Tue Jan  2 07:11:41 2007
@@ -19,22 +19,11 @@
 import java.io.File;
 import java.io.IOException;
 
-import org.apache.avalon.framework.CascadingRuntimeException;
-import org.apache.avalon.framework.activity.Startable;
-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.AbstractLogEnabled;
-import org.apache.avalon.framework.parameters.Parameterizable;
-import org.apache.avalon.framework.parameters.Parameters;
-import org.apache.avalon.framework.parameters.ParameterException;
-import org.apache.avalon.framework.service.ServiceException;
-import org.apache.avalon.framework.service.ServiceManager;
-import org.apache.avalon.framework.service.Serviceable;
-import org.apache.avalon.framework.thread.ThreadSafe;
+import javax.servlet.ServletContext;
 
-import org.apache.cocoon.Constants;
 import org.apache.cocoon.components.thread.RunnableManager;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 import org.hsqldb.Database;
 import org.hsqldb.DatabaseManager;
 
@@ -43,9 +32,8 @@
  *
  * @version $Id$
  */
-public class ServerImpl extends AbstractLogEnabled
-                        implements Server, Parameterizable, Contextualizable,
-                                   ThreadSafe, Runnable, Serviceable, Startable {
+public class ServerImpl
+       implements Runnable {
 
     private static final boolean DEFAULT_TRACE = false;
     private static final boolean DEFAULT_SILENT = true;
@@ -54,103 +42,145 @@
     private static final String DEFAULT_DB_NAME = "cocoondb";
     private static final String DEFAULT_DB_PATH = "context://WEB-INF/db";
 
-    /** Cocoon context **/
-    private org.apache.cocoon.environment.Context cocoonContext;
-
     /** The HSQLDB HSQL protocol network database server instance **/
     private org.hsqldb.Server hsqlServer = new org.hsqldb.Server();
 
     /** The threadpool name to be used for daemon thread */
-    private String m_daemonThreadPoolName = "daemon";
+    private String daemonThreadPoolName = "daemon";
+
+    /** The path to the db. */
+    private String path = DEFAULT_DB_PATH;
+
+    /** By default we use the logger for this class. */
+    private Log logger = LogFactory.getLog(getClass());
+
+    /** The servlet context. */
+    private ServletContext servletContext;
+
+    /** The db name. */
+    private String name = DEFAULT_DB_NAME;
+
+    /** The runnable manager. */
+    private RunnableManager runnableManager;
+
+    private boolean trace = DEFAULT_TRACE;
+    private boolean silent = DEFAULT_SILENT;
+    private int port = DEFAULT_PORT;
+
+    public ServerImpl() {
+        hsqlServer.setLogWriter(null); /* Remove console log */
+        hsqlServer.setErrWriter(null); /* Remove console log */
+        hsqlServer.setNoSystemExit(true);        
+    }
+
+    public Log getLogger() {
+        return this.logger;
+    }
+
+    public void setLogger(Log l) {
+        this.logger = l;
+    }
+
+    public org.hsqldb.Server getServer() {
+        return this.hsqlServer;
+    }
+
+    public void setThreadPoolName(String name) {
+        this.daemonThreadPoolName = name;
+    }
+
+    public void setPath(String newPath) {
+        this.path = newPath;
+    }
+
+    public void setPort(int p) {
+        this.port = p;
+    }
+
+    public void setSilent(boolean silent) {
+        this.silent = silent;
+    }
 
-    /** The {@link ServiceManager} instance */
-    private ServiceManager m_serviceManager;
+    public void setTrace(boolean trace) {
+        this.trace = trace;
+    }
+
+    public void setName(String newName) {
+        this.name = newName;
+    }
+
+    public void setServletContext(ServletContext c) {
+        this.servletContext = c;
+    }
 
-    /** Contextualize this class */
-    public void contextualize(Context context) throws ContextException {
-        cocoonContext = (org.apache.cocoon.environment.Context) context.get(Constants.CONTEXT_ENVIRONMENT_CONTEXT);
+    public void setRunnableManager(RunnableManager runnableManager) {
+        this.runnableManager = runnableManager;
     }
 
     /**
      * Initialize the ServerImpl.
-     * Posible options:
-     * <ul>
-     *  <li>port = port where the server is listening</li>
-     *  <li>silent = false => display all queries</li>
-     *  <li>trace = print JDBC trace messages</li>
-     *  <li>name = name of the HSQL-DB</li>
-     *  <li>path = path to the database - context-protocol is resolved</li>
-     * </ul>
      */
-    public void parameterize(Parameters params) throws ParameterException {
-        hsqlServer.setLogWriter(null); /* Remove console log */
-        hsqlServer.setErrWriter(null); /* Remove console log */
-        hsqlServer.setPort(params.getParameterAsInteger("port", DEFAULT_PORT));
-        hsqlServer.setSilent(params.getParameterAsBoolean("silent", DEFAULT_SILENT));
-        hsqlServer.setTrace(params.getParameterAsBoolean("trace", DEFAULT_TRACE));
-        hsqlServer.setNoSystemExit(true);
+    public void init() {
+        this.hsqlServer.setSilent(this.silent);
+        this.hsqlServer.setTrace(this.trace);
+        this.hsqlServer.setPort(this.port);
         if (getLogger().isDebugEnabled()) {
             getLogger().debug("Configure HSQLDB with port: " + hsqlServer.getPort() +
                               ", silent: " + hsqlServer.isSilent() +
                               ", trace: " + hsqlServer.isTrace());
         }
 
-        m_daemonThreadPoolName = params.getParameter("thread-pool-name", m_daemonThreadPoolName);
-
-        final String dbCfgPath = params.getParameter("path", DEFAULT_DB_PATH);
+        final String dbCfgPath = this.path;
         String dbPath = dbCfgPath;
         // Test if we are running inside a WAR file
         if(dbPath.startsWith(ServerImpl.CONTEXT_PROTOCOL)) {
-            dbPath = this.cocoonContext.getRealPath(dbPath.substring(ServerImpl.CONTEXT_PROTOCOL.length()));
+            dbPath = this.servletContext.getRealPath(dbPath.substring(ServerImpl.CONTEXT_PROTOCOL.length()));
         }
         if (dbPath == null) {
-            throw new ParameterException("The hsqldb cannot be used inside an unexpanded
WAR file. " +
+            throw new IllegalArgumentException("The hsqldb cannot be used inside an unexpanded
WAR file. " +
                                          "Real path for <" + dbCfgPath + "> is null.");
         }
 
-        String dbName = params.getParameter("name", DEFAULT_DB_NAME);
         try {
-            hsqlServer.setDatabasePath(0, new File(dbPath).getCanonicalPath() + File.separator
+ dbName);
+            hsqlServer.setDatabasePath(0, new File(dbPath).getCanonicalPath() + File.separator
+ name);
         } catch (IOException e) {
-            throw new ParameterException("Could not get database directory <" + dbPath
+ ">", e);
+            throw new RuntimeException("Could not get database directory <" + dbPath +
">", e);
         }
 
         if (getLogger().isDebugEnabled()) {
             getLogger().debug("Database path is <" + hsqlServer.getDatabasePath(0, true)
+ ">");
         }
+        this.start();
     }
 
     /**
-     * @param serviceManager The <@link ServiceManager} instance
-     * @throws ServiceException In case we cannot find a service needed
+     * Destroy the server and release everything.
      */
-    public void service(ServiceManager serviceManager) throws ServiceException {
-        m_serviceManager = serviceManager;
+    public void destroy() {
+        this.stop();
     }
 
-    /** Start the server */
-    public void start() {
-        RunnableManager runnableManager = null;
-        try {
-            runnableManager = (RunnableManager) m_serviceManager.lookup(RunnableManager.ROLE);
-            runnableManager.execute(m_daemonThreadPoolName, this);
-        } catch(final ServiceException e) {
-            throw new CascadingRuntimeException("Cannot get RunnableManager", e);
-        } finally {
-            if (null != runnableManager) {
-                m_serviceManager.release(runnableManager);
-            }
-        }
+    /** 
+     * Start the server.
+     */
+    protected void start() {
+        this.runnableManager.execute(this.daemonThreadPoolName, this);
     }
 
-    /** Stop the server */
-    public void stop() {
-        getLogger().debug("Shutting down HSQLDB");
+    /**
+     * Stop the server.
+     */
+    protected void stop() {
+        if ( this.getLogger().isDebugEnabled() ) {
+            getLogger().debug("Shutting down HSQLDB");
+        }
         // AG: Temporally workaround for http://issues.apache.org/jira/browse/COCOON-1862
         // A newer version of hsqldb or SAP NetWeaver may not need the next line
         DatabaseManager.closeDatabases(Database.CLOSEMODE_COMPACT);
-        hsqlServer.stop();
-        getLogger().debug("Shutting down HSQLDB: Done");
+        this.hsqlServer.stop();
+        if ( this.getLogger().isDebugEnabled() ) {
+            getLogger().debug("Shutting down HSQLDB: Done");
+        }
     }
 
     /** Run the server */

Added: cocoon/trunk/blocks/cocoon-hsqldb/cocoon-hsqldb-impl/src/main/resources/META-INF/cocoon/spring/cocoon-hsqldb-block.xml
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-hsqldb/cocoon-hsqldb-impl/src/main/resources/META-INF/cocoon/spring/cocoon-hsqldb-block.xml?view=auto&rev=491810
==============================================================================
--- cocoon/trunk/blocks/cocoon-hsqldb/cocoon-hsqldb-impl/src/main/resources/META-INF/cocoon/spring/cocoon-hsqldb-block.xml
(added)
+++ cocoon/trunk/blocks/cocoon-hsqldb/cocoon-hsqldb-impl/src/main/resources/META-INF/cocoon/spring/cocoon-hsqldb-block.xml
Tue Jan  2 07:11:41 2007
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN"
+    "http://www.springframework.org/dtd/spring-beans-2.0.dtd">
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+<!-- @version $Id$ -->
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xmlns:util="http://www.springframework.org/schema/util"
+       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
+                           http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.0.xsd">
+
+  <!--+
+      | HSQLDB Server for samples:
+      |
+      |  port   : number      port where the server is listening
+      |  silent : true/false  display all queries
+      |  trace  : true/false  display JDBC trace messages
+      |  name   : string      name of the HSQL-DB
+      |  path   : string      path to the database - context-protocol is resolved
+      +-->
+  <bean name="org.apache.cocoon.components.hsqldb.Server"
+        class="org.apache.cocoon.components.hsqldb.ServerImpl"
+        scope="singleton" init-method="init" destroy-method="destroy">
+    <property name="servletContext" ref="javax.servlet.ServletContext"/>
+    <property name="runnableManager" ref="org.apache.cocoon.components.thread.RunnableManager"/>
+    <property name="port" value="${org.apache.cocoon.hsqldb.server.port}"/>
+    <property name="silent" value="true"/>
+    <property name="trace" value="false"/>
+    <property name="threadPoolName" value="daemon"/>
+    <property name="name" value="cocoondb"/>
+    <property name="path" value="${org.apache.cocoon.hsqldb.server.db.path}"/>
+  </bean>
+</beans>
\ No newline at end of file

Propchange: cocoon/trunk/blocks/cocoon-hsqldb/cocoon-hsqldb-impl/src/main/resources/META-INF/cocoon/spring/cocoon-hsqldb-block.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/trunk/blocks/cocoon-hsqldb/cocoon-hsqldb-impl/src/main/resources/META-INF/cocoon/spring/cocoon-hsqldb-block.xml
------------------------------------------------------------------------------
    svn:keywords = Id

Modified: cocoon/trunk/blocks/cocoon-hsqldb/cocoon-hsqldb-impl/status.xml
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-hsqldb/cocoon-hsqldb-impl/status.xml?view=diff&rev=491810&r1=491809&r2=491810
==============================================================================
--- cocoon/trunk/blocks/cocoon-hsqldb/cocoon-hsqldb-impl/status.xml (original)
+++ cocoon/trunk/blocks/cocoon-hsqldb/cocoon-hsqldb-impl/status.xml Tue Jan  2 07:11:41 2007
@@ -66,6 +66,9 @@
  <!-- The following list contains the changes since the latest 2.1.x version. -->
  <changes>
   <release version="@version@" date="@date@">
+    <action type="update" dev="CZ">
+      Remove dependencies to Avalon and to Cocoon core.
+    </action>
   </release>
  </changes>
 



Mime
View raw message