jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r577711 - in /jackrabbit/branches/1.3/jackrabbit-core/src/main/java/org/apache/jackrabbit/core: ItemManager.java persistence/bundle/BundleDbPersistenceManager.java
Date Thu, 20 Sep 2007 12:11:10 GMT
Author: jukka
Date: Thu Sep 20 05:11:09 2007
New Revision: 577711

URL: http://svn.apache.org/viewvc?rev=577711&view=rev
Log:
1.3: Merged revisions 532720, 533091 and 535830 (JCR-862)

Modified:
    jackrabbit/branches/1.3/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemManager.java
    jackrabbit/branches/1.3/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/BundleDbPersistenceManager.java

Modified: jackrabbit/branches/1.3/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/1.3/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemManager.java?rev=577711&r1=577710&r2=577711&view=diff
==============================================================================
--- jackrabbit/branches/1.3/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemManager.java
(original)
+++ jackrabbit/branches/1.3/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemManager.java
Thu Sep 20 05:11:09 2007
@@ -33,9 +33,7 @@
 import org.apache.jackrabbit.core.util.Dumpable;
 import org.apache.jackrabbit.core.version.VersionHistoryImpl;
 import org.apache.jackrabbit.core.version.VersionImpl;
-import org.apache.jackrabbit.name.NoPrefixDeclaredException;
 import org.apache.jackrabbit.name.Path;
-import org.apache.jackrabbit.name.PathFormat;
 import org.apache.jackrabbit.name.QName;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -92,13 +90,14 @@
     /**
      * A cache for item instances created by this <code>ItemManager</code>
      */
-    private Map itemCache;
+    private final Map itemCache;
 
     /**
      * Creates a new per-session instance <code>ItemManager</code> instance.
      *
      * @param itemStateProvider the item state provider associated with
      *                          the new instance
+     * @param hierMgr           the hierarchy manager
      * @param session           the session associated with the new instance
      * @param rootNodeDef       the definition of the root node
      * @param rootNodeId        the id of the root node
@@ -121,7 +120,9 @@
      * Disposes this <code>ItemManager</code> and frees resources.
      */
     void dispose() {
-        itemCache.clear();
+        synchronized (itemCache) {
+            itemCache.clear();
+        }
     }
 
     private NodeDefinition getDefinition(NodeState state)
@@ -597,7 +598,9 @@
      *         or <code>null</code> if there's no corresponding cache entry.
      */
     private ItemImpl retrieveItem(ItemId id) {
-        return (ItemImpl) itemCache.get(id);
+        synchronized (itemCache) {
+            return (ItemImpl) itemCache.get(id);
+        }
     }
 
     /**
@@ -607,14 +610,16 @@
      * @param item the item to cache
      */
     private void cacheItem(ItemImpl item) {
-        ItemId id = item.getId();
-        if (itemCache.containsKey(id)) {
-            log.warn("overwriting cached item " + id);
-        }
-        if (log.isDebugEnabled()) {
-            log.debug("caching item " + id);
+        synchronized (itemCache) {
+            ItemId id = item.getId();
+            if (itemCache.containsKey(id)) {
+                log.warn("overwriting cached item " + id);
+            }
+            if (log.isDebugEnabled()) {
+                log.debug("caching item " + id);
+            }
+            itemCache.put(id, item);
         }
-        itemCache.put(id, item);
     }
 
     /**
@@ -626,7 +631,9 @@
         if (log.isDebugEnabled()) {
             log.debug("removing item " + id + " from cache");
         }
-        itemCache.remove(id);
+        synchronized (itemCache) {
+            itemCache.remove(id);
+        }
     }
 
     //-------------------------------------------------< misc. helper methods >
@@ -704,26 +711,28 @@
     /**
      * {@inheritDoc}
      */
-    public void dump(PrintStream ps) {
+    public synchronized void dump(PrintStream ps) {
         ps.println("ItemManager (" + this + ")");
         ps.println();
         ps.println("Items in cache:");
         ps.println();
-        Iterator iter = itemCache.keySet().iterator();
-        while (iter.hasNext()) {
-            ItemId id = (ItemId) iter.next();
-            ItemImpl item = (ItemImpl) itemCache.get(id);
-            if (item.isNode()) {
-                ps.print("Node: ");
-            } else {
-                ps.print("Property: ");
-            }
-            if (item.isTransient()) {
-                ps.print("transient ");
-            } else {
-                ps.print("          ");
+        synchronized (itemCache) {
+            Iterator iter = itemCache.keySet().iterator();
+            while (iter.hasNext()) {
+                ItemId id = (ItemId) iter.next();
+                ItemImpl item = (ItemImpl) itemCache.get(id);
+                if (item.isNode()) {
+                    ps.print("Node: ");
+                } else {
+                    ps.print("Property: ");
+                }
+                if (item.isTransient()) {
+                    ps.print("transient ");
+                } else {
+                    ps.print("          ");
+                }
+                ps.println(id + "\t" + item.safeGetJCRPath() + " (" + item + ")");
             }
-            ps.println(id + "\t" + item.safeGetJCRPath() + " (" + item + ")");
         }
     }
 

Modified: jackrabbit/branches/1.3/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/BundleDbPersistenceManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/1.3/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/BundleDbPersistenceManager.java?rev=577711&r1=577710&r2=577711&view=diff
==============================================================================
--- jackrabbit/branches/1.3/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/BundleDbPersistenceManager.java
(original)
+++ jackrabbit/branches/1.3/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/BundleDbPersistenceManager.java
Thu Sep 20 05:11:09 2007
@@ -530,7 +530,7 @@
         Driver drv = (Driver) Class.forName(driver).newInstance();
         log.info("JDBC driver created: {}", drv);
         con = DriverManager.getConnection(url, user, password);
-        con.setAutoCommit(true);
+        //con.setAutoCommit(true);
 
         // make sure schemaObjectPrefix consists of legal name characters only
         prepareSchemaObjectPrefix();



Mime
View raw message