james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nor...@apache.org
Subject svn commit: r952134 - /james/imap/trunk/jcr/src/main/java/org/apache/james/imap/jcr/AbstractJCRMapper.java
Date Mon, 07 Jun 2010 08:10:34 GMT
Author: norman
Date: Mon Jun  7 08:10:33 2010
New Revision: 952134

URL: http://svn.apache.org/viewvc?rev=952134&view=rev
Log:
Only use one JCR Session per Request

Modified:
    james/imap/trunk/jcr/src/main/java/org/apache/james/imap/jcr/AbstractJCRMapper.java

Modified: james/imap/trunk/jcr/src/main/java/org/apache/james/imap/jcr/AbstractJCRMapper.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/jcr/src/main/java/org/apache/james/imap/jcr/AbstractJCRMapper.java?rev=952134&r1=952133&r2=952134&view=diff
==============================================================================
--- james/imap/trunk/jcr/src/main/java/org/apache/james/imap/jcr/AbstractJCRMapper.java (original)
+++ james/imap/trunk/jcr/src/main/java/org/apache/james/imap/jcr/AbstractJCRMapper.java Mon
Jun  7 08:10:33 2010
@@ -36,11 +36,11 @@ import org.apache.james.imap.store.trans
 public abstract class AbstractJCRMapper extends AbstractTransactionalMapper implements JCRImapConstants
{
     public final static String MAILBOXES_PATH =  "mailboxes";
     public final static String SUBSCRIPTIONS_PATH =  "subscriptions";
+    private final static String JCR_SESSION = "JCR_SESSION";
 
-    private Session session;
     private final Log logger;
-	private final MailboxSessionJCRRepository repository;
-	private final MailboxSession mSession;
+    private final MailboxSessionJCRRepository repository;
+    private final MailboxSession mSession;
     private final NodeLocker locker;
 
     public AbstractJCRMapper(final MailboxSessionJCRRepository repository, MailboxSession
mSession, NodeLocker locker, Log logger) {
@@ -69,8 +69,10 @@ public abstract class AbstractJCRMapper 
      * @return session
      */
     protected Session getSession() throws RepositoryException{
+        Session session = (Session) mSession.getAttributes().get(JCR_SESSION);
     	if (session == null) {
     		session = repository.login(mSession);
+    		mSession.getAttributes().put(JCR_SESSION, session);
     	}
         return session;
     }
@@ -116,6 +118,8 @@ public abstract class AbstractJCRMapper 
      * Logout from open JCR Session
      */
     public void endRequest() {
+        Session session = (Session) mSession.getAttributes().remove(JCR_SESSION);
+
         if (session != null) {
             if (session.isLive())
                 session.logout();



---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


Mime
View raw message