]> git.argeo.org Git - lgpl/argeo-commons.git/blobdiff - org.argeo.cms/src/org/argeo/cms/internal/kernel/KernelThread.java
Prepare JCR decoupling.
[lgpl/argeo-commons.git] / org.argeo.cms / src / org / argeo / cms / internal / kernel / KernelThread.java
index 228737b9d42721b64c5b56a7cb52d891f078303b..a0f9c5b71d895b7357a4458bd9611c7d0a8d4185 100644 (file)
@@ -7,15 +7,15 @@ import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.jackrabbit.api.stats.RepositoryStatistics;
 import org.apache.jackrabbit.stats.RepositoryStatisticsImpl;
-import org.argeo.cms.CmsException;
+import org.argeo.cms.internal.auth.CmsSessionImpl;
 
 /**
- * Background thread started by the {@link Kernel}, which gather statistics and
+ * Background thread started by the kernel, which gather statistics and
  * monitor/control other processes.
  */
 class KernelThread extends Thread {
-       @SuppressWarnings("unused")
-       private final Kernel kernel;
+       private final static Log log = LogFactory.getLog(KernelThread.class);
+
        private RepositoryStatisticsImpl repoStats;
 
        /** The smallest period of operation, in ms */
@@ -32,13 +32,14 @@ class KernelThread extends Thread {
        @SuppressWarnings("unused")
        private long cycle = 0l;
 
-       public KernelThread(Kernel kernel) {
-               super(kernel.threadGroup, kernel.getClass().getSimpleName());
-               this.kernel = kernel;
-               // this.repoStats = kernel.repository.getRepositoryStatistics();
+       public KernelThread(ThreadGroup threadGroup, String name) {
+               super(threadGroup, name);
        }
 
        private void doSmallestPeriod() {
+               // Clean expired sessions
+               CmsSessionImpl.closeInvalidSessions();
+
                if (kernelStatsLog.isDebugEnabled()) {
                        StringBuilder line = new StringBuilder(64);
                        line.append("ยง\t");
@@ -89,6 +90,8 @@ class KernelThread extends Thread {
 
        @Override
        public void run() {
+               if (log.isTraceEnabled())
+                       log.trace("Kernel thread started.");
                final long periodNs = PERIOD * m;
                while (running) {
                        long beginNs = System.nanoTime();
@@ -110,11 +113,12 @@ class KernelThread extends Thread {
        synchronized void destroyAndJoin() {
                running = false;
                notifyAll();
-               interrupt();
-               try {
-                       join(PERIOD * 2);
-               } catch (InterruptedException e) {
-                       throw new CmsException("Kernel thread destruction was interrupted");
-               }
+//             interrupt();
+//             try {
+//                     join(PERIOD * 2);
+//             } catch (InterruptedException e) {
+//                     // throw new CmsException("Kernel thread destruction was interrupted");
+//                     log.error("Kernel thread destruction was interrupted", e);
+//             }
        }
 }