jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r957571 - in /jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core: ./ session/
Date Thu, 24 Jun 2010 14:59:48 GMT
Author: jukka
Date: Thu Jun 24 14:59:48 2010
New Revision: 957571

URL: http://svn.apache.org/viewvc?rev=957571&view=rev
Log:
JCR-890: concurrent read-only access to a session

Re-introduce SessionState.checkAlive() to optimize sanity checks

Modified:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemImpl.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemManager.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/SessionImpl.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/WorkspaceImpl.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/session/ActiveSessionState.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/session/ClosedSessionState.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/session/SessionState.java

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemImpl.java?rev=957571&r1=957570&r2=957571&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemImpl.java
Thu Jun 24 14:59:48 2010
@@ -109,13 +109,10 @@ public abstract class ItemImpl implement
      */
     protected void sanityCheck() throws RepositoryException {
         // check session status
-        perform(new SessionOperation("sanity check"));
+        sessionContext.getSessionState().checkAlive();
 
         // check status of this item for read operation
-        final int status = data.getStatus();
-        if (status == STATUS_DESTROYED || status == STATUS_INVALIDATED) {
-            throw new InvalidItemStateException(id + ": the item does not exist anymore");
-        }
+        itemSanityCheck();
     }
 
     /**

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemManager.java?rev=957571&r1=957570&r2=957571&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemManager.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemManager.java
Thu Jun 24 14:59:48 2010
@@ -133,6 +133,15 @@ public class ItemManager implements Dump
     }
 
     /**
+     * Checks that this session is alive.
+     *
+     * @throws RepositoryException if the session has been closed
+     */
+    private void sanityCheck() throws RepositoryException {
+        sessionContext.getSessionState().checkAlive();
+    }
+
+    /**
      * Disposes this <code>ItemManager</code> and frees resources.
      */
     void dispose() {
@@ -277,8 +286,7 @@ public class ItemManager implements Dump
      */
     private boolean itemExists(ItemId itemId, Path path) {
         try {
-            // check sanity of session
-            session.sanityCheck();
+            sanityCheck();
 
             // shortcut: check if state exists for the given item
             if (!sism.hasItemState(itemId)) {
@@ -305,8 +313,7 @@ public class ItemManager implements Dump
      * @throws RepositoryException
      */
     private ItemImpl getItem(ItemId itemId, Path path) throws ItemNotFoundException, AccessDeniedException,
RepositoryException {
-        // check sanity of session
-        session.sanityCheck();
+        sanityCheck();
 
         boolean permissionCheck = true;
         ItemData data = getItemData(itemId, path, permissionCheck);
@@ -454,8 +461,7 @@ public class ItemManager implements Dump
      */
     public boolean itemExists(Path path) {
         try {
-            // check sanity of session
-            session.sanityCheck();
+            sanityCheck();
 
             ItemId id = hierMgr.resolvePath(path);
             return (id != null) && itemExists(id, path);
@@ -472,8 +478,7 @@ public class ItemManager implements Dump
      */
     public boolean nodeExists(Path path) {
         try {
-            // check sanity of session
-            session.sanityCheck();
+            sanityCheck();
 
             NodeId id = hierMgr.resolveNodePath(path);
             return (id != null) && itemExists(id, path);
@@ -490,8 +495,7 @@ public class ItemManager implements Dump
      */
     public boolean propertyExists(Path path) {
         try {
-            // check sanity of session
-            session.sanityCheck();
+            sanityCheck();
 
             PropertyId id = hierMgr.resolvePropertyPath(path);
             return (id != null) && itemExists(id, path);
@@ -666,8 +670,7 @@ public class ItemManager implements Dump
      */
     synchronized boolean hasChildNodes(NodeId parentId)
             throws ItemNotFoundException, AccessDeniedException, RepositoryException {
-        // check sanity of session
-        session.sanityCheck();
+        sanityCheck();
 
         ItemData data = getItemData(parentId);
         if (!data.isNode()) {
@@ -695,8 +698,7 @@ public class ItemManager implements Dump
      */
     synchronized NodeIterator getChildNodes(NodeId parentId)
             throws ItemNotFoundException, AccessDeniedException, RepositoryException {
-        // check sanity of session
-        session.sanityCheck();
+        sanityCheck();
 
         ItemData data = getItemData(parentId);
         if (!data.isNode()) {
@@ -726,8 +728,7 @@ public class ItemManager implements Dump
      */
     synchronized boolean hasChildProperties(NodeId parentId)
             throws ItemNotFoundException, AccessDeniedException, RepositoryException {
-        // check sanity of session
-        session.sanityCheck();
+        sanityCheck();
 
         ItemData data = getItemData(parentId);
         if (!data.isNode()) {
@@ -757,8 +758,7 @@ public class ItemManager implements Dump
      */
     synchronized PropertyIterator getChildProperties(NodeId parentId)
             throws ItemNotFoundException, AccessDeniedException, RepositoryException {
-        // check sanity of session
-        session.sanityCheck();
+        sanityCheck();
 
         ItemData data = getItemData(parentId);
         if (!data.isNode()) {

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/SessionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/SessionImpl.java?rev=957571&r1=957570&r2=957571&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/SessionImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/SessionImpl.java
Thu Jun 24 14:59:48 2010
@@ -363,8 +363,8 @@ public class SessionImpl extends Abstrac
      *                             for some reason (e.g. if this session has
      *                             been closed explicitly or if it has expired)
      */
-    protected void sanityCheck() throws RepositoryException {
-        perform(new SessionOperation("sanity check"));
+    private void sanityCheck() throws RepositoryException {
+        context.getSessionState().checkAlive();
     }
 
     /**

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/WorkspaceImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/WorkspaceImpl.java?rev=957571&r1=957570&r2=957571&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/WorkspaceImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/WorkspaceImpl.java
Thu Jun 24 14:59:48 2010
@@ -196,8 +196,7 @@ public class WorkspaceImpl extends Abstr
      *                             for some reason
      */
     public void sanityCheck() throws RepositoryException {
-        // check session status
-        session.sanityCheck();
+        sessionContext.getSessionState().checkAlive();
     }
 
     //--------------------------------------------------< new JSR 283 methods >

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/session/ActiveSessionState.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/session/ActiveSessionState.java?rev=957571&r1=957570&r2=957571&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/session/ActiveSessionState.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/session/ActiveSessionState.java
Thu Jun 24 14:59:48 2010
@@ -59,6 +59,12 @@ public class ActiveSessionState implemen
     }
 
     /**
+     * Does nothing; the session is alive.
+     */
+    public void checkAlive() {
+    }
+
+    /**
      * Performs the given operation within a synchronized block.
      *
      * @throws RepositoryException if the operation fails

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/session/ClosedSessionState.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/session/ClosedSessionState.java?rev=957571&r1=957570&r2=957571&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/session/ClosedSessionState.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/session/ClosedSessionState.java
Thu Jun 24 14:59:48 2010
@@ -43,6 +43,17 @@ public class ClosedSessionState implemen
      *
      * @throws RepositoryException always thrown
      */
+    public void checkAlive() throws RepositoryException {
+        throw new RepositoryException(
+                "This session has been closed. See the chained exception"
+                + " for a trace of where the session was closed", exception);
+    }
+
+    /**
+     * Throws an exception; the session is closed.
+     *
+     * @throws RepositoryException always thrown
+     */
     public void perform(SessionOperation operation) throws RepositoryException {
         throw new RepositoryException(
                 "Unable to perform " + operation + " since this session"

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/session/SessionState.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/session/SessionState.java?rev=957571&r1=957570&r2=957571&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/session/SessionState.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/session/SessionState.java
Thu Jun 24 14:59:48 2010
@@ -34,6 +34,13 @@ public interface SessionState {
     boolean isAlive();
 
     /**
+     * Throws an exception if this session is not alive.
+     *
+     * @throws RepositoryException throw if this session is not alive
+     */
+    void checkAlive() throws RepositoryException;
+
+    /**
      * Performs the given session operation.
      *
      * @param operation the session operation



Mime
View raw message