jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From alexparvule...@apache.org
Subject svn commit: r1296214 - /jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/lock/LockManagerImpl.java
Date Fri, 02 Mar 2012 14:09:10 GMT
Author: alexparvulescu
Date: Fri Mar  2 14:09:10 2012
New Revision: 1296214

URL: http://svn.apache.org/viewvc?rev=1296214&view=rev
Log:
JCR-3248 TimeoutHandler visitor should be extracted into a dedicated class

Modified:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/lock/LockManagerImpl.java

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/lock/LockManagerImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/lock/LockManagerImpl.java?rev=1296214&r1=1296213&r2=1296214&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/lock/LockManagerImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/lock/LockManagerImpl.java
Fri Mar  2 14:09:10 2012
@@ -16,13 +16,32 @@
  */
 package org.apache.jackrabbit.core.lock;
 
-import EDU.oswego.cs.dl.util.concurrent.ReentrantLock;
+import java.io.BufferedReader;
+import java.io.BufferedWriter;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.OutputStreamWriter;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.ScheduledFuture;
+import java.util.concurrent.TimeUnit;
+
+import javax.jcr.ItemNotFoundException;
+import javax.jcr.PropertyType;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+import javax.jcr.Workspace;
+import javax.jcr.lock.Lock;
+import javax.jcr.lock.LockException;
+import javax.jcr.observation.Event;
+import javax.jcr.observation.EventIterator;
+import javax.transaction.xa.Xid;
+
 import org.apache.commons.collections.map.LinkedMap;
 import org.apache.commons.io.IOUtils;
-import org.apache.jackrabbit.core.id.ItemId;
-import org.apache.jackrabbit.core.id.NodeId;
 import org.apache.jackrabbit.core.NodeImpl;
-import org.apache.jackrabbit.core.id.PropertyId;
 import org.apache.jackrabbit.core.SessionImpl;
 import org.apache.jackrabbit.core.SessionListener;
 import org.apache.jackrabbit.core.TransactionContext;
@@ -33,6 +52,9 @@ import org.apache.jackrabbit.core.cluste
 import org.apache.jackrabbit.core.fs.FileSystem;
 import org.apache.jackrabbit.core.fs.FileSystemException;
 import org.apache.jackrabbit.core.fs.FileSystemResource;
+import org.apache.jackrabbit.core.id.ItemId;
+import org.apache.jackrabbit.core.id.NodeId;
+import org.apache.jackrabbit.core.id.PropertyId;
 import org.apache.jackrabbit.core.observation.EventImpl;
 import org.apache.jackrabbit.core.observation.SynchronousEventListener;
 import org.apache.jackrabbit.core.state.ItemStateException;
@@ -44,31 +66,10 @@ import org.apache.jackrabbit.spi.Path;
 import org.apache.jackrabbit.spi.commons.conversion.MalformedPathException;
 import org.apache.jackrabbit.spi.commons.name.NameConstants;
 import org.apache.jackrabbit.spi.commons.name.PathMap;
-import javax.jcr.Workspace;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import javax.jcr.ItemNotFoundException;
-import javax.jcr.PropertyType;
-import javax.jcr.RepositoryException;
-import javax.jcr.Session;
-import javax.jcr.lock.Lock;
-import javax.jcr.lock.LockException;
-import javax.jcr.observation.Event;
-import javax.jcr.observation.EventIterator;
-import javax.transaction.xa.Xid;
-
-import java.io.BufferedReader;
-import java.io.BufferedWriter;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.io.OutputStreamWriter;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Iterator;
-import java.util.concurrent.ScheduledExecutorService;
-import java.util.concurrent.ScheduledFuture;
-import java.util.concurrent.TimeUnit;
+import EDU.oswego.cs.dl.util.concurrent.ReentrantLock;
 
 /**
  * Provides the functionality needed for locking and unlocking nodes.
@@ -232,26 +233,31 @@ public class LockManagerImpl
      *      JSR 283: Locking
      */
     private class TimeoutHandler implements Runnable {
+        private final TimeoutHandlerVisitor visitor = new TimeoutHandlerVisitor();
+
         public void run() {
-            lockMap.traverse(new PathMap.ElementVisitor<LockInfo>() {
-                public void elementVisited(PathMap.Element<LockInfo> element) {
-                    LockInfo info = element.get();
-                    if (info != null && info.isLive() && info.isExpired())
{
-                        NodeId id = info.getId();
-                        SessionImpl holder = info.getLockHolder();
-                        if (holder == null) {
-                            info.setLockHolder(sysSession);
-                            holder = sysSession;
-                        }
-                        try {
-                            // FIXME: This session access is not thread-safe!
-                            unlock(holder.getNodeById(id));
-                        } catch (RepositoryException e) {
-                            log.warn("Unable to expire the lock " + id, e);
-                        }
-                    }
+            lockMap.traverse(visitor, false);
+        }
+    }
+
+    private class TimeoutHandlerVisitor implements
+            PathMap.ElementVisitor<LockInfo> {
+        public void elementVisited(PathMap.Element<LockInfo> element) {
+            LockInfo info = element.get();
+            if (info != null && info.isLive() && info.isExpired()) {
+                NodeId id = info.getId();
+                SessionImpl holder = info.getLockHolder();
+                if (holder == null) {
+                    info.setLockHolder(sysSession);
+                    holder = sysSession;
+                }
+                try {
+                    // FIXME: This session access is not thread-safe!
+                    unlock(holder.getNodeById(id));
+                } catch (RepositoryException e) {
+                    log.warn("Unable to expire the lock " + id, e);
                 }
-            }, false);
+            }
         }
     }
 



Mime
View raw message