jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r1175041 - in /jackrabbit/sandbox/jackrabbit-mk: jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/ jackrabbit-spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/
Date Fri, 23 Sep 2011 21:39:47 GMT
Author: mduerig
Date: Fri Sep 23 21:39:47 2011
New Revision: 1175041

URL: http://svn.apache.org/viewvc?rev=1175041&view=rev
Log:
Microkernel based Jackrabbit prototype (WIP)
refactor: make SessionState inherit from SessionInfoImpl

Modified:
    jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/AbstractRepositoryService.java
    jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/RepositoryServiceImpl.java
    jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/SessionState.java

Modified: jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/AbstractRepositoryService.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/AbstractRepositoryService.java?rev=1175041&r1=1175040&r2=1175041&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/AbstractRepositoryService.java
(original)
+++ jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/AbstractRepositoryService.java
Fri Sep 23 21:39:47 2011
@@ -345,9 +345,6 @@ public abstract class AbstractRepository
      */
     @Override
     public void dispose(SessionInfo sessionInfo) throws RepositoryException {
-        if (changePollingExecutor != null) {
-            changePollingExecutor.shutdown();
-        }
     }
 
     //-----------------------------< node types >-------------------------------

Modified: jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/RepositoryServiceImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/RepositoryServiceImpl.java?rev=1175041&r1=1175040&r2=1175041&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/RepositoryServiceImpl.java
(original)
+++ jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/RepositoryServiceImpl.java
Fri Sep 23 21:39:47 2011
@@ -69,7 +69,6 @@ import javax.jcr.PathNotFoundException;
 import javax.jcr.PropertyType;
 import javax.jcr.RepositoryException;
 import javax.jcr.UnsupportedRepositoryOperationException;
-import javax.jcr.query.InvalidQueryException;
 import javax.jcr.query.Query;
 import javax.jcr.version.OnParentVersionAction;
 import java.io.IOException;
@@ -85,7 +84,6 @@ import java.util.Map.Entry;
 import java.util.Set;
 import java.util.UUID;
 import java.util.concurrent.Callable;
-import java.util.concurrent.ConcurrentHashMap;
 
 import static javax.jcr.Repository.IDENTIFIER_STABILITY;
 import static javax.jcr.Repository.IDENTIFIER_STABILITY_METHOD_DURATION;
@@ -199,7 +197,6 @@ public class RepositoryServiceImpl exten
     private final PropertyIndex jcrUuidIndex;
     private final PrefixIndex referenceIndex;
     private final PrefixIndex weakReferenceIndex;
-    private final Map<SessionInfo, SessionState> sessions = new ConcurrentHashMap<SessionInfo,
SessionState>();
     private final NodeTypeStore nodeTypeStore;
     private final QueryProcessor queryProcessor;
     private final String defaultWorkspace;
@@ -279,14 +276,7 @@ public class RepositoryServiceImpl exten
             userId = anonymousId;
         }
 
-        SessionInfo s = super.createSessionInfo(userId, workspaceName);
-        createSessionState(s);
-        return s;
-    }
-
-    @Override
-    public void dispose(SessionInfo sessionInfo) throws RepositoryException {
-        sessions.remove(sessionInfo);
+        return new SessionState(microKernel, userId, workspaceName);
     }
 
     @Override
@@ -561,7 +551,7 @@ public class RepositoryServiceImpl exten
 
     @Override
     public Subscription createSubscription(SessionInfo sessionInfo, EventFilter[] filters)
throws RepositoryException {
-        SubscriptionImpl subscription = new SubscriptionImpl(microKernel, sessionState(sessionInfo));
+        SubscriptionImpl subscription = new SubscriptionImpl(microKernel, sessionInfoImpl(sessionInfo));
         subscription.setEventFilters(filters);
         return subscription;
     }
@@ -894,8 +884,8 @@ public class RepositoryServiceImpl exten
         }
     }
 
-    private static SessionInfoImpl sessionInfoImpl(SessionInfo sessionInfo) throws RepositoryException
{
-        if (sessionInfo instanceof SessionInfoImpl) {
+    private static SessionState sessionInfoImpl(SessionInfo sessionInfo) throws RepositoryException
{
+        if (sessionInfo instanceof SessionState) {
             return cast(sessionInfo);
         }
         else {
@@ -905,29 +895,6 @@ public class RepositoryServiceImpl exten
         }
     }
 
-    private SessionState sessionState(SessionInfo sessionInfo) throws RepositoryException
{
-        SessionState state = sessions.get(sessionInfo);
-
-        if (state == null) {
-            RepositoryException e = new RepositoryException("Invalid session");
-            log.error(e.getMessage(), e);
-            throw e;
-        }
-        else {
-            return state;
-        }
-    }
-
-    private void createSessionState(SessionInfo sessionInfo) throws RepositoryException {
-        try {
-            sessions.put(sessionInfo, new SessionState(sessionInfo, microKernel.getHeadRevision()));
-        }
-        catch (MicroKernelException e) {
-            log.error(e.getMessage(), e);
-            throw new RepositoryException(e.getMessage(), e);
-        }
-    }
-
     private void createWorkspace(String revisionId, String name, boolean ignoreExisting)
throws RepositoryException {
         try {
             if (microKernel.nodeExists('/' + name, revisionId)) {
@@ -1108,7 +1075,7 @@ public class RepositoryServiceImpl exten
             // todo: check value constraints
             // todo: throw InvalidItemStateException when item no longer exists
             // todo: throw ReferentialIntegrityException when saving removed node which is
target of a reference
-            sessionState(sessionInfo).commitWithLock(new Callable<String>() {
+            sessionInfoImpl(sessionInfo).commitWithLock(new Callable<String>() {
                 @Override
                 public String call() {
                     String rev = microKernel.getHeadRevision();

Modified: jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/SessionState.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/SessionState.java?rev=1175041&r1=1175040&r2=1175041&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/SessionState.java
(original)
+++ jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/SessionState.java
Fri Sep 23 21:39:47 2011
@@ -19,7 +19,8 @@
 
 package org.apache.jackrabbit.spi2microkernel;
 
-import org.apache.jackrabbit.spi.SessionInfo;
+import org.apache.jackrabbit.mk.api.MicroKernel;
+import org.apache.jackrabbit.spi.commons.SessionInfoImpl;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -28,19 +29,17 @@ import java.util.ArrayList;
 import java.util.List;
 import java.util.concurrent.Callable;
 
-public class SessionState {
+public class SessionState extends SessionInfoImpl {
     private static final Logger log = LoggerFactory.getLogger(SessionState.class);
 
-    private final SessionInfo sessionInfo;
+    private final MicroKernel microKernel;
     private final List<String> commitLog = new ArrayList<String>();
 
-    public SessionState(SessionInfo sessionInfo, String initialRevision) {
-        this.sessionInfo = sessionInfo;
-        commitLog.add(initialRevision);
-    }
-
-    public SessionInfo getSessionInfo() {
-        return sessionInfo;
+    public SessionState(MicroKernel microKernel, String userId, String workspaceName) {
+        this.microKernel = microKernel;
+        setUserID(userId);
+        setWorkspacename(workspaceName);
+        commitLog.add(microKernel.getHeadRevision());
     }
 
     public void commitWithLock(Callable<String> commit) throws RepositoryException
{
@@ -86,4 +85,11 @@ public class SessionState {
     public boolean hasRevision(String revisionId) {
         return getCommitLog().contains(revisionId);
     }
+
+    //------------------------------------------< SessionInfo >---
+
+    @Override
+    public void refresh() {
+        super.refresh();    // todo implement refresh
+    }
 }



Mime
View raw message