jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r962485 - in /jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core: ./ session/
Date Fri, 09 Jul 2010 11:38:27 GMT
Author: jukka
Date: Fri Jul  9 11:38:27 2010
New Revision: 962485

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

Make SessionContext an argument of SessionOperation.perform(). The ultimate goal is to be
able to have the SessionOperation classes be the only place where the SessionContext can be
accessed.

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/ItemRefreshOperation.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemSaveOperation.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/NodeImpl.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/SessionMoveOperation.java
    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/SessionOperation.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
    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=962485&r1=962484&r2=962485&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
Fri Jul  9 11:38:27 2010
@@ -384,7 +384,7 @@ public abstract class ItemImpl implement
     public void save() throws RepositoryException {
         // check state of this instance
         sanityCheck();
-        perform(new ItemSaveOperation(sessionContext, getItemState()));
+        perform(new ItemSaveOperation(getItemState()));
     }
 
     /**
@@ -399,7 +399,7 @@ public abstract class ItemImpl implement
             // of all descendant non-transient instances; maybe also
             // have to reset stale ItemState instances
         } else {
-            perform(new ItemRefreshOperation(sessionContext, getItemState()));
+            perform(new ItemRefreshOperation(getItemState()));
         }
     }
 

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemRefreshOperation.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemRefreshOperation.java?rev=962485&r1=962484&r2=962485&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemRefreshOperation.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemRefreshOperation.java
Fri Jul  9 11:38:27 2010
@@ -28,7 +28,7 @@ import org.apache.jackrabbit.core.state.
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-public class ItemRefreshOperation extends SessionOperation {
+public class ItemRefreshOperation implements SessionOperation {
 
     /**
      * Logger instance.
@@ -38,13 +38,11 @@ public class ItemRefreshOperation extend
 
     private final ItemState state;
 
-    public ItemRefreshOperation(SessionContext context, ItemState state) {
-        super("item refresh", context);
+    public ItemRefreshOperation(ItemState state) {
         this.state = state;
     }
 
-    @Override
-    public void perform() throws RepositoryException {
+    public void perform(SessionContext context) throws RepositoryException {
         SessionItemStateManager stateMgr = context.getItemStateManager();
 
         // Optimisation for the root node

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemSaveOperation.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemSaveOperation.java?rev=962485&r1=962484&r2=962485&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemSaveOperation.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemSaveOperation.java
Fri Jul  9 11:38:27 2010
@@ -72,7 +72,7 @@ import org.slf4j.Logger;
 /**
  * The session operation triggered by {@link Item#save()}.
  */
-class ItemSaveOperation extends SessionOperation {
+class ItemSaveOperation implements SessionOperation {
 
     /**
      * Logger instance.
@@ -82,13 +82,11 @@ class ItemSaveOperation extends SessionO
 
     private final ItemState state;
 
-    public ItemSaveOperation(SessionContext context, ItemState state) {
-        super("item save", context);
+    public ItemSaveOperation(ItemState state) {
         this.state = state;
     }
 
-    @Override
-    public void perform() throws RepositoryException {
+    public void perform(SessionContext context) throws RepositoryException {
         SessionItemStateManager stateMgr = context.getItemStateManager();
 
         /**
@@ -97,7 +95,7 @@ class ItemSaveOperation extends SessionO
          */
         Collection<ItemState> dirty;
         try {
-            dirty = getTransientStates();
+            dirty = getTransientStates(context.getItemStateManager());
         } catch (ConcurrentModificationException e) {
             String msg = "Concurrent modification; session is closed";
             log.error(msg, e);
@@ -113,7 +111,8 @@ class ItemSaveOperation extends SessionO
          * build list of transient descendants in the attic
          * (i.e. those marked as 'removed')
          */
-        Collection<ItemState> removed = getRemovedStates();
+        Collection<ItemState> removed =
+            getRemovedStates(context.getItemStateManager());
 
         // All affected item states. The keys are used to look up whether
         // an item is affected, and the values are iterated through below
@@ -214,7 +213,7 @@ class ItemSaveOperation extends SessionO
 
         // validate access and node type constraints
         // (this will also validate child removals)
-        validateTransientItems(dirty, removed);
+        validateTransientItems(context, dirty, removed);
 
         // start the update operation
         try {
@@ -226,20 +225,22 @@ class ItemSaveOperation extends SessionO
         boolean succeeded = false;
         try {
             // process transient items marked as 'removed'
-            removeTransientItems(removed);
+            removeTransientItems(context.getItemStateManager(), removed);
 
             // process transient items that have change in mixins
-            processShareableNodes(dirty);
+            processShareableNodes(
+                    context.getRepositoryContext().getNodeTypeRegistry(),
+                    dirty);
 
             // initialize version histories for new nodes (might generate new transient state)
-            if (initVersionHistories(dirty)) {
+            if (initVersionHistories(context, dirty)) {
                 // re-build the list of transient states because the previous call
                 // generated new transient state
-                dirty = getTransientStates();
+                dirty = getTransientStates(context.getItemStateManager());
             }
 
             // process 'new' or 'modified' transient states
-            persistTransientItems(dirty);
+            persistTransientItems(context.getItemManager(), dirty);
 
             // dispose the transient states marked 'new' or 'modified'
             // at this point item state data is pushed down one level,
@@ -272,7 +273,7 @@ class ItemSaveOperation extends SessionO
                 // applied by persistTransientItems() and we need to
                 // restore transient state, i.e. undo the effect of
                 // persistTransientItems()
-                restoreTransientItems(dirty);
+                restoreTransientItems(context, dirty);
             }
         }
 
@@ -297,7 +298,8 @@ class ItemSaveOperation extends SessionO
      * @throws InvalidItemStateException
      * @throws RepositoryException
      */
-    private Collection<ItemState> getTransientStates()
+    private Collection<ItemState> getTransientStates(
+            SessionItemStateManager sism)
             throws InvalidItemStateException, RepositoryException {
         // list of transient states that should be persisted
         ArrayList<ItemState> dirty = new ArrayList<ItemState>();
@@ -305,7 +307,7 @@ class ItemSaveOperation extends SessionO
         if (state.isNode()) {
             // build list of 'new' or 'modified' descendants
             for (ItemState transientState
-                    : context.getItemStateManager().getDescendantTransientItemStates(state.getId()))
{
+                    : sism.getDescendantTransientItemStates(state.getId())) {
                 // fail-fast test: check status of transient state
                 switch (transientState.getStatus()) {
                     case ItemState.STATUS_NEW:
@@ -384,12 +386,13 @@ class ItemSaveOperation extends SessionO
      * @throws InvalidItemStateException
      * @throws RepositoryException
      */
-    private Collection<ItemState> getRemovedStates()
+    private Collection<ItemState> getRemovedStates(
+            SessionItemStateManager sism)
             throws InvalidItemStateException, RepositoryException {
         if (state.isNode()) {
             ArrayList<ItemState> removed = new ArrayList<ItemState>();
             for (ItemState transientState
-                    : context.getItemStateManager().getDescendantTransientItemStatesInAttic(state.getId()))
{
+                    : sism.getDescendantTransientItemStatesInAttic(state.getId())) {
                 // check if stale
                 switch (transientState.getStatus()) {
                 case ItemState.STATUS_STALE_MODIFIED:
@@ -433,6 +436,7 @@ class ItemSaveOperation extends SessionO
      * and in Property.setValue (for properties to be modified).
      */
     private void validateTransientItems(
+            SessionContext context,
             Iterable<ItemState> dirty, Iterable<ItemState> removed)
             throws RepositoryException {
         SessionImpl session = context.getSessionImpl();
@@ -491,7 +495,9 @@ class ItemSaveOperation extends SessionO
                 // primary type
                 NodeTypeImpl pnt = ntMgr.getNodeType(nodeState.getNodeTypeName());
                 // effective node type (primary type incl. mixins)
-                EffectiveNodeType ent = getEffectiveNodeType(nodeState);
+                EffectiveNodeType ent = getEffectiveNodeType(
+                        context.getRepositoryContext().getNodeTypeRegistry(),
+                        nodeState);
                 /**
                  * if the transient node was added (i.e. if it is 'new') or if
                  * its primary type has changed, check its node type against the
@@ -709,13 +715,14 @@ class ItemSaveOperation extends SessionO
      * walk through list of transient items marked 'removed' and
      * definitively remove each one
      */
-    private void removeTransientItems(Iterable<ItemState> states) {
+    private void removeTransientItems(
+            SessionItemStateManager sism, Iterable<ItemState> states) {
         for (ItemState transientState : states) {
             ItemState persistentState = transientState.getOverlayedState();
             // remove persistent state
             // this will indirectly (through stateDestroyed listener method)
             // permanently invalidate all Item instances wrapping it
-            context.getItemStateManager().destroy(persistentState);
+            sism.destroy(persistentState);
         }
     }
 
@@ -729,7 +736,8 @@ class ItemSaveOperation extends SessionO
      * has been removed, throw.</li>
      * </ul>
      */
-    private void processShareableNodes(Iterable<ItemState> states)
+    private void processShareableNodes(
+            NodeTypeRegistry registry, Iterable<ItemState> states)
             throws RepositoryException {
         for (ItemState is : states) {
             if (is.isNode()) {
@@ -737,10 +745,10 @@ class ItemSaveOperation extends SessionO
                 boolean wasShareable = false;
                 if (ns.hasOverlayedState()) {
                     NodeState old = (NodeState) ns.getOverlayedState();
-                    EffectiveNodeType ntOld = getEffectiveNodeType(old);
+                    EffectiveNodeType ntOld = getEffectiveNodeType(registry, old);
                     wasShareable = ntOld.includesNodeType(NameConstants.MIX_SHAREABLE);
                 }
-                EffectiveNodeType ntNew = getEffectiveNodeType(ns);
+                EffectiveNodeType ntNew = getEffectiveNodeType(registry, ns);
                 boolean isShareable = ntNew.includesNodeType(NameConstants.MIX_SHAREABLE);
 
                 if (!wasShareable && isShareable) {
@@ -765,7 +773,8 @@ class ItemSaveOperation extends SessionO
      * @return true if this call generated new transient state; otherwise false
      * @throws RepositoryException
      */
-    private boolean initVersionHistories(Iterable<ItemState> states)
+    private boolean initVersionHistories(
+            SessionContext context, Iterable<ItemState> states)
             throws RepositoryException {
         SessionImpl session = context.getSessionImpl();
         ItemManager itemMgr = context.getItemManager();
@@ -775,7 +784,9 @@ class ItemSaveOperation extends SessionO
         for (ItemState itemState : states) {
             if (itemState.isNode()) {
                 NodeState nodeState = (NodeState) itemState;
-                EffectiveNodeType nt = getEffectiveNodeType(nodeState);
+                EffectiveNodeType nt = getEffectiveNodeType(
+                        context.getRepositoryContext().getNodeTypeRegistry(),
+                        nodeState);
                 if (nt.includesNodeType(NameConstants.MIX_VERSIONABLE)) {
                     if (!nodeState.hasPropertyName(NameConstants.JCR_VERSIONHISTORY)) {
                         NodeImpl node = (NodeImpl) itemMgr.getItem(itemState.getId());
@@ -830,9 +841,9 @@ class ItemSaveOperation extends SessionO
     /**
      * walk through list of transient items and persist each one
      */
-    private void persistTransientItems(Iterable<ItemState> states)
+    private void persistTransientItems(
+            ItemManager itemMgr, Iterable<ItemState> states)
             throws RepositoryException {
-        ItemManager itemMgr = context.getItemManager();
         for (ItemState state : states) {
             // persist state of transient item
             itemMgr.getItem(state.getId()).makePersistent();
@@ -842,7 +853,8 @@ class ItemSaveOperation extends SessionO
     /**
      * walk through list of transient states and re-apply transient changes
      */
-    private void restoreTransientItems(Iterable<ItemState> items) {
+    private void restoreTransientItems(
+            SessionContext context, Iterable<ItemState> items) {
         ItemManager itemMgr = context.getItemManager();
         SessionItemStateManager stateMgr = context.getItemStateManager();
 
@@ -897,11 +909,10 @@ class ItemSaveOperation extends SessionO
      * @return the effective node type
      * @throws RepositoryException
      */
-    private EffectiveNodeType getEffectiveNodeType(NodeState state)
+    private EffectiveNodeType getEffectiveNodeType(
+            NodeTypeRegistry registry, NodeState state)
             throws RepositoryException {
         try {
-            NodeTypeRegistry registry =
-                context.getRepositoryContext().getNodeTypeRegistry();
             return registry.getEffectiveNodeType(
                     state.getNodeTypeName(), state.getMixinTypeNames());
         } catch (NodeTypeConflictException e) {

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/NodeImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/NodeImpl.java?rev=962485&r1=962484&r2=962485&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/NodeImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/NodeImpl.java
Fri Jul  9 11:38:27 2010
@@ -1579,7 +1579,7 @@ public class NodeImpl extends ItemImpl i
             throws ValueFormatException, VersionException, LockException,
             ConstraintViolationException, RepositoryException {
         SetPropertyOperation operation =
-            new SetPropertyOperation(sessionContext, name, value, false);
+            new SetPropertyOperation(name, value, false);
         sessionContext.getSessionState().perform(operation);
         return operation.getProperty();
     }
@@ -2165,8 +2165,8 @@ public class NodeImpl extends ItemImpl i
         if (value != null && value.getType() != type) {
             value = ValueHelper.convert(value, type, getValueFactory());
         }
-        SetPropertyOperation operation = new SetPropertyOperation(
-                sessionContext, session.getQName(name), value, true);
+        SetPropertyOperation operation =
+            new SetPropertyOperation(session.getQName(name), value, true);
         sessionContext.getSessionState().perform(operation);
         return operation.getProperty();
     }
@@ -2174,8 +2174,8 @@ public class NodeImpl extends ItemImpl i
     /** Wrapper around {@link SetPropertyOperation} */
     public Property setProperty(String name, Value value)
             throws RepositoryException {
-        SetPropertyOperation operation = new SetPropertyOperation(
-                sessionContext, session.getQName(name), value, false);
+        SetPropertyOperation operation =
+            new SetPropertyOperation(session.getQName(name), value, false);
         sessionContext.getSessionState().perform(operation);
         return operation.getProperty();
     }
@@ -2254,7 +2254,7 @@ public class NodeImpl extends ItemImpl i
      * definition and the implementation tries to convert the passed value to
      * that type. If that fails, then a {@link ValueFormatException} is thrown.
      */
-    private class SetPropertyOperation extends SessionOperation {
+    private class SetPropertyOperation implements SessionOperation {
 
         private final Name name;
 
@@ -2271,9 +2271,7 @@ public class NodeImpl extends ItemImpl i
          * @param enforceType <code>true</code> to enforce the value type
          */
         public SetPropertyOperation(
-                SessionContext sessionContext,
                 Name name, Value value, boolean enforceType) {
-            super("setProperty()", sessionContext);
             this.name = name;
             this.value = value;
             this.enforceType = enforceType;
@@ -2305,8 +2303,7 @@ public class NodeImpl extends ItemImpl i
          *                                      validation immediately.
          * @throws RepositoryException          if another error occurs.
          */
-        @Override
-        public void perform() throws RepositoryException {
+        public void perform(SessionContext context) throws RepositoryException {
             itemSanityCheck();
             // check pre-conditions for setting property
             checkSetProperty();

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=962485&r1=962484&r2=962485&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
Fri Jul  9 11:38:27 2010
@@ -865,7 +865,7 @@ public class SessionImpl extends Abstrac
      * {@inheritDoc}
      */
     public void save() throws RepositoryException {
-        perform(new SessionSaveOperation(context));
+        perform(new SessionSaveOperation());
     }
 
     /**
@@ -873,7 +873,7 @@ public class SessionImpl extends Abstrac
      */
     public void refresh(boolean keepChanges) throws RepositoryException {
         perform(new SessionRefreshOperation(
-                context, keepChanges, clusterSyncOnRefresh()));
+                keepChanges, clusterSyncOnRefresh()));
     }
 
     /**
@@ -907,8 +907,7 @@ public class SessionImpl extends Abstrac
      */
     public void move(String srcAbsPath, String destAbsPath)
             throws RepositoryException {
-        perform(new SessionMoveOperation(
-                context, this, srcAbsPath, destAbsPath));
+        perform(new SessionMoveOperation(this, srcAbsPath, destAbsPath));
     }
 
     /**

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/SessionMoveOperation.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/SessionMoveOperation.java?rev=962485&r1=962484&r2=962485&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/SessionMoveOperation.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/SessionMoveOperation.java
Fri Jul  9 11:38:27 2010
@@ -36,7 +36,7 @@ import org.apache.jackrabbit.spi.commons
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-public class SessionMoveOperation extends SessionOperation {
+public class SessionMoveOperation implements SessionOperation {
 
     private final Logger log =
         LoggerFactory.getLogger(SessionMoveOperation.class);
@@ -54,11 +54,8 @@ public class SessionMoveOperation extend
     private final Path.Element destName;
 
     public SessionMoveOperation(
-            SessionContext sessionContext,
             PathResolver resolver, String srcAbsPath, String destAbsPath)
             throws RepositoryException {
-        super("move", sessionContext);
-
         this.srcAbsPath = srcAbsPath;
         this.srcPath = getAbsolutePath(resolver, srcAbsPath);
         this.srcName = srcPath.getNameElement();
@@ -105,8 +102,7 @@ public class SessionMoveOperation extend
         }
     }
 
-    @Override
-    public void perform() throws RepositoryException {
+    public void perform(SessionContext context) throws RepositoryException {
         // Get node instances
         NodeImpl targetNode = getNode(context, srcPath, srcAbsPath);
         NodeImpl srcParentNode =

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=962485&r1=962484&r2=962485&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
Fri Jul  9 11:38:27 2010
@@ -66,7 +66,7 @@ public class SessionContext {
         assert session != null;
         this.repositoryContext = repositoryContext;
         this.session = session;
-        this.state = new SessionState();
+        this.state = new SessionState(this);
     }
 
     public RepositoryContext getRepositoryContext() {

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/session/SessionOperation.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/session/SessionOperation.java?rev=962485&r1=962484&r2=962485&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/session/SessionOperation.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/session/SessionOperation.java
Fri Jul  9 11:38:27 2010
@@ -19,42 +19,18 @@ package org.apache.jackrabbit.core.sessi
 import javax.jcr.RepositoryException;
 
 /**
- * An operation that is performed on a JCR session. Used by the
- * {@link SessionState} interface to implement generic controls like
- * synchronization and liveness checks on all session operation.
+ * Session operation. Used by the {@link SessionState} class to implement
+ * generic controls like synchronization and liveness checks on all session
+ * operation.
  */
-public abstract class SessionOperation {
-
-    private final String name;
-
-    protected final SessionContext context;
-
-    /**
-     * Creates a new session operation.
-     *
-     * @param name operation name
-     * @param context component context of the session
-     */
-    protected SessionOperation(String name, SessionContext context) {
-        this.name = name;
-        this.context = context;
-    }
+public interface SessionOperation {
 
     /**
-     * Performs this operation. The default implementation does nothing;
-     * subclasses should override this method to implement custom operations.
+     * Performs the session operation.
      *
+     * @param context component context of this session
      * @throws RepositoryException if the operation fails
      */
-    public abstract void perform() throws RepositoryException;
-
-    /**
-     * Returns the name of this operation.
-     *
-     * @return operation name
-     */
-    public String toString() {
-        return name;
-    }
+    void perform(SessionContext context) throws RepositoryException;
 
 }

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=962485&r1=962484&r2=962485&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
Fri Jul  9 11:38:27 2010
@@ -24,21 +24,18 @@ import org.apache.jackrabbit.core.cluste
 /**
  * Operation to refresh the state of a session.
  */
-public class SessionRefreshOperation extends SessionOperation {
+public class SessionRefreshOperation implements SessionOperation {
 
     private final boolean keepChanges;
 
     private final boolean clusterSync;
 
-    public SessionRefreshOperation(
-            SessionContext context, boolean keepChanges, boolean clusterSync) {
-        super("refresh", context);
+    public SessionRefreshOperation(boolean keepChanges, boolean clusterSync) {
         this.keepChanges = keepChanges;
         this.clusterSync = clusterSync;
     }
 
-    @Override
-    public void perform() throws RepositoryException {
+    public void perform(SessionContext context) throws RepositoryException {
         // JCR-1753: Ensure that we are up to date with cluster changes
         ClusterNode cluster = context.getRepositoryContext().getClusterNode();
         if (cluster != null && clusterSync) {

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=962485&r1=962484&r2=962485&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
Fri Jul  9 11:38:27 2010
@@ -21,14 +21,9 @@ import javax.jcr.Session;
 
 import org.apache.jackrabbit.core.id.NodeId;
 
-public class SessionSaveOperation extends SessionOperation {
+public class SessionSaveOperation implements SessionOperation {
 
-    public SessionSaveOperation(SessionContext context) {
-        super("save", context);
-    }
-
-    @Override
-    public void perform() throws RepositoryException {
+    public void perform(SessionContext context) throws RepositoryException {
         NodeId id;
         // JCR-2425: check whether session is allowed to read root node
         if (context.getSessionImpl().hasPermission("/", Session.ACTION_READ)) {

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=962485&r1=962484&r2=962485&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
Fri Jul  9 11:38:27 2010
@@ -49,6 +49,11 @@ public class SessionState {
         LoggerFactory.getLogger(SessionState.class);
 
     /**
+     * Component context of this session.
+     */
+    private final SessionContext context;
+
+    /**
      * The lock used to guarantee synchronized execution of repository
      * operations. An explicit lock is used instead of normal Java
      * synchronization in order to be able to log attempts to concurrently
@@ -65,6 +70,10 @@ public class SessionState {
      */
     private volatile Exception closed = null;
 
+    public SessionState(SessionContext context) {
+        this.context = context;
+    }
+
     /**
      * Checks whether this session is alive. This method should generally
      * only be called from within a performed {@link SessionOperation}, as
@@ -109,7 +118,7 @@ public class SessionState {
         try {
             checkAlive();
             log.debug("Performing {}", operation);
-            operation.perform();
+            operation.perform(context);
         } finally {
             lock.unlock();
         }



Mime
View raw message