jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r628457 - in /jackrabbit/sandbox/jackrabbit-ngp/src/main/java/org/apache/jackrabbit/ngp: SessionImpl.java session/BoundSession.java session/ClosedSession.java session/SessionState.java session/StateSwitch.java session/UnboundSession.java
Date Sun, 17 Feb 2008 08:58:30 GMT
Author: jukka
Date: Sun Feb 17 00:58:23 2008
New Revision: 628457

URL: http://svn.apache.org/viewvc?rev=628457&view=rev
Log:
NGP: Simplified session code

Removed:
    jackrabbit/sandbox/jackrabbit-ngp/src/main/java/org/apache/jackrabbit/ngp/session/BoundSession.java
    jackrabbit/sandbox/jackrabbit-ngp/src/main/java/org/apache/jackrabbit/ngp/session/ClosedSession.java
    jackrabbit/sandbox/jackrabbit-ngp/src/main/java/org/apache/jackrabbit/ngp/session/StateSwitch.java
    jackrabbit/sandbox/jackrabbit-ngp/src/main/java/org/apache/jackrabbit/ngp/session/UnboundSession.java
Modified:
    jackrabbit/sandbox/jackrabbit-ngp/src/main/java/org/apache/jackrabbit/ngp/SessionImpl.java
    jackrabbit/sandbox/jackrabbit-ngp/src/main/java/org/apache/jackrabbit/ngp/session/SessionState.java

Modified: jackrabbit/sandbox/jackrabbit-ngp/src/main/java/org/apache/jackrabbit/ngp/SessionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-ngp/src/main/java/org/apache/jackrabbit/ngp/SessionImpl.java?rev=628457&r1=628456&r2=628457&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-ngp/src/main/java/org/apache/jackrabbit/ngp/SessionImpl.java
(original)
+++ jackrabbit/sandbox/jackrabbit-ngp/src/main/java/org/apache/jackrabbit/ngp/SessionImpl.java
Sun Feb 17 00:58:23 2008
@@ -16,33 +16,20 @@
  */
 package org.apache.jackrabbit.ngp;
 
-import java.security.AccessControlException;
 import java.util.Map;
 
-import javax.jcr.AccessDeniedException;
 import javax.jcr.Credentials;
-import javax.jcr.InvalidItemStateException;
-import javax.jcr.ItemExistsException;
-import javax.jcr.ItemNotFoundException;
 import javax.jcr.NamespaceException;
 import javax.jcr.Node;
-import javax.jcr.PathNotFoundException;
 import javax.jcr.Repository;
 import javax.jcr.RepositoryException;
 import javax.jcr.SimpleCredentials;
-import javax.jcr.UnsupportedRepositoryOperationException;
 import javax.jcr.ValueFactory;
 import javax.jcr.Workspace;
-import javax.jcr.lock.LockException;
-import javax.jcr.nodetype.ConstraintViolationException;
-import javax.jcr.nodetype.NoSuchNodeTypeException;
-import javax.jcr.version.VersionException;
 
 import org.apache.jackrabbit.commons.AbstractSession;
 import org.apache.jackrabbit.ngp.journal.Journal;
-import org.apache.jackrabbit.ngp.session.ClosedSession;
-import org.apache.jackrabbit.ngp.session.StateSwitch;
-import org.apache.jackrabbit.ngp.session.UnboundSession;
+import org.apache.jackrabbit.ngp.session.SessionState;
 import org.xml.sax.ContentHandler;
 import org.xml.sax.SAXException;
 
@@ -52,16 +39,23 @@
 
     private final Map<String, Object> attributes;
 
-    private StateSwitch state;
+    private SessionState state;
 
     SessionImpl(
             Repository repository, Map<String, Object> attributes,
-            Journal journal) {
+            Journal journal) throws RepositoryException {
         this.repository = repository;
         this.attributes = attributes;
-        this.state = new StateSwitch();
+        this.state = new SessionState(journal);
+    }
 
-        state.setState(new UnboundSession(journal, state));
+    private SessionState getState() throws RepositoryException {
+        SessionState state = this.state;
+        if (state != null) {
+            return state;
+        } else {
+            throw new RepositoryException("This session has been closed");
+        }
     }
 
     /**
@@ -109,12 +103,19 @@
     }
 
     /**
+     * Closes this session. Any unsaved state is discarded.
+     */
+    public void logout() {
+        state = null;
+    }
+
+    /**
      * Returns <code>true</code> if this session is usable by the client.
      *
      * @return state of this session
      */
     public boolean isLive() {
-        return state.isLive();
+        return state != null;
     }
 
     /**
@@ -125,18 +126,11 @@
      */
     public synchronized void refresh(boolean keepChanges)
             throws RepositoryException {
-        state.refresh(keepChanges);
-    }
-
-    /**
-     * Closes this session. Any unsaved state is discarded.
-     */
-    public synchronized void logout() {
-        state.setState(new ClosedSession());
+        getState().refresh(keepChanges);
     }
 
     public synchronized Node getRootNode() throws RepositoryException {
-        return new NodeImpl(this, null, "", state.getRootNode());
+        return new NodeImpl(this, null, "", getState().getRootNode());
     }
 
     public void addLockToken(String lt) {
@@ -145,29 +139,30 @@
     }
 
     public void checkPermission(String absPath, String actions)
-            throws AccessControlException, RepositoryException {
+            throws RepositoryException {
         // TODO Auto-generated method stub
 
     }
 
-    public void exportDocumentView(String absPath,
-            ContentHandler contentHandler, boolean skipBinary, boolean noRecurse)
-            throws PathNotFoundException, SAXException, RepositoryException {
+    public void exportDocumentView(
+            String absPath, ContentHandler contentHandler,
+            boolean skipBinary, boolean noRecurse)
+            throws SAXException, RepositoryException {
         // TODO Auto-generated method stub
 
     }
 
-    public void exportSystemView(String absPath, ContentHandler contentHandler,
+    public void exportSystemView(
+            String absPath, ContentHandler contentHandler,
             boolean skipBinary, boolean noRecurse)
-            throws PathNotFoundException, SAXException, RepositoryException {
+            throws SAXException, RepositoryException {
         // TODO Auto-generated method stub
 
     }
 
-    public ContentHandler getImportContentHandler(String parentAbsPath,
-            int uuidBehavior) throws PathNotFoundException,
-            ConstraintViolationException, VersionException, LockException,
-            RepositoryException {
+    public ContentHandler getImportContentHandler(
+            String parentAbsPath, int uuidBehavior)
+            throws RepositoryException {
         // TODO Auto-generated method stub
         return null;
     }
@@ -188,20 +183,17 @@
         return null;
     }
 
-    public String getNamespaceURI(String prefix) throws NamespaceException,
-            RepositoryException {
+    public String getNamespaceURI(String prefix) throws RepositoryException {
         // TODO Auto-generated method stub
         return null;
     }
 
-    public Node getNodeByUUID(String uuid) throws ItemNotFoundException,
-            RepositoryException {
+    public Node getNodeByUUID(String uuid) throws RepositoryException {
         // TODO Auto-generated method stub
         return null;
     }
 
-    public ValueFactory getValueFactory()
-            throws UnsupportedRepositoryOperationException, RepositoryException {
+    public ValueFactory getValueFactory() throws RepositoryException {
         // TODO Auto-generated method stub
         return null;
     }
@@ -217,9 +209,7 @@
     }
 
     public void move(String srcAbsPath, String destAbsPath)
-            throws ItemExistsException, PathNotFoundException,
-            VersionException, ConstraintViolationException, LockException,
-            RepositoryException {
+            throws RepositoryException {
         // TODO Auto-generated method stub
 
     }
@@ -229,16 +219,13 @@
 
     }
 
-    public void save() throws AccessDeniedException, ItemExistsException,
-            ConstraintViolationException, InvalidItemStateException,
-            VersionException, LockException, NoSuchNodeTypeException,
-            RepositoryException {
+    public void save() throws RepositoryException {
         // TODO Auto-generated method stub
 
     }
 
     public void setNamespacePrefix(String prefix, String uri)
-            throws NamespaceException, RepositoryException {
+            throws RepositoryException {
         // TODO Auto-generated method stub
 
     }

Modified: jackrabbit/sandbox/jackrabbit-ngp/src/main/java/org/apache/jackrabbit/ngp/session/SessionState.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-ngp/src/main/java/org/apache/jackrabbit/ngp/session/SessionState.java?rev=628457&r1=628456&r2=628457&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-ngp/src/main/java/org/apache/jackrabbit/ngp/session/SessionState.java
(original)
+++ jackrabbit/sandbox/jackrabbit-ngp/src/main/java/org/apache/jackrabbit/ngp/session/SessionState.java
Sun Feb 17 00:58:23 2008
@@ -18,14 +18,27 @@
 
 import javax.jcr.RepositoryException;
 
+import org.apache.jackrabbit.ngp.journal.Journal;
+import org.apache.jackrabbit.ngp.node.BoundNode;
 import org.apache.jackrabbit.ngp.node.NodeState;
 
-public interface SessionState {
+public class SessionState {
 
-    boolean isLive();
+    private final Journal journal;
 
-    void refresh(boolean keepChanges) throws RepositoryException;
+    private final NodeState root;
 
-    NodeState getRootNode() throws RepositoryException;
+    public SessionState(Journal journal) throws RepositoryException {
+        this.journal = journal;
+        this.root = new BoundNode(journal, journal.getDefaultRecord());
+    }
+
+    public void refresh(boolean keepChanges) throws RepositoryException {
+        root.refresh(journal.getDefaultRecord());
+    }
+
+    public NodeState getRootNode() {
+        return root;
+    }
 
 }



Mime
View raw message