jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r1299693 - in /jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit: CacheFactory.java GlobalContext.java state/NodeStateProvider.java state/TransientNodeStateCache.java state/TransientNodeStateCacheImpl.java
Date Mon, 12 Mar 2012 14:51:38 GMT
Author: mduerig
Date: Mon Mar 12 14:51:37 2012
New Revision: 1299693

URL: http://svn.apache.org/viewvc?rev=1299693&view=rev
Log:
Microkernel based prototype of JCR implementation (WIP)
- refactor node state cache 

Removed:
    jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/CacheFactory.java
    jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/state/TransientNodeStateCache.java
    jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/state/TransientNodeStateCacheImpl.java
Modified:
    jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/GlobalContext.java
    jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/state/NodeStateProvider.java

Modified: jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/GlobalContext.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/GlobalContext.java?rev=1299693&r1=1299692&r2=1299693&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/GlobalContext.java
(original)
+++ jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/GlobalContext.java
Mon Mar 12 14:51:37 2012
@@ -25,7 +25,6 @@ import org.apache.jackrabbit.mk.MicroKer
 import org.apache.jackrabbit.mk.api.MicroKernel;
 import org.apache.jackrabbit.security.Authenticator;
 import org.apache.jackrabbit.security.AuthenticatorImpl;
-import org.apache.jackrabbit.state.TransientNodeStateCacheImpl;
 import org.apache.jackrabbit.utils.Unchecked;
 
 import javax.jcr.Repository;
@@ -49,7 +48,6 @@ public class GlobalContext {
         put(Repository.class, RepositoryImpl.create(this));
         put(Authenticator.class, AuthenticatorImpl.INSTANCE);
         put(SessionFactory.class, SessionImpl.FACTORY);
-        put(CacheFactory.class, TransientNodeStateCacheImpl.FACTORY);
     }
 
     public <T> T getInstance(Class<T> forClass) {

Modified: jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/state/NodeStateProvider.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/state/NodeStateProvider.java?rev=1299693&r1=1299692&r2=1299693&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/state/NodeStateProvider.java
(original)
+++ jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/state/NodeStateProvider.java
Mon Mar 12 14:51:37 2012
@@ -1,49 +1,67 @@
 package org.apache.jackrabbit.state;
 
+import org.apache.commons.collections.map.LRUMap;
 import org.apache.jackrabbit.Path;
 import org.apache.jackrabbit.SessionImpl.Context;
+import org.apache.jackrabbit.configuration.RepositoryConfiguration;
 import org.apache.jackrabbit.state.ChangeTree.NodeDelta;
+import org.apache.jackrabbit.utils.Unchecked;
+
+import java.util.Map;
 
 public class NodeStateProvider {
     private final Context sessionContext;
     private final TransientSpace transientSpace;
-    private final TransientNodeStateCache nodeStateCache;
+    private final Map<Path, TransientNodeState> cache;
 
     public NodeStateProvider(Context sessionContext, TransientSpace transientSpace) {
         this.sessionContext = sessionContext;
         this.transientSpace = transientSpace;
-        nodeStateCache = new TransientNodeStateCacheImpl(100); // fixme don't hard code
+
+        RepositoryConfiguration config = sessionContext.getGlobalContext().getInstance(RepositoryConfiguration.class);
+        if (config.getNodeStateCacheSize() <= 0) {
+            cache = null;
+        }
+        else {
+            cache = Unchecked.cast(new LRUMap(config.getNodeStateCacheSize()));
+        }
     }
 
     public TransientNodeState getNodeState(Path path) {
-        TransientNodeState state = nodeStateCache.get(path);
+        TransientNodeState state = cache.get(path);
         if (state == null) {
             NodeDelta delta = transientSpace.getNodeDelta(path);
             if (delta == null) {
                 return null;
             }
             state = new TransientNodeState(sessionContext, delta);
-            nodeStateCache.put(path, state);
+            if (cache != null) {
+                cache.put(path, state);
+            }
         }
         return state;
     }
 
     public void release(Path path) {
-        nodeStateCache.remove(path);
+        if (cache != null) {
+            cache.remove(path);
+        }
     }
 
     public void clear() {
-        nodeStateCache.clear();
+        if (cache != null) {
+            cache.clear();
+        }
     }
 
     //------------------------------------------< internal/private >---
 
     TransientNodeState getNodeState(NodeDelta nodeDelta) {
         Path path = nodeDelta.getPath();
-        TransientNodeState state = nodeStateCache.get(path);
+        TransientNodeState state = cache.get(path);
         if (state == null) {
             state = new TransientNodeState(sessionContext, nodeDelta);
-            nodeStateCache.put(path, state);
+            cache.put(path, state);
         }
         return state;
     }



Mime
View raw message