jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r984730 - in /jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/session: SessionContext.java SessionItemOperation.java SessionRefreshOperation.java SessionSaveOperation.java
Date Thu, 12 Aug 2010 11:53:39 GMT
Author: jukka
Date: Thu Aug 12 11:53:39 2010
New Revision: 984730

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

Add javadocs

Modified:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/session/SessionContext.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/session/SessionItemOperation.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/session/SessionRefreshOperation.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/session/SessionSaveOperation.java

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/session/SessionContext.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/session/SessionContext.java?rev=984730&r1=984729&r2=984730&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/session/SessionContext.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/session/SessionContext.java
Thu Aug 12 11:53:39 2010
@@ -34,10 +34,20 @@ import org.apache.jackrabbit.spi.commons
 import org.apache.jackrabbit.spi.commons.conversion.MalformedPathException;
 import org.apache.jackrabbit.spi.commons.conversion.NamePathResolver;
 
+/**
+ * Component context of a session. This class keeps track of the internal
+ * components associated with a session.
+ */
 public class SessionContext implements NamePathResolver {
 
+    /**
+     * The repository context of this session.
+     */
     private final RepositoryContext repositoryContext;
 
+    /**
+     * This session.
+     */
     private final SessionImpl session;
 
     /**
@@ -65,8 +75,17 @@ public class SessionContext implements N
      */
     private volatile AccessManager accessManager;
 
+    /**
+     * The observation manager of this session.
+     */
     private volatile ObservationManagerImpl observationManager;
 
+    /**
+     * Creates a component context for the given session.
+     *
+     * @param repositoryContext repository context of the session
+     * @param session the session
+     */
     public SessionContext(
             RepositoryContext repositoryContext, SessionImpl session) {
         assert repositoryContext != null;
@@ -76,6 +95,11 @@ public class SessionContext implements N
         this.state = new SessionState(this);
     }
 
+    /**
+     * Returns the repository context of the session.
+     *
+     * @return repository context
+     */
     public RepositoryContext getRepositoryContext() {
         return repositoryContext;
     }
@@ -99,10 +123,20 @@ public class SessionContext implements N
         return repositoryContext.getDataStore();
     }
 
+    /**
+     * Returns this session.
+     *
+     * @return session
+     */
     public SessionImpl getSessionImpl() {
         return session;
     }
 
+    /**
+     * Returns the state of this session.
+     *
+     * @return session state
+     */
     public SessionState getSessionState() {
         return state;
     }

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/session/SessionItemOperation.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/session/SessionItemOperation.java?rev=984730&r1=984729&r2=984730&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/session/SessionItemOperation.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/session/SessionItemOperation.java
Thu Aug 12 11:53:39 2010
@@ -33,38 +33,15 @@ import org.apache.jackrabbit.spi.commons
  */
 public abstract class SessionItemOperation<T> implements SessionOperation<T>
{
 
-    private final String method;
-
-    private final String path;
-
-    private SessionItemOperation(String method, String path) {
-        this.method = method;
-        this.path = path;
-    }
-
-    public String toString() {
-        return method + "(" + path + ")";
-    }
-
-    public T perform(SessionContext context) throws RepositoryException {
-        try {
-            Path normalized =
-                context.getQPath(path).getNormalizedPath();
-            if (normalized.isAbsolute()) {
-                return perform(context.getItemManager(), normalized);
-            } else {
-                throw new RepositoryException("Not an absolute path: " + path);
-            }
-        } catch (AccessDeniedException e) {
-            throw new PathNotFoundException(path);
-        } catch (NameException e) {
-            throw new RepositoryException("Invalid path:" + path, e);
-        }
-    }
-
-    protected abstract T perform(ItemManager manager, Path path)
-            throws RepositoryException;
+    //----------------------------------------------< static factory methods >
 
+    /**
+     * Creates a session operation for checking the existence of an item
+     * at the given path.
+     *
+     * @param path absolute path of the item
+     * @return session operation
+     */
     public static SessionItemOperation<Boolean> itemExists(String path) {
         return new SessionItemOperation<Boolean>("itemExists", path) {
             @Override @SuppressWarnings("deprecation")
@@ -74,6 +51,13 @@ public abstract class SessionItemOperati
         };
     }
 
+    /**
+     * Creates a session operation for checking the existence of a property
+     * at the given path.
+     *
+     * @param path absolute path of the property
+     * @return session operation
+     */
     public static SessionItemOperation<Boolean> propertyExists(String path) {
         return new SessionItemOperation<Boolean>("propertyExists", path) {
             @Override
@@ -83,6 +67,13 @@ public abstract class SessionItemOperati
         };
     }
 
+    /**
+     * Creates a session operation for checking the existence of a node
+     * at the given path.
+     *
+     * @param path absolute path of the node
+     * @return session operation
+     */
     public static SessionItemOperation<Boolean> nodeExists(String path) {
         return new SessionItemOperation<Boolean>("nodeExists", path) {
             @Override
@@ -92,6 +83,12 @@ public abstract class SessionItemOperati
         };
     }
 
+    /**
+     * Creates a session operation for getting the item at the given path.
+     *
+     * @param path absolute path of the item
+     * @return session operation
+     */
     public static SessionItemOperation<ItemImpl> getItem(String path) {
         return new SessionItemOperation<ItemImpl>("getItem", path) {
             @Override @SuppressWarnings("deprecation")
@@ -102,6 +99,12 @@ public abstract class SessionItemOperati
         };
     }
 
+    /**
+     * Creates a session operation for getting the property at the given path.
+     *
+     * @param path absolute path of the property
+     * @return session operation
+     */
     public static SessionItemOperation<PropertyImpl> getProperty(String path) {
         return new SessionItemOperation<PropertyImpl>("getProperty", path) {
             @Override
@@ -112,6 +115,12 @@ public abstract class SessionItemOperati
         };
     }
 
+    /**
+     * Creates a session operation for getting the node at the given path.
+     *
+     * @param path absolute path of the node
+     * @return session operation
+     */
     public static SessionItemOperation<NodeImpl> getNode(String path) {
         return new SessionItemOperation<NodeImpl>("getNode", path) {
             @Override
@@ -122,6 +131,12 @@ public abstract class SessionItemOperati
         };
     }
 
+    /**
+     * Creates a session operation for removing the item at the given path.
+     *
+     * @param path absolute path of the item
+     * @return session operation
+     */
     public static SessionItemOperation<Object> remove(String path) {
         return new SessionItemOperation<Object>("remove", path) {
             @Override  @SuppressWarnings("deprecation")
@@ -133,4 +148,71 @@ public abstract class SessionItemOperati
         };
     }
 
+    //------------------------------------------------< SessionItemOperation >
+
+    /**
+     * The method being executed (itemExists/getItem/remove/etc.)
+     */
+    private final String method;
+
+    /**
+     * Absolute path of the item that this operation accesses.
+     */
+    private final String path;
+
+    /**
+     * Creates a new operation for a accessing the item at the given path.
+     *
+     * @param method method being executed
+     * @param path absolute path of the item
+     */
+    private SessionItemOperation(String method, String path) {
+        this.method = method;
+        this.path = path;
+    }
+
+    /**
+     * Performs this operation on the specified item. This method resolves
+     * the given absolute path and calls the abstract
+     * {@link #perform(ItemManager, Path)} method to actually perform the
+     * selected operation.
+     *
+     * @throws RepositoryException if the operation fails
+     */
+    public T perform(SessionContext context) throws RepositoryException {
+        try {
+            Path normalized =
+                context.getQPath(path).getNormalizedPath();
+            if (normalized.isAbsolute()) {
+                return perform(context.getItemManager(), normalized);
+            } else {
+                throw new RepositoryException("Not an absolute path: " + path);
+            }
+        } catch (AccessDeniedException e) {
+            throw new PathNotFoundException(path);
+        } catch (NameException e) {
+            throw new RepositoryException("Invalid path:" + path, e);
+        }
+    }
+
+    /**
+     * Performs this operation using the given item manager.
+     *
+     * @param manager item manager of this session
+     * @param path resolved path of the item
+     * @throws RepositoryException if the operation fails
+     */
+    protected abstract T perform(ItemManager manager, Path path)
+            throws RepositoryException;
+
+    //--------------------------------------------------------------< Object >
+
+    /**
+     * Returns a string representation of this operation.
+     *
+     * @return "getItem(/path/to/item)", etc.
+     */
+    public String toString() {
+        return method + "(" + path + ")";
+    }
 }
\ No newline at end of file

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/session/SessionRefreshOperation.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/session/SessionRefreshOperation.java?rev=984730&r1=984729&r2=984730&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/session/SessionRefreshOperation.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/session/SessionRefreshOperation.java
Thu Aug 12 11:53:39 2010
@@ -26,15 +26,30 @@ import org.apache.jackrabbit.core.cluste
  */
 public class SessionRefreshOperation implements SessionOperation<Object> {
 
+    /**
+     * Flag to keep transient changes.
+     */
     private final boolean keepChanges;
 
+    /**
+     * Flag to synchronise with other cluster nodes.
+     */
     private final boolean clusterSync;
 
+    /**
+     * Creates a session refresh operation.
+     *
+     * @param keepChanges whether to keep transient changes
+     * @param clusterSync whether to synchronise with other cluster nodes
+     */
     public SessionRefreshOperation(boolean keepChanges, boolean clusterSync) {
         this.keepChanges = keepChanges;
         this.clusterSync = clusterSync;
     }
 
+    /**
+     * Refreshes the session.
+     */
     public Object perform(SessionContext context) throws RepositoryException {
         // JCR-1753: Ensure that we are up to date with cluster changes
         ClusterNode cluster = context.getRepositoryContext().getClusterNode();

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/session/SessionSaveOperation.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/session/SessionSaveOperation.java?rev=984730&r1=984729&r2=984730&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/session/SessionSaveOperation.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/session/SessionSaveOperation.java
Thu Aug 12 11:53:39 2010
@@ -21,8 +21,16 @@ import javax.jcr.Session;
 
 import org.apache.jackrabbit.core.id.NodeId;
 
+/**
+ * Operation to persist transient changes in a session.
+ */
 public class SessionSaveOperation implements SessionOperation<Object> {
 
+    /**
+     * Persists transient changes by delegating to the save() method of the
+     * root node (or the parent of transient changes if access to the root
+     * node is not available to this session).
+     */
     public Object perform(SessionContext context) throws RepositoryException {
         NodeId id;
         // JCR-2425: check whether session is allowed to read root node



Mime
View raw message