Return-Path: Delivered-To: apmail-jackrabbit-commits-archive@www.apache.org Received: (qmail 9014 invoked from network); 17 Feb 2008 08:58:55 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 17 Feb 2008 08:58:55 -0000 Received: (qmail 53028 invoked by uid 500); 17 Feb 2008 08:58:49 -0000 Delivered-To: apmail-jackrabbit-commits-archive@jackrabbit.apache.org Received: (qmail 53001 invoked by uid 500); 17 Feb 2008 08:58:49 -0000 Mailing-List: contact commits-help@jackrabbit.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@jackrabbit.apache.org Delivered-To: mailing list commits@jackrabbit.apache.org Received: (qmail 52992 invoked by uid 99); 17 Feb 2008 08:58:49 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 17 Feb 2008 00:58:49 -0800 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 17 Feb 2008 08:58:11 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id A6BE31A9832; Sun, 17 Feb 2008 00:58:30 -0800 (PST) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: commits@jackrabbit.apache.org From: jukka@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20080217085830.A6BE31A9832@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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 attributes; - private StateSwitch state; + private SessionState state; SessionImpl( Repository repository, Map 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 true 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; + } }