Author: fmeschbe
Date: Tue Dec  1 09:59:01 2009
New Revision: 885708

URL: http://svn.apache.org/viewvc?rev=885708&view=rev
Log:
SLING-1212 Use JCR 2.0 and upgraded to Jackrabbit API 2.0-beta3. Also remove 
the obsolete session pool functionality

Removed:
    
sling/whiteboard/fmeschbe/jackrabbit2upgrade/bundles/jcr/base/src/main/java/org/apache/sling/jcr/base/internal/PooledJackrabbitSession.java
    
sling/whiteboard/fmeschbe/jackrabbit2upgrade/bundles/jcr/base/src/main/java/org/apache/sling/jcr/base/internal/PooledSession.java
    
sling/whiteboard/fmeschbe/jackrabbit2upgrade/bundles/jcr/base/src/main/java/org/apache/sling/jcr/base/internal/SessionPool.java
    
sling/whiteboard/fmeschbe/jackrabbit2upgrade/bundles/jcr/base/src/main/java/org/apache/sling/jcr/base/internal/SessionPoolFactory.java
    
sling/whiteboard/fmeschbe/jackrabbit2upgrade/bundles/jcr/base/src/main/java/org/apache/sling/jcr/base/internal/SessionPoolManager.java
Modified:
    sling/whiteboard/fmeschbe/jackrabbit2upgrade/bundles/jcr/base/pom.xml
    
sling/whiteboard/fmeschbe/jackrabbit2upgrade/bundles/jcr/base/src/main/java/org/apache/sling/jcr/base/AbstractSlingRepository.java
    
sling/whiteboard/fmeschbe/jackrabbit2upgrade/bundles/jcr/base/src/main/java/org/apache/sling/jcr/base/util/AccessControlUtil.java

Modified: sling/whiteboard/fmeschbe/jackrabbit2upgrade/bundles/jcr/base/pom.xml
URL: 
http://svn.apache.org/viewvc/sling/whiteboard/fmeschbe/jackrabbit2upgrade/bundles/jcr/base/pom.xml?rev=885708&r1=885707&r2=885708&view=diff
==============================================================================
--- sling/whiteboard/fmeschbe/jackrabbit2upgrade/bundles/jcr/base/pom.xml 
(original)
+++ sling/whiteboard/fmeschbe/jackrabbit2upgrade/bundles/jcr/base/pom.xml Tue 
Dec  1 09:59:01 2009
@@ -93,9 +93,10 @@
             <version>2.0.2-incubator</version>
         </dependency>
         <dependency>
-            <groupId>org.apache.jackrabbit</groupId>
-            <artifactId>jackrabbit-api</artifactId>
-            <version>1.5.0</version>
+            <groupId>javax.jcr</groupId>
+            <artifactId>jcr</artifactId>
+            <version>2.0</version>
+            <scope>provided</scope>
         </dependency>
         <dependency>
             <groupId>org.apache.jackrabbit</groupId>
@@ -103,6 +104,11 @@
             <version>1.5.0</version>
             <scope>provided</scope>
         </dependency>
+        <dependency>
+            <groupId>org.apache.jackrabbit</groupId>
+            <artifactId>jackrabbit-api</artifactId>
+            <version>2.0-beta3</version>
+        </dependency>
         <!-- OSGi Libraries -->
         <dependency>
             <groupId>org.osgi</groupId>

Modified: 
sling/whiteboard/fmeschbe/jackrabbit2upgrade/bundles/jcr/base/src/main/java/org/apache/sling/jcr/base/AbstractSlingRepository.java
URL: 
http://svn.apache.org/viewvc/sling/whiteboard/fmeschbe/jackrabbit2upgrade/bundles/jcr/base/src/main/java/org/apache/sling/jcr/base/AbstractSlingRepository.java?rev=885708&r1=885707&r2=885708&view=diff
==============================================================================
--- 
sling/whiteboard/fmeschbe/jackrabbit2upgrade/bundles/jcr/base/src/main/java/org/apache/sling/jcr/base/AbstractSlingRepository.java
 (original)
+++ 
sling/whiteboard/fmeschbe/jackrabbit2upgrade/bundles/jcr/base/src/main/java/org/apache/sling/jcr/base/AbstractSlingRepository.java
 Tue Dec  1 09:59:01 2009
@@ -31,9 +31,6 @@
 
 import org.apache.jackrabbit.api.JackrabbitWorkspace;
 import org.apache.sling.jcr.api.SlingRepository;
-import org.apache.sling.jcr.base.internal.SessionPool;
-import org.apache.sling.jcr.base.internal.SessionPoolFactory;
-import org.apache.sling.jcr.base.internal.SessionPoolManager;
 import org.apache.sling.jcr.base.internal.loader.Loader;
 import org.apache.sling.jcr.base.util.RepositoryAccessor;
 import org.osgi.framework.BundleContext;
@@ -79,31 +76,6 @@
     /** @scr.property valueRef="DEFAULT_POLL_INACTIVE" */
     public static final String PROPERTY_POLL_INACTIVE = "poll.inactive";
 
-    /**
-     * The name of the configuration parameter containing the maximum number of
-     * seconds to wait for the number of currently active sessions to drop be
-     * low the upper limit before giving up (value is "pool.maxActiveWait").
-     *
-     * @scr.property value="1" type="Integer"
-     */
-    public static final String PROPERTY_MAX_ACTIVE_SESSIONS_WAIT = 
"pool.maxActiveWait";
-
-    /**
-     * The name of the configuration parameter containing the upper limit of 
the
-     * simultaneously active sessions (value is "pool.maxActive").
-     *
-     * @scr.property value="-1" type="Integer"
-     */
-    public static final String PROPERTY_MAX_ACTIVE_SESSIONS = "pool.maxActive";
-
-    /**
-     * The name of the configuration parameter containing the upper limit of 
the
-     * currently idle sessions to keep in the pool (value is "pool.maxIdle").
-     *
-     * @scr.property value="0" type="Integer"
-     */
-    public static final String PROPERTY_MAX_IDLE_SESSIONS = "pool.maxIdle";
-
     public static final String DEFAULT_ANONYMOUS_USER = "anonymous";
 
     public static final String DEFAULT_ANONYMOUS_PASS = "anonymous";
@@ -146,8 +118,6 @@
 
     private char[] adminPass;
 
-    private SessionPoolManager poolManager;
-
     private Loader loader;
 
     // the poll interval used while the repository is not active
@@ -237,7 +207,7 @@
         try {
             log(LogService.LOG_DEBUG, "login: Logging in to workspace '"
                 + workspace + "'");
-            Session session = getPoolManager().login(credentials, workspace);
+            Session session = getRepository().login(credentials, workspace);
 
             // if the defualt workspace is null, acquire a session from the 
pool
             // and use the workspace used as the new default workspace
@@ -256,13 +226,13 @@
             if (workspace != null
                 && workspace.equals(this.getDefaultWorkspace())
                 && this.createWorkspace(workspace)) {
-                return this.getPoolManager().login(credentials, workspace);
+                return this.getRepository().login(credentials, workspace);
             }
 
             // otherwise (any workspace) or if workspace creation fails
             // just forward the original exception
             throw nswe;
-            
+
         } catch (RuntimeException re) {
             // SLING-702: Jackrabbit throws IllegalStateException if the
             // repository has already been shut down ...
@@ -300,49 +270,6 @@
         return new String[0];
     }
 
-    // ---------- Session Pool support 
-----------------------------------------
-
-    protected final SessionPoolManager getPoolManager() {
-        if (this.poolManager == null) {
-            this.poolManager = new SessionPoolManager(this.getRepository(),
-                this.loader, this.getSessionPoolFactory());
-        }
-
-        return this.poolManager;
-    }
-
-    /**
-     * @return
-     */
-    protected SessionPoolFactory getSessionPoolFactory() {
-        @SuppressWarnings("unchecked")
-        Dictionary<String, Object> properties = 
this.componentContext.getProperties();
-        final int maxActiveSessions = this.getIntProperty(properties,
-            PROPERTY_MAX_ACTIVE_SESSIONS);
-        final int maxIdleSessions = this.getIntProperty(properties,
-            PROPERTY_MAX_IDLE_SESSIONS);
-        final int maxActiveSessionsWait = this.getIntProperty(properties,
-            PROPERTY_MAX_ACTIVE_SESSIONS_WAIT);
-        return new SessionPoolFactory() {
-
-            public SessionPool createPool(final SessionPoolManager mgr,
-                    final SimpleCredentials credentials) {
-                // create and configure the new pool
-                final SessionPool pool = createSessionPool(mgr, credentials);
-                pool.setMaxActiveSessions(maxActiveSessions);
-                pool.setMaxActiveSessionsWait(maxActiveSessionsWait);
-                pool.setMaxIdleSessions(maxIdleSessions);
-                return pool;
-            }
-        };
-    }
-
-    protected SessionPool createSessionPool(final SessionPoolManager mgr,
-            final SimpleCredentials credentials) {
-        final SessionPool pool = new SessionPool(mgr, credentials);
-        return pool;
-    }
-
     // ---------- logging 
------------------------------------------------------
 
     protected void log(int level, String message) {
@@ -537,11 +464,6 @@
      */
     protected void tearDown(Repository repository) {
 
-        if (this.poolManager != null) {
-            this.poolManager.dispose();
-            this.poolManager = null;
-        }
-
         if (this.loader != null) {
             this.loader.dispose();
             this.loader = null;
@@ -833,10 +755,10 @@
                     log(
                         LogService.LOG_DEBUG,
                         "pingRepository() successful but pingAndCheck() fails, 
calling disposeRepository()");
-                    
+
                     // drop reference
                     repository = null;
-                    
+
                 } else {
 
                     // otherwise let go of the repository and fail startup
@@ -933,7 +855,7 @@
                     if (repo == null) {
                         // No Repository yet, try to start
                         if (startRepository()) {
-                            log(LogService.LOG_INFO, "Repository started 
successfully"); 
+                            log(LogService.LOG_INFO, "Repository started 
successfully");
                             ok = true;
                             newPollTime = pollTimeActiveSeconds * MSEC;
                         } else {
@@ -944,7 +866,7 @@
                     } else if (pingAndCheck()) {
                         ok = true;
                         newPollTime = pollTimeActiveSeconds * MSEC;
-                        
+
                     } else {
                         // Repository disappeared
                         log(LogService.LOG_INFO,
@@ -952,10 +874,10 @@
                         stopRepository();
                         newPollTime = pollTimeInActiveSeconds * MSEC;
                     }
-                    
+
                     if(newPollTime != pollTimeMsec) {
                         pollTimeMsec = newPollTime;
-                        log(LogService.LOG_DEBUG, 
+                        log(LogService.LOG_DEBUG,
                                 "Repository Pinger interval set to " + 
pollTimeMsec + " msec, repository is "
                                 + (ok ? "available" : "NOT available")
                                 );
@@ -969,9 +891,9 @@
         } catch (Throwable t) {
             // try to log the cause for thread termination
             log(LogService.LOG_ERROR, "Repository Pinger caught unexpected 
issue", t);
-            
+
         } finally {
-            
+
             // whatever goes on, make sure the repository is disposed of
             // at the end of the thread....
             log(LogService.LOG_INFO, "Stopping repository on shutdown");

Modified: 
sling/whiteboard/fmeschbe/jackrabbit2upgrade/bundles/jcr/base/src/main/java/org/apache/sling/jcr/base/util/AccessControlUtil.java
URL: 
http://svn.apache.org/viewvc/sling/whiteboard/fmeschbe/jackrabbit2upgrade/bundles/jcr/base/src/main/java/org/apache/sling/jcr/base/util/AccessControlUtil.java?rev=885708&r1=885707&r2=885708&view=diff
==============================================================================
--- 
sling/whiteboard/fmeschbe/jackrabbit2upgrade/bundles/jcr/base/src/main/java/org/apache/sling/jcr/base/util/AccessControlUtil.java
 (original)
+++ 
sling/whiteboard/fmeschbe/jackrabbit2upgrade/bundles/jcr/base/src/main/java/org/apache/sling/jcr/base/util/AccessControlUtil.java
 Tue Dec  1 09:59:01 2009
@@ -27,23 +27,22 @@
 import javax.jcr.RepositoryException;
 import javax.jcr.Session;
 import javax.jcr.UnsupportedRepositoryOperationException;
+import javax.jcr.security.AccessControlEntry;
+import javax.jcr.security.AccessControlException;
+import javax.jcr.security.AccessControlList;
+import javax.jcr.security.AccessControlManager;
+import javax.jcr.security.Privilege;
 
 import org.apache.jackrabbit.api.JackrabbitSession;
-import org.apache.jackrabbit.api.jsr283.security.AccessControlEntry;
-import org.apache.jackrabbit.api.jsr283.security.AccessControlException;
-import org.apache.jackrabbit.api.jsr283.security.AccessControlList;
-import org.apache.jackrabbit.api.jsr283.security.AccessControlManager;
-import org.apache.jackrabbit.api.jsr283.security.Privilege;
 import org.apache.jackrabbit.api.security.principal.PrincipalManager;
 import org.apache.jackrabbit.api.security.user.UserManager;
-import org.apache.sling.jcr.base.internal.PooledSession;
 
 /**
- * A simple utility class providing utilities with respect to 
+ * A simple utility class providing utilities with respect to
  * access control over repositories.
  */
 public class AccessControlUtil {
-       
+
        // the name of the accessor method for the AccessControlManager
     private static final String METHOD_GET_ACCESS_CONTROL_MANAGER = 
"getAccessControlManager";
     // the name of the accessor method for the UserManager
@@ -52,19 +51,19 @@
     private static final String METHOD_GET_PRINCIPAL_MANAGER = 
"getPrincipalManager";
     // the name of the JackrabbitAccessControlList method getPath
     private static final String METHOD_JACKRABBIT_ACL_GET_PATH = "getPath";
-    // the name of the JackrabbitAccessControlList method 
+    // the name of the JackrabbitAccessControlList method
     private static final String METHOD_JACKRABBIT_ACL_IS_EMPTY = "isEmpty";
-    // the name of the JackrabbitAccessControlList method 
+    // the name of the JackrabbitAccessControlList method
     private static final String METHOD_JACKRABBIT_ACL_SIZE = "size";
-    // the name of the JackrabbitAccessControlList method 
+    // the name of the JackrabbitAccessControlList method
     private static final String METHOD_JACKRABBIT_ACL_ADD_ENTRY = "addEntry";
-    // the name of the JackrabbitAccessControlEntry method 
+    // the name of the JackrabbitAccessControlEntry method
     private static final String METHOD_JACKRABBIT_ACE_IS_ALLOW = "isAllow";
 
 
-       
+
     // ---------- SessionImpl methods 
-----------------------------------------------------
-    
+
        /**
      * Returns the <code>AccessControlManager</code> for the given
      * <code>session</code>. If the session does not have a
@@ -72,7 +71,7 @@
      * <code>UnsupportedRepositoryOperationException</code> is thrown. 
Otherwise
      * the <code>AccessControlManager</code> is returned or if the call fails,
      * the respective exception is thrown.
-     * 
+     *
      * @param session The JCR Session whose <code>AccessControlManager</code> 
is
      *            to be returned. If the session is a pooled session, the
      *            session underlying the pooled session is actually used.
@@ -85,16 +84,11 @@
      */
        public static AccessControlManager getAccessControlManager(Session 
session)
                                                                                
        throws UnsupportedRepositoryOperationException, RepositoryException {
-                // unwrap a pooled session
-        if (session instanceof PooledSession) {
-            session = ((PooledSession) session).getSession();
-        }
-        
         return safeInvokeRepoMethod(session, 
METHOD_GET_ACCESS_CONTROL_MANAGER, AccessControlManager.class);
        }
-       
+
        // ---------- JackrabbitSession methods 
-----------------------------------------------
-       
+
        /**
         * Returns the <code>UserManager</code> for the given
      * <code>session</code>. If the session does not have a
@@ -102,12 +96,12 @@
      * <code>UnsupportedRepositoryOperationException</code> is thrown. 
Otherwise
      * the <code>UserManager</code> is returned or if the call fails,
      * the respective exception is thrown.
-        * 
+        *
         * @param session  The JCR Session whose <code>UserManager</code> is
      *            to be returned. If the session is not a 
<code>JackrabbitSession</code>
      *            uses reflection to retrive the manager from the repository.
         * @return The <code>UserManager</code> of the session.
-        * @throws AccessDeniedException If this session is not allowed 
+        * @throws AccessDeniedException If this session is not allowed
         *                        to access user data.
         * @throws UnsupportedRepositoryOperationException If the session has no
      *            <code>getUserManager</code> method or the exception
@@ -115,7 +109,7 @@
         * @throws RepositoryException Forwarded from the
      *             <code>getUserManager</code> method call.
         */
-       public static UserManager getUserManager(Session session) 
+       public static UserManager getUserManager(Session session)
                                                                                
throws AccessDeniedException, UnsupportedRepositoryOperationException, 
RepositoryException {
                JackrabbitSession jackrabbitSession = 
getJackrabbitSession(session);
                if(jackrabbitSession != null) {
@@ -124,7 +118,7 @@
                        return safeInvokeRepoMethod(session, 
METHOD_GET_USER_MANAGER, UserManager.class);
                }
        }
-       
+
        /**
         * Returns the <code>PrincipalManager</code> for the given
      * <code>session</code>. If the session does not have a
@@ -132,13 +126,13 @@
      * <code>UnsupportedRepositoryOperationException</code> is thrown. 
Otherwise
      * the <code>PrincipalManager</code> is returned or if the call fails,
      * the respective exception is thrown.
-        * 
+        *
         * @param session  The JCR Session whose <code>PrincipalManager</code> 
is
      *            to be returned. If the session is not a 
<code>JackrabbitSession</code>
      *            uses reflection to retrive the manager from the repository.
         * @return The <code>PrincipalManager</code> of the session.
         * @throws AccessDeniedException
-        * @throws UnsupportedRepositoryOperationException If the session has 
no 
+        * @throws UnsupportedRepositoryOperationException If the session has no
         *                              <code>PrincipalManager</code> method or 
the exception
      *                 thrown by the method.
         * @throws RepositoryException Forwarded from the
@@ -153,9 +147,9 @@
                        return safeInvokeRepoMethod(session, 
METHOD_GET_PRINCIPAL_MANAGER, PrincipalManager.class);
                }
        }
-       
+
        // ---------- AccessControlList methods 
-----------------------------------------------
-       
+
        /**
         * Returns the path of the node <code>AccessControlList</code> acl
         * has been created for.
@@ -163,7 +157,7 @@
        public static String getPath(AccessControlList acl) throws 
RepositoryException {
                        return safeInvokeRepoMethod(acl, 
METHOD_JACKRABBIT_ACL_GET_PATH, String.class);
        }
-       
+
        /**
         * Returns <code>true</code> if <code>AccessControlList</code> acl
         * does not yet define any entries.
@@ -171,14 +165,14 @@
     public static boolean isEmpty(AccessControlList acl) throws 
RepositoryException {
                return safeInvokeRepoMethod(acl, 
METHOD_JACKRABBIT_ACL_IS_EMPTY, Boolean.class);
     }
-    
+
     /**
      * Returns the number of acl entries or 0 if the acl is empty.
      */
     public static int size(AccessControlList acl) throws RepositoryException {
                return safeInvokeRepoMethod(acl, METHOD_JACKRABBIT_ACL_SIZE, 
Integer.class);
     }
-    
+
     /**
      * Same as {...@link #addEntry(AccessControlList, Principal, Privilege[], 
boolean, Map)} using
      * some implementation specific restrictions.
@@ -190,7 +184,7 @@
        Class[] types = new Class[] {Principal.class, Privilege[].class, 
boolean.class};
                return safeInvokeRepoMethod(acl, 
METHOD_JACKRABBIT_ACL_ADD_ENTRY, Boolean.class, args, types);
     }
-    
+
     /**
      * Adds an access control entry to the acl consisting of the specified
      * <code>principal</code>, the specified <code>privileges</code>, the
@@ -207,24 +201,24 @@
        Class[] types = new Class[] {Principal.class, Privilege[].class, 
boolean.class, Map.class};
                return safeInvokeRepoMethod(acl, 
METHOD_JACKRABBIT_ACL_ADD_ENTRY, Boolean.class, args, types);
     }
-    
+
     // ---------- AccessControlEntry methods 
-----------------------------------------------
-    
+
     /**
-     * Returns true if the AccessControlEntry represents 'allowed' rights or 
false 
+     * Returns true if the AccessControlEntry represents 'allowed' rights or 
false
      * it it represents 'denied' rights.
      */
     public static boolean isAllow(AccessControlEntry ace) throws 
RepositoryException {
                return safeInvokeRepoMethod(ace, 
METHOD_JACKRABBIT_ACE_IS_ALLOW, Boolean.class);
     }
-    
+
     // ---------- internal 
-----------------------------------------------------
-    
+
     /**
      * Use reflection to invoke a repository method.
      */
     @SuppressWarnings("unchecked")
-       private static <T> T safeInvokeRepoMethod(Object target, String 
methodName, Class<T> returnType, Object[] args, Class[] argsTypes) 
+       private static <T> T safeInvokeRepoMethod(Object target, String 
methodName, Class<T> returnType, Object[] args, Class[] argsTypes)
                                                                                
                        throws UnsupportedRepositoryOperationException, 
RepositoryException {
        try {
                Method m = target.getClass().getMethod(methodName, argsTypes);
@@ -255,19 +249,19 @@
             throw new RepositoryException(methodName, t);
         }
        }
-    
-    private static <T> T safeInvokeRepoMethod(Object target, String 
methodName, Class<T> returnType, Object... args) 
+
+    private static <T> T safeInvokeRepoMethod(Object target, String 
methodName, Class<T> returnType, Object... args)
                                                                                
                                                                throws 
UnsupportedRepositoryOperationException, RepositoryException {
        return safeInvokeRepoMethod(target, methodName, returnType, args, new 
Class[0]);
     }
-    
+
     /**
      * Unwrap the jackrabbit session.
      */
        private static JackrabbitSession getJackrabbitSession(Session session) {
                if (session instanceof JackrabbitSession)
                        return (JackrabbitSession) session;
-               else 
+               else
                        return null;
        }
 }


Reply via email to