jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r1182998 - in /jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel: SessionInfoImpl.java SubscriptionImpl.java
Date Thu, 13 Oct 2011 17:25:15 GMT
Author: mduerig
Date: Thu Oct 13 17:25:14 2011
New Revision: 1182998

URL: http://svn.apache.org/viewvc?rev=1182998&view=rev
Log:
Microkernel based Jackrabbit prototype (WIP)
observation: use session id to determine which changes are local

Modified:
    jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/SessionInfoImpl.java
    jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/SubscriptionImpl.java

Modified: jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/SessionInfoImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/SessionInfoImpl.java?rev=1182998&r1=1182997&r2=1182998&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/SessionInfoImpl.java
(original)
+++ jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/SessionInfoImpl.java
Thu Oct 13 17:25:14 2011
@@ -25,25 +25,21 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import javax.jcr.RepositoryException;
-import java.util.ArrayList;
-import java.util.List;
 import java.util.UUID;
+import java.util.concurrent.atomic.AtomicReference;
 
 public class SessionInfoImpl extends org.apache.jackrabbit.spi.commons.SessionInfoImpl {
     private static final Logger log = LoggerFactory.getLogger(SessionInfoImpl.class);
 
     private final String id = UUID.randomUUID().toString();
     private final MicroKernel microKernel;
-    private final List<String> commitLog = new ArrayList<String>();
-
-    private String revision;
+    private final AtomicReference<String> revision = new AtomicReference<String>();
 
     public SessionInfoImpl(MicroKernel microKernel, String userId, String workspaceName)
{
         this.microKernel = microKernel;
         setUserID(userId);
         setWorkspacename(workspaceName);
-        revision = microKernel.getHeadRevision();
-        commitLog.add(revision);
+        revision.set(microKernel.getHeadRevision());
     }
 
     public String getId() {
@@ -51,16 +47,13 @@ public class SessionInfoImpl extends org
     }
 
     public String getRevision() {
-        return revision;
+        return revision.get();
     }
 
     public void commitWithLock(Function1<MicroKernel, String> commit) throws RepositoryException
{
         try {
-            synchronized (commitLog) {
-                revision = commit.apply(microKernel);
-                refresh();
-                commitLog.add(revision);
-            }
+            revision.set(commit.apply(microKernel));
+            super.refresh();
         }
         catch (Exception e) {
             log.error(e.getMessage(), e);
@@ -68,44 +61,12 @@ public class SessionInfoImpl extends org
         }
     }
 
-    /**
-     * The initial revision from when the session was created
-     * @return
-     */
-    public String getInitialRevision() {
-        synchronized (commitLog) {
-            return commitLog.get(commitLog.size() - 1);
-        }
-    }
-
-    /**
-     * Snapshot of this session state's commit log at the time of the call
-     * @return
-     */
-    public List<String> getCommitLog() {
-        List<String> commitLog = new ArrayList<String>(this.commitLog.size());
-        synchronized (this.commitLog) {
-            commitLog.addAll(this.commitLog);
-        }
-        return commitLog;
-    }
-
-    /**
-     * Determines whether the given {@code revisionId} was committed by this session.
-     * That is, whether the commit log of this instance contains the given revisionId.
-     * @param revisionId
-     * @return
-     */
-    public boolean hasRevision(String revisionId) {
-        return getCommitLog().contains(revisionId);
-    }
-
     //------------------------------------------< SessionInfo >---
 
     @Override
     public void refresh() {
         super.refresh();
-        revision = microKernel.getHeadRevision();
+        revision.set(microKernel.getHeadRevision());
     }
 
     //------------------------------------------< Object >---

Modified: jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/SubscriptionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/SubscriptionImpl.java?rev=1182998&r1=1182997&r2=1182998&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/SubscriptionImpl.java
(original)
+++ jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/SubscriptionImpl.java
Thu Oct 13 17:25:14 2011
@@ -246,7 +246,7 @@ public class SubscriptionImpl implements
 
         public EventSource(EventFilter[] eventFilters, SessionInfoImpl sessionInfo) {
             this.eventFilters = eventFilters;
-            startRevision = sessionInfo.getInitialRevision();
+            startRevision = sessionInfo.getRevision();
         }
 
         public EventSource(EventFilter[] eventFilters, String startRevision) {
@@ -318,7 +318,7 @@ public class SubscriptionImpl implements
                     .setUserData(commitInfo.getUserData());
 
             Collection<Event> events = getEvents(changes, eventTemplate);
-            boolean isLocal = sessionInfo.hasRevision(revisionId);
+            boolean isLocal = sessionInfo.getId().equals(commitInfo.getSessionId());
 
             // events.filter(event => eventFilters.any(_.accept(event, isLocal))
             for (Iterator<Event> it = events.iterator(); it.hasNext(); ) {



Mime
View raw message