Author: fmeschbe Date: Sat Jan 3 12:00:04 2009 New Revision: 731076 URL: http://svn.apache.org/viewvc?rev=731076&view=rev Log: SLING-802 Provide support for the new JackrabbitSession through the session pool.
Added: incubator/sling/trunk/jcr/base/src/main/java/org/apache/sling/jcr/base/internal/PooledJackrabbitSession.java (with props) Modified: incubator/sling/trunk/jcr/base/src/main/java/org/apache/sling/jcr/base/internal/PooledSession.java incubator/sling/trunk/jcr/base/src/main/java/org/apache/sling/jcr/base/internal/SessionPool.java Added: incubator/sling/trunk/jcr/base/src/main/java/org/apache/sling/jcr/base/internal/PooledJackrabbitSession.java URL: http://svn.apache.org/viewvc/incubator/sling/trunk/jcr/base/src/main/java/org/apache/sling/jcr/base/internal/PooledJackrabbitSession.java?rev=731076&view=auto ============================================================================== --- incubator/sling/trunk/jcr/base/src/main/java/org/apache/sling/jcr/base/internal/PooledJackrabbitSession.java (added) +++ incubator/sling/trunk/jcr/base/src/main/java/org/apache/sling/jcr/base/internal/PooledJackrabbitSession.java Sat Jan 3 12:00:04 2009 @@ -0,0 +1,59 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.sling.jcr.base.internal; + +import javax.jcr.AccessDeniedException; +import javax.jcr.RepositoryException; +import javax.jcr.UnsupportedRepositoryOperationException; + +import org.apache.jackrabbit.api.JackrabbitSession; +import org.apache.jackrabbit.api.security.principal.PrincipalManager; +import org.apache.jackrabbit.api.security.user.UserManager; + +/** + * The <code>PooledJackrabbitSession</code> class implements the Jackrabbit 1.5 + * <code>JackrabbitSession</code> interface as a wrapper to a delegatee session. + * Methods are just delegated to the delegatee session. + */ +public class PooledJackrabbitSession extends PooledSession implements + JackrabbitSession { + + public PooledJackrabbitSession(SessionPool sessionPool, + JackrabbitSession delegatee) { + super(sessionPool, delegatee); + } + + /** + * Returns the <code>PrincipalManager</code> of the underlying Jackrabbit + * Session. + */ + public PrincipalManager getPrincipalManager() throws AccessDeniedException, + UnsupportedRepositoryOperationException, RepositoryException { + return ((JackrabbitSession) getSession()).getPrincipalManager(); + } + + /** + * Returns the <code>UserManager</code> of the underlying Jackrabbit + * Session. + */ + public UserManager getUserManager() throws AccessDeniedException, + UnsupportedRepositoryOperationException, RepositoryException { + return ((JackrabbitSession) getSession()).getUserManager(); + } +} Propchange: incubator/sling/trunk/jcr/base/src/main/java/org/apache/sling/jcr/base/internal/PooledJackrabbitSession.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: incubator/sling/trunk/jcr/base/src/main/java/org/apache/sling/jcr/base/internal/PooledJackrabbitSession.java ------------------------------------------------------------------------------ svn:keywords = Author Date Id Revision Rev Url Modified: incubator/sling/trunk/jcr/base/src/main/java/org/apache/sling/jcr/base/internal/PooledSession.java URL: http://svn.apache.org/viewvc/incubator/sling/trunk/jcr/base/src/main/java/org/apache/sling/jcr/base/internal/PooledSession.java?rev=731076&r1=731075&r2=731076&view=diff ============================================================================== --- incubator/sling/trunk/jcr/base/src/main/java/org/apache/sling/jcr/base/internal/PooledSession.java (original) +++ incubator/sling/trunk/jcr/base/src/main/java/org/apache/sling/jcr/base/internal/PooledSession.java Sat Jan 3 12:00:04 2009 @@ -49,12 +49,13 @@ import org.xml.sax.SAXException; /** - * The <code>PooledSession</code> class implements the <code>javax.jcr.Session</code> - * interface as a wrapper to a delegatee session. The only method overwritten - * by this implementation is the {...@link #logout()} which does not actually - * logout the delegatee but releases this session to the session pool to which - * this session is attached and {...@link #impersonate(Credentials)} which also - * tries to return a pooled session for the impersonated user. + * The <code>PooledSession</code> class implements the + * <code>javax.jcr.Session</code> interface as a wrapper to a delegatee session. + * The only method overwritten by this implementation is the {...@link #logout()} + * which does not actually logout the delegatee but releases this session to the + * session pool to which this session is attached and + * {...@link #impersonate(Credentials)} which also tries to return a pooled session + * for the impersonated user. */ public class PooledSession implements Session { @@ -93,7 +94,7 @@ * Returns the delegatee session to which all calls except {...@link #logout()} * and {...@link #impersonate(Credentials)} are delegated. */ - protected Session getSession() { + public Session getSession() { return this.delegatee; } Modified: incubator/sling/trunk/jcr/base/src/main/java/org/apache/sling/jcr/base/internal/SessionPool.java URL: http://svn.apache.org/viewvc/incubator/sling/trunk/jcr/base/src/main/java/org/apache/sling/jcr/base/internal/SessionPool.java?rev=731076&r1=731075&r2=731076&view=diff ============================================================================== --- incubator/sling/trunk/jcr/base/src/main/java/org/apache/sling/jcr/base/internal/SessionPool.java (original) +++ incubator/sling/trunk/jcr/base/src/main/java/org/apache/sling/jcr/base/internal/SessionPool.java Sat Jan 3 12:00:04 2009 @@ -38,6 +38,7 @@ import javax.jcr.query.Query; import javax.jcr.query.QueryManager; +import org.apache.jackrabbit.api.JackrabbitSession; import org.apache.sling.jcr.api.TooManySessionsException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -699,8 +700,15 @@ * @param delegatee The <code>Session</code> to wrap as a pooled session. * @see PooledSession */ - protected PooledSession createPooledSession(Session delegatee) throws RepositoryException { - PooledSession pooledSession = new PooledSession(this, delegatee); + protected PooledSession createPooledSession(Session delegatee) + throws RepositoryException { + PooledSession pooledSession; + if (delegatee instanceof JackrabbitSession) { + pooledSession = new PooledJackrabbitSession(this, + (JackrabbitSession) delegatee); + } else { + pooledSession = new PooledSession(this, delegatee); + } // keep the pooled session synchronized (this.activeSessions) {