]> git.argeo.org Git - lgpl/argeo-commons.git/blobdiff - server/runtime/org.argeo.server.jcr/src/main/java/org/argeo/jcr/ThreadBoundJcrSessionFactory.java
Last modified support
[lgpl/argeo-commons.git] / server / runtime / org.argeo.server.jcr / src / main / java / org / argeo / jcr / ThreadBoundJcrSessionFactory.java
index 1c33a43dec9a6788831fa92a2e8b83326645438c..4e9e0a759d51f7e1b44110f3cc6e2acbdbe7a9a0 100644 (file)
@@ -35,13 +35,9 @@ import javax.jcr.SimpleCredentials;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.argeo.ArgeoException;
-import org.springframework.beans.factory.DisposableBean;
-import org.springframework.beans.factory.FactoryBean;
-import org.springframework.beans.factory.InitializingBean;
 
 /** Proxy JCR sessions and attach them to calling threads. */
-public class ThreadBoundJcrSessionFactory implements FactoryBean,
-               InitializingBean, DisposableBean {
+public abstract class ThreadBoundJcrSessionFactory {
        private final static Log log = LogFactory
                        .getLog(ThreadBoundJcrSessionFactory.class);
 
@@ -73,7 +69,7 @@ public class ThreadBoundJcrSessionFactory implements FactoryBean,
        }
 
        /** Logs in to the repository using various strategies. */
-       protected Session login() {
+       protected synchronized Session login() {
                if (!isActive())
                        throw new ArgeoException("Thread bound session factory inactive");
 
@@ -126,12 +122,12 @@ public class ThreadBoundJcrSessionFactory implements FactoryBean,
                return proxiedSession;
        }
 
-       public void afterPropertiesSet() throws Exception {
+       public void init() throws Exception {
                monitoringThread = new MonitoringThread();
                monitoringThread.start();
        }
 
-       public synchronized void destroy() throws Exception {
+       public synchronized void dispose() throws Exception {
                if (activeSessions.size() == 0)
                        return;
 
@@ -256,6 +252,10 @@ public class ThreadBoundJcrSessionFactory implements FactoryBean,
        /** Monitors registered thread in order to clean up dead ones. */
        private class MonitoringThread extends Thread {
 
+               public MonitoringThread() {
+                       super("ThreadBound JCR Session Monitor");
+               }
+
                @Override
                public void run() {
                        while (isActive()) {