[exo-jcr-commits] exo-jcr SVN: r1417 - in jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock: jbosscache and 1 other directory.
do-not-reply at jboss.org
do-not-reply at jboss.org
Fri Jan 15 10:26:08 EST 2010
Author: sergiykarpenko
Date: 2010-01-15 10:26:08 -0500 (Fri, 15 Jan 2010)
New Revision: 1417
Modified:
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/LockImpl.java
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/jbosscache/CacheLockImpl.java
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/jbosscache/CacheableLockManager.java
Log:
EXOJCR-332: CacheableLockManager code cleanup
Modified: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/LockImpl.java
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/LockImpl.java 2010-01-15 15:02:55 UTC (rev 1416)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/LockImpl.java 2010-01-15 15:26:08 UTC (rev 1417)
@@ -100,7 +100,7 @@
return lockData.getTimeToDeath();
}
- protected void setTimeOut(long timeOut)
+ protected void setTimeOut(long timeOut) throws LockException
{
lockData.setTimeOut(timeOut);
}
Modified: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/jbosscache/CacheLockImpl.java
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/jbosscache/CacheLockImpl.java 2010-01-15 15:02:55 UTC (rev 1416)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/jbosscache/CacheLockImpl.java 2010-01-15 15:26:08 UTC (rev 1417)
@@ -41,6 +41,13 @@
private CacheableLockManager lockManager;
+ /**
+ * Constructor.
+ *
+ * @param session - session owner
+ * @param lockData - LockData
+ * @param lockManager - CacheableLockManager
+ */
public CacheLockImpl(SessionImpl session, LockData lockData, CacheableLockManager lockManager)
{
this.lockData = lockData;
@@ -49,39 +56,39 @@
this.live = true;
}
+ /**
+ * {@inheritDoc}
+ */
public String getLockOwner()
{
return lockData.getOwner();
}
+ /**
+ * {@inheritDoc}
+ */
public String getLockToken()
{
return lockManager.getLockToken(session.getId(), lockData);
}
+ /**
+ * {@inheritDoc}
+ */
public boolean isLive()
{
- // it is already not alive
if (!live)
{
+ // it is already not alive
return false;
}
- // update from cache. If it is not present there - means it is not live
- // node unlocked and/or re-locked with another session
- LockData newlockData = lockManager.getLockDataById(lockData.getNodeIdentifier());
- if (newlockData == null || newlockData.getToken() != lockData.getToken())
- {
- live = false;
- return false;
- }
- else
- {
- // update, whether time to death changed, or whatever
- this.lockData = newlockData;
- return true;
- }
+ live = lockManager.isLockLive(lockData.getNodeIdentifier());
+ return live;
}
+ /**
+ * {@inheritDoc}
+ */
public void refresh() throws LockException, RepositoryException
{
if (!isLive())
@@ -95,6 +102,9 @@
lockData = newLockData;
}
+ /**
+ * {@inheritDoc}
+ */
public Node getNode()
{
try
@@ -108,35 +118,39 @@
return null;
}
+ /**
+ * {@inheritDoc}
+ */
public boolean isDeep()
{
return lockData.isDeep();
}
+ /**
+ * {@inheritDoc}
+ */
public boolean isSessionScoped()
{
return lockData.isSessionScoped();
}
+ /**
+ * {@inheritDoc}
+ */
public long getTimeToDeath()
{
return lockData.getTimeToDeath();
}
- protected void setTimeOut(long timeOut)
+ /**
+ * {@inheritDoc}
+ */
+ protected void setTimeOut(long timeOut) throws LockException
{
lockData.setTimeOut(timeOut);
//reset lock data
- try
- {
- lockManager.refresh(lockData);
- }
- catch (LockException e)
- {
- // TODO remove or change this
- e.printStackTrace();
- }
+ lockManager.refresh(lockData);
}
}
Modified: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/jbosscache/CacheableLockManager.java
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/jbosscache/CacheableLockManager.java 2010-01-15 15:02:55 UTC (rev 1416)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/jbosscache/CacheableLockManager.java 2010-01-15 15:26:08 UTC (rev 1417)
@@ -16,23 +16,6 @@
*/
package org.exoplatform.services.jcr.impl.core.lock.jbosscache;
-import java.io.Serializable;
-import java.math.BigInteger;
-import java.security.MessageDigest;
-import java.security.NoSuchAlgorithmException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import javax.jcr.AccessDeniedException;
-import javax.jcr.RepositoryException;
-import javax.jcr.UnsupportedRepositoryOperationException;
-import javax.jcr.lock.Lock;
-import javax.jcr.lock.LockException;
-
import org.exoplatform.management.annotations.Managed;
import org.exoplatform.management.annotations.ManagedDescription;
import org.exoplatform.management.jmx.annotations.NameTemplate;
@@ -75,6 +58,23 @@
import org.jboss.cache.Node;
import org.picocontainer.Startable;
+import java.io.Serializable;
+import java.math.BigInteger;
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import javax.jcr.AccessDeniedException;
+import javax.jcr.RepositoryException;
+import javax.jcr.UnsupportedRepositoryOperationException;
+import javax.jcr.lock.Lock;
+import javax.jcr.lock.LockException;
+
/**
* Created by The eXo Platform SAS.
*
@@ -109,14 +109,15 @@
private static final int SEARCH_CLOSEDCHILD = 4;
/**
- * Path to jbosscache-configuration
+ * Name of lock root in jboss-cache.
*/
- public static final String JBOSSCACHE_CONFIG = "jbosscache-configuration";
+ public static final String LOCKS = "$LOCKS";
+ /**
+ * Attribute name where LockData will be stored.
+ */
public static final String LOCK_DATA = "$LOCK_DATA";
- public static final String LOCKS = "$LOCKS";
-
/**
* Logger
*/
@@ -367,9 +368,6 @@
for (LockData lockData : getLockList())
{
- //TODO check is live or remove it
- //if (lockData.isLive())
- //{
// check is lock holder
if (lockTokenHolders.containsKey(session.getId())
&& lockTokenHolders.get(session.getId()).contains(lockData.getToken()))
@@ -405,14 +403,7 @@
this.removeLockToken(session.getId(), lockData.getToken());
}
}
- //TODO
- // }
- // else
- // {
- // entries.remove();
- // }
}
-
}
/*
@@ -910,4 +901,14 @@
return null;
}
}
+
+ public boolean isLockLive(String nodeId)
+ {
+ if (pendingLocks.containsKey(nodeId) || lockRoot.hasChild(Fqn.fromString(nodeId)))
+ {
+ return true;
+ }
+
+ return false;
+ }
}
More information about the exo-jcr-commits
mailing list