Author: cziegeler
Date: Thu Dec 13 04:14:50 2007
New Revision: 603901
URL: http://svn.apache.org/viewvc?rev=603901&view=rev
Log:
Add new session pool factory to make the pool configurable.
Added:
incubator/sling/trunk/jcr/api/src/main/java/org/apache/sling/jcr/api/internal/SessionPoolFactory.java
(with props)
Modified:
incubator/sling/trunk/jcr/api/src/main/java/org/apache/sling/jcr/api/AbstractSlingRepository.java
incubator/sling/trunk/jcr/api/src/main/java/org/apache/sling/jcr/api/internal/SessionPool.java
incubator/sling/trunk/jcr/api/src/main/java/org/apache/sling/jcr/api/internal/SessionPoolManager.java
Modified:
incubator/sling/trunk/jcr/api/src/main/java/org/apache/sling/jcr/api/AbstractSlingRepository.java
URL:
http://svn.apache.org/viewvc/incubator/sling/trunk/jcr/api/src/main/java/org/apache/sling/jcr/api/AbstractSlingRepository.java?rev=603901&r1=603900&r2=603901&view=diff
==============================================================================
---
incubator/sling/trunk/jcr/api/src/main/java/org/apache/sling/jcr/api/AbstractSlingRepository.java
(original)
+++
incubator/sling/trunk/jcr/api/src/main/java/org/apache/sling/jcr/api/AbstractSlingRepository.java
Thu Dec 13 04:14:50 2007
@@ -30,6 +30,8 @@
import javax.jcr.Workspace;
import org.apache.jackrabbit.api.JackrabbitWorkspace;
+import org.apache.sling.jcr.api.internal.SessionPool;
+import org.apache.sling.jcr.api.internal.SessionPoolFactory;
import org.apache.sling.jcr.api.internal.SessionPoolManager;
import org.apache.sling.jcr.api.internal.loader.Loader;
import org.osgi.framework.Bundle;
@@ -126,20 +128,36 @@
protected final SessionPoolManager getPoolManager()
throws RepositoryException {
if (this.poolManager == null) {
- @SuppressWarnings("unchecked")
- Dictionary<String, Object> properties =
this.componentContext.getProperties();
- int maxActiveSessions = this.getIntProperty(properties,
- PARAM_MAX_ACTIVE_SESSIONS);
- int maxIdleSessions = this.getIntProperty(properties,
- PARAM_MAX_IDLE_SESSIONS);
- int maxActiveSessionsWait = this.getIntProperty(properties,
- PARAM_MAX_ACTIVE_SESSIONS_WAIT);
-
this.poolManager = new SessionPoolManager(this.getDelegatee(),
this.loader,
- maxActiveSessions, maxActiveSessionsWait, maxIdleSessions);
+ this.getSessionPoolFactory());
}
return this.poolManager;
+ }
+
+ /**
+ * @return
+ */
+ protected SessionPoolFactory getSessionPoolFactory() {
+ @SuppressWarnings("unchecked")
+ Dictionary<String, Object> properties =
this.componentContext.getProperties();
+ final int maxActiveSessions = this.getIntProperty(properties,
+ PARAM_MAX_ACTIVE_SESSIONS);
+ final int maxIdleSessions = this.getIntProperty(properties,
+ PARAM_MAX_IDLE_SESSIONS);
+ final int maxActiveSessionsWait = this.getIntProperty(properties,
+ PARAM_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 = new SessionPool(mgr, credentials);
+ pool.setMaxActiveSessions(maxActiveSessions);
+ pool.setMaxActiveSessionsWait(maxActiveSessionsWait);
+ pool.setMaxIdleSessions(maxIdleSessions);
+ return pool;
+ }
+ };
}
/**
Modified:
incubator/sling/trunk/jcr/api/src/main/java/org/apache/sling/jcr/api/internal/SessionPool.java
URL:
http://svn.apache.org/viewvc/incubator/sling/trunk/jcr/api/src/main/java/org/apache/sling/jcr/api/internal/SessionPool.java?rev=603901&r1=603900&r2=603901&view=diff
==============================================================================
---
incubator/sling/trunk/jcr/api/src/main/java/org/apache/sling/jcr/api/internal/SessionPool.java
(original)
+++
incubator/sling/trunk/jcr/api/src/main/java/org/apache/sling/jcr/api/internal/SessionPool.java
Thu Dec 13 04:14:50 2007
@@ -153,9 +153,8 @@
* Creates a new instance of this class presetting internal counters
* and data structures.
*
- * @param repository The <code>Repository</code> to login to.
*/
- SessionPool(SessionPoolManager poolManager, SimpleCredentials credentials)
{
+ public SessionPool(SessionPoolManager poolManager, SimpleCredentials
credentials) {
this.poolManager = poolManager;
this.userName = credentials.getUserID();
this.passData = this.getPassData(credentials);
Added:
incubator/sling/trunk/jcr/api/src/main/java/org/apache/sling/jcr/api/internal/SessionPoolFactory.java
URL:
http://svn.apache.org/viewvc/incubator/sling/trunk/jcr/api/src/main/java/org/apache/sling/jcr/api/internal/SessionPoolFactory.java?rev=603901&view=auto
==============================================================================
---
incubator/sling/trunk/jcr/api/src/main/java/org/apache/sling/jcr/api/internal/SessionPoolFactory.java
(added)
+++
incubator/sling/trunk/jcr/api/src/main/java/org/apache/sling/jcr/api/internal/SessionPoolFactory.java
Thu Dec 13 04:14:50 2007
@@ -0,0 +1,29 @@
+/*
+ * 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.api.internal;
+
+import javax.jcr.SimpleCredentials;
+
+/**
+ * A session pool factory creates new session pools.
+ */
+public interface SessionPoolFactory {
+
+ SessionPool createPool(SessionPoolManager mgr, SimpleCredentials
credentials);
+}
Propchange:
incubator/sling/trunk/jcr/api/src/main/java/org/apache/sling/jcr/api/internal/SessionPoolFactory.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
incubator/sling/trunk/jcr/api/src/main/java/org/apache/sling/jcr/api/internal/SessionPoolFactory.java
------------------------------------------------------------------------------
svn:keywords = author date id revision url
Modified:
incubator/sling/trunk/jcr/api/src/main/java/org/apache/sling/jcr/api/internal/SessionPoolManager.java
URL:
http://svn.apache.org/viewvc/incubator/sling/trunk/jcr/api/src/main/java/org/apache/sling/jcr/api/internal/SessionPoolManager.java?rev=603901&r1=603900&r2=603901&view=diff
==============================================================================
---
incubator/sling/trunk/jcr/api/src/main/java/org/apache/sling/jcr/api/internal/SessionPoolManager.java
(original)
+++
incubator/sling/trunk/jcr/api/src/main/java/org/apache/sling/jcr/api/internal/SessionPoolManager.java
Thu Dec 13 04:14:50 2007
@@ -50,36 +50,15 @@
private final NamespaceMapper namespaceMapper;
- /**
- * The maximum number of active sessions per session pool, that is per
user.
- */
- private int poolMaxActiveSessions;
-
- /** The maximum number of idle sessions stored in the sessionPool */
- private int poolMaxIdleSessions;
-
- /**
- * The number of seconds to wait for the number of currently active
sessions
- * from this pool to drop below the configured number of maximum active
- * sessions.
- */
- private int poolMaxActiveSessionsWait;
+ private final SessionPoolFactory sessionPoolFactory;
public SessionPoolManager(Repository repository,
NamespaceMapper mapper,
- int maxActiveSessions,
- int maxActiveSessionsWait,
- int maxIdleSessions) {
+ SessionPoolFactory factory) {
this.repository = repository;
this.sessionPools = new HashMap<String, SessionPool>();
-
- // default session pool configuration (actual values will be checked
- // for validity by the SessionPool instances themselves when
- // configuring)
- this.poolMaxActiveSessions = maxActiveSessions;
- this.poolMaxActiveSessionsWait = maxActiveSessionsWait;
- this.poolMaxIdleSessions = maxIdleSessions;
+ this.sessionPoolFactory = factory;
this.namespaceMapper = mapper;
}
@@ -164,11 +143,7 @@
String userName = credentials.getUserID();
SessionPool pool = this.sessionPools.get(userName);
if (pool == null) {
- // create and configure the new pool
- pool = new SessionPool(this, credentials);
- pool.setMaxActiveSessions(this.poolMaxActiveSessions);
- pool.setMaxActiveSessionsWait(this.poolMaxActiveSessionsWait);
- pool.setMaxIdleSessions(this.poolMaxIdleSessions);
+ pool = this.sessionPoolFactory.createPool(this, credentials);
this.sessionPools.put(userName, pool);
}