jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ste...@apache.org
Subject svn commit: r265517 - in /incubator/jackrabbit/trunk/contrib/db-persistence: ./ applications/test/ applications/test/workspaces/default/ applications/test/workspaces/test/ src/java/org/apache/jackrabbit/core/state/db/
Date Wed, 31 Aug 2005 15:58:22 GMT
Author: stefan
Date: Wed Aug 31 08:58:14 2005
New Revision: 265517

URL: http://svn.apache.org/viewcvs?rev=265517&view=rev
Log:
added support for Derby (embedded)
changed test configuration to use Derby instead of MySQL

Added:
    incubator/jackrabbit/trunk/contrib/db-persistence/src/java/org/apache/jackrabbit/core/state/db/DerbyPersistenceManager.java
  (with props)
    incubator/jackrabbit/trunk/contrib/db-persistence/src/java/org/apache/jackrabbit/core/state/db/derby.ddl
Modified:
    incubator/jackrabbit/trunk/contrib/db-persistence/applications/test/repository.xml
    incubator/jackrabbit/trunk/contrib/db-persistence/applications/test/workspaces/default/workspace.xml
    incubator/jackrabbit/trunk/contrib/db-persistence/applications/test/workspaces/test/workspace.xml
    incubator/jackrabbit/trunk/contrib/db-persistence/project.xml

Modified: incubator/jackrabbit/trunk/contrib/db-persistence/applications/test/repository.xml
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/db-persistence/applications/test/repository.xml?rev=265517&r1=265516&r2=265517&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/db-persistence/applications/test/repository.xml (original)
+++ incubator/jackrabbit/trunk/contrib/db-persistence/applications/test/repository.xml Wed
Aug 31 08:58:14 2005
@@ -166,16 +166,14 @@
             class: FQN of class implementing the FileSystem interface
         -->
         <FileSystem class="org.apache.jackrabbit.core.fs.local.LocalFileSystem">
-            <param name="path" value="${wsp.home}/data"/>
+            <param name="path" value="${wsp.home}"/>
         </FileSystem>
         <!--
             persistence manager of the workspace:
             class: FQN of class implementing the PersistenceManager interface
         -->
-        <PersistenceManager class="org.apache.jackrabbit.core.state.db.SimpleDbPersistenceManager">
-          <param name="driver" value="com.mysql.jdbc.Driver"/>
-          <param name="url" value="jdbc:mysql:///test"/>
-          <param name="schema" value="mysql"/>
+        <PersistenceManager class="org.apache.jackrabbit.core.state.db.DerbyPersistenceManager">
+          <param name="url" value="jdbc:derby:${wsp.home}/db;create=true"/>
           <param name="schemaObjectPrefix" value="${wsp.name}_"/>
         </PersistenceManager>
         <!--
@@ -205,10 +203,8 @@
             a 'normal' persistence manager, but this could change in future
             implementations.
         -->
-        <PersistenceManager class="org.apache.jackrabbit.core.state.db.SimpleDbPersistenceManager">
-          <param name="driver" value="com.mysql.jdbc.Driver"/>
-          <param name="url" value="jdbc:mysql:///test"/>
-          <param name="schema" value="mysql"/>
+        <PersistenceManager class="org.apache.jackrabbit.core.state.db.DerbyPersistenceManager">
+          <param name="url" value="jdbc:derby:${rep.home}/version/db;create=true"/>
           <param name="schemaObjectPrefix" value="version_"/>
         </PersistenceManager>
 

Modified: incubator/jackrabbit/trunk/contrib/db-persistence/applications/test/workspaces/default/workspace.xml
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/db-persistence/applications/test/workspaces/default/workspace.xml?rev=265517&r1=265516&r2=265517&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/db-persistence/applications/test/workspaces/default/workspace.xml
(original)
+++ incubator/jackrabbit/trunk/contrib/db-persistence/applications/test/workspaces/default/workspace.xml
Wed Aug 31 08:58:14 2005
@@ -5,17 +5,15 @@
       class: FQN of class implementing FileSystem interface
   -->
   <FileSystem class="org.apache.jackrabbit.core.fs.local.LocalFileSystem">
-    <param name="path" value="${wsp.home}/data" />
+    <param name="path" value="${wsp.home}" />
   </FileSystem>
   <!--
       persistence of the workspace:
       class: FQN of class implementing PersistenceManager interface
   -->
-  <PersistenceManager class="org.apache.jackrabbit.core.state.db.SimpleDbPersistenceManager">
-    <param name="driver" value="com.mysql.jdbc.Driver"/>
-    <param name="url" value="jdbc:mysql:///test"/>
-    <param name="schema" value="mysql"/>
-    <param name="schemaObjectPrefix" value="${wsp.name}_"/>
+  <PersistenceManager class="org.apache.jackrabbit.core.state.db.DerbyPersistenceManager">
+     <param name="url" value="jdbc:derby:${wsp.home}/db;create=true"/>
+     <param name="schemaObjectPrefix" value="${wsp.name}_"/>
   </PersistenceManager>
   <!--
       Search index and the file system it uses.

Modified: incubator/jackrabbit/trunk/contrib/db-persistence/applications/test/workspaces/test/workspace.xml
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/db-persistence/applications/test/workspaces/test/workspace.xml?rev=265517&r1=265516&r2=265517&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/db-persistence/applications/test/workspaces/test/workspace.xml
(original)
+++ incubator/jackrabbit/trunk/contrib/db-persistence/applications/test/workspaces/test/workspace.xml
Wed Aug 31 08:58:14 2005
@@ -5,17 +5,15 @@
       class: FQN of class implementing FileSystem interface
   -->
   <FileSystem class="org.apache.jackrabbit.core.fs.local.LocalFileSystem">
-    <param name="path" value="${wsp.home}/data" />
+    <param name="path" value="${wsp.home}" />
   </FileSystem>
   <!--
       persistence of the workspace:
       class: FQN of class implementing PersistenceManager interface
   -->
-  <PersistenceManager class="org.apache.jackrabbit.core.state.db.SimpleDbPersistenceManager">
-    <param name="driver" value="com.mysql.jdbc.Driver"/>
-    <param name="url" value="jdbc:mysql:///test"/>
-    <param name="schema" value="mysql"/>
-    <param name="schemaObjectPrefix" value="${wsp.name}_"/>
+  <PersistenceManager class="org.apache.jackrabbit.core.state.db.DerbyPersistenceManager">
+     <param name="url" value="jdbc:derby:${wsp.home}/db;create=true"/>
+     <param name="schemaObjectPrefix" value="${wsp.name}_"/>
   </PersistenceManager>
   <!--
       Search index and the file system it uses.

Modified: incubator/jackrabbit/trunk/contrib/db-persistence/project.xml
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/db-persistence/project.xml?rev=265517&r1=265516&r2=265517&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/db-persistence/project.xml (original)
+++ incubator/jackrabbit/trunk/contrib/db-persistence/project.xml Wed Aug 31 08:58:14 2005
@@ -79,6 +79,11 @@
           runtime dependencies of jackrabbit/jUnit test-cases 
         -->
         <dependency>
+            <groupId>org.apache.derby</groupId>
+            <artifactId>derby</artifactId>
+            <version>10.1.1.0</version>
+        </dependency>
+        <dependency>
             <groupId>mysql</groupId>
             <artifactId>mysql-connector-java</artifactId>
             <version>3.0.10</version>

Added: incubator/jackrabbit/trunk/contrib/db-persistence/src/java/org/apache/jackrabbit/core/state/db/DerbyPersistenceManager.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/db-persistence/src/java/org/apache/jackrabbit/core/state/db/DerbyPersistenceManager.java?rev=265517&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/db-persistence/src/java/org/apache/jackrabbit/core/state/db/DerbyPersistenceManager.java
(added)
+++ incubator/jackrabbit/trunk/contrib/db-persistence/src/java/org/apache/jackrabbit/core/state/db/DerbyPersistenceManager.java
Wed Aug 31 08:58:14 2005
@@ -0,0 +1,111 @@
+/*
+ * Copyright 2004-2005 The Apache Software Foundation or its licensors,
+ *                     as applicable.
+ *
+ * Licensed 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.
+ */
+package org.apache.jackrabbit.core.state.db;
+
+import org.apache.log4j.Logger;
+
+import java.sql.DriverManager;
+import java.sql.SQLException;
+
+/**
+ * <code>DerbyPersistenceManager</code> is a JDBC-based
+ * <code>PersistenceManager</code> for Jackrabbit that persists
+ * <code>ItemState</code> and <code>NodeReferences</code> objects
in an
+ * embedded Derby database using a simple custom serialization format and a
+ * very basic non-normalized database schema (in essence tables with one 'key'
+ * and one 'data' column).
+ * <p/>
+ * It is configured through the following properties:
+ * <ul>
+ * <li><code>url</code>: the database url of the form
+ * <code>"jdbc:derby:[db];[attributes]"</code></li>
+ * <li><code>schemaObjectPrefix</code>: prefix to be prepended to schema
objects</li>
+ * <li><code>driver</code>: the FQN name of the JDBC driver class
+ * (default: <code>"org.apache.derby.jdbc.EmbeddedDriver"</code>)</li>
+ * <li><code>schema</code>: type of schema to be used
+ * (default: <code>"derby"</code>)</li>
+ * <li><code>user</code>: the database user (default: <code>""</code>)</li>
+ * <li><code>password</code>: the user's password (default: <code>""</code>)</li>
+ * </ul>
+ * See also {@link SimpleDbPersistenceManager}.
+ * <p/>
+ * The following is a fragment from a sample configuration:
+ * <pre>
+ *   &lt;PersistenceManager class="org.apache.jackrabbit.core.state.db.DerbyPersistenceManager"&gt;
+ *       &lt;param name="url" value="jdbc:derby:${wsp.home}/db;create=true"/&gt;
+ *       &lt;param name="schemaObjectPrefix" value="${wsp.name}_"/&gt;
+ *  &lt;/PersistenceManager&gt;
+ * </pre>
+ */
+public class DerbyPersistenceManager extends SimpleDbPersistenceManager {
+
+    /**
+     * Logger instance
+     */
+    private static Logger log = Logger.getLogger(DerbyPersistenceManager.class);
+
+    /**
+     * Creates a new <code>SimpleDbPersistenceManager</code> instance.
+     */
+    public DerbyPersistenceManager() {
+        // preset some attributes to reasonable defaults
+        schema = "derby";
+        driver = "org.apache.derby.jdbc.EmbeddedDriver";
+        schemaObjectPrefix = "";
+        user = "";
+        password = "";
+        initialized = false;
+    }
+
+    //---------------------------------< SimpleDbPersistenceManager overrides >
+    /**
+     * {@inheritDoc}
+     * <p/>
+     * Overridden in order to properly shutdown the embedded Derby database.
+     */
+    public synchronized void close() throws Exception {
+        if (!initialized) {
+            throw new IllegalStateException("not initialized");
+        }
+
+        // prepare connection url for issuing shutdown command
+        String url = con.getMetaData().getURL();
+        int pos = url.lastIndexOf(';');
+        if (pos != -1) {
+            // strip amy attributes from connection url
+            url = url.substring(0, pos);
+        }
+        url += ";shutdown=true";
+
+        // we have to reset the connection to 'autoCommit=true' before closing it;
+        // otherwise Derby would mysteriously complain about some pending uncommitted
+        // changes which can't possibly be true.
+        // @todo further investigate
+        con.setAutoCommit(true);
+
+        // call base class implementation
+        super.close();
+
+        // now it's safe to shutdown the embedded Derby database
+        try {
+            DriverManager.getConnection(url);
+        } catch (SQLException e) {
+            // a shutdown command always raises a SQLException
+            log.info(e.getMessage());
+        }
+    }
+}

Propchange: incubator/jackrabbit/trunk/contrib/db-persistence/src/java/org/apache/jackrabbit/core/state/db/DerbyPersistenceManager.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/jackrabbit/trunk/contrib/db-persistence/src/java/org/apache/jackrabbit/core/state/db/derby.ddl
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/db-persistence/src/java/org/apache/jackrabbit/core/state/db/derby.ddl?rev=265517&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/db-persistence/src/java/org/apache/jackrabbit/core/state/db/derby.ddl
(added)
+++ incubator/jackrabbit/trunk/contrib/db-persistence/src/java/org/apache/jackrabbit/core/state/db/derby.ddl
Wed Aug 31 08:58:14 2005
@@ -0,0 +1,6 @@
+create table ${schemaObjectPrefix}NODE (NODE_ID char(36) not null, NODE_DATA blob not null)
+create unique index ${schemaObjectPrefix}NODE_IDX on ${schemaObjectPrefix}NODE (NODE_ID)
+create table ${schemaObjectPrefix}PROP (PROP_ID varchar(1024) not null, PROP_DATA blob not
null)
+create unique index ${schemaObjectPrefix}PROP_IDX on ${schemaObjectPrefix}PROP (PROP_ID)
+create table ${schemaObjectPrefix}REFS (NODE_ID char(36) not null, REFS_DATA blob not null)
+create unique index ${schemaObjectPrefix}REFS_IDX on ${schemaObjectPrefix}REFS (NODE_ID)



Mime
View raw message