Janitor thread per instance unstable github/unstable
authorMathieu Baudier <mbaudier@argeo.org>
Wed, 8 May 2024 07:00:57 +0000 (09:00 +0200)
committerMathieu Baudier <mbaudier@argeo.org>
Wed, 8 May 2024 07:00:57 +0000 (09:00 +0200)
org.argeo.app.core/src/org/argeo/app/core/SuiteContentNamespace.java
sdk/branches/unstable.bnd
swt/org.argeo.app.swt/src/org/argeo/app/swt/ux/SwtArgeoApp.java

index 46456493b115a81f682a14bb2b3d17e27c42b568..be4238f6fa77b2f8128c7d83c20defab5075e239 100644 (file)
@@ -1,21 +1,16 @@
 package org.argeo.app.core;
 
-import static java.lang.System.Logger.Level.ERROR;
-
 import java.net.MalformedURLException;
-import java.net.URI;
 import java.net.URL;
 import java.util.Objects;
 
 import org.argeo.api.acr.spi.ContentNamespace;
-import org.argeo.cms.acr.CmsContentNamespace;
 
 public enum SuiteContentNamespace implements ContentNamespace {
        //
        // ARGEO
        //
-       ENTITY("entity", "http://www.argeo.org/ns/entity",
-                       "platform:/plugin/org.argeo.app.api/org/argeo/api/app/entity.xsd", null),
+       ENTITY("entity", "http://www.argeo.org/ns/entity", "/org/argeo/app/api/entity.xsd", null),
        //
        ARGEO_DBK("argeodbk", "http://www.argeo.org/ns/argeodbk", null, null),
        //
@@ -70,22 +65,28 @@ public enum SuiteContentNamespace implements ContentNamespace {
                Objects.requireNonNull(namespace);
                this.namespace = namespace;
                if (resourceFileName != null) {
-                       try {
-                               // FIXME workaround when in nested OSGi frameworks
-                               // we should use class path, as before
-                               if (!resourceFileName.startsWith("platform:")) {
-                                       resource = URI.create("platform:/plugin/org.argeo.app.core" + RESOURCE_BASE + resourceFileName)
-                                                       .toURL();
-                               } else {
-                                       resource = URI.create(resourceFileName).toURL();
-                               }
-                       } catch (MalformedURLException e) {
-                               resource = null;
-                               System.getLogger(CmsContentNamespace.class.getName()).log(ERROR,
-                                               "Cannot load " + resourceFileName + ": " + e.getMessage());
-                               // throw new IllegalArgumentException("Cannot convert " + resourceFileName + "
-                               // to URL");
-                       }
+                       if (!resourceFileName.startsWith("/"))
+                               resource = getClass().getResource(RESOURCE_BASE + resourceFileName);
+                       else
+                               resource = getClass().getResource(resourceFileName);
+//                     Objects.requireNonNull(resource);
+
+//                     try {
+//                             // FIXME workaround when in nested OSGi frameworks
+//                             // we should use class path, as before
+//                             if (!resourceFileName.startsWith("platform:")) {
+//                                     resource = URI.create("platform:/plugin/org.argeo.app.core" + RESOURCE_BASE + resourceFileName)
+//                                                     .toURL();
+//                             } else {
+//                                     resource = URI.create(resourceFileName).toURL();
+//                             }
+//                     } catch (MalformedURLException e) {
+//                             resource = null;
+//                             System.getLogger(CmsContentNamespace.class.getName()).log(ERROR,
+//                                             "Cannot load " + resourceFileName + ": " + e.getMessage());
+//                             // throw new IllegalArgumentException("Cannot convert " + resourceFileName + "
+//                             // to URL");
+//                     }
                        // Objects.requireNonNull(resource);
                }
                if (publicUrl != null)
index 060ef943bec53241190ebd77e23d720010c803fc..283899657cbeeabec66eaa0a565f1362b48d10ba 100644 (file)
@@ -1,7 +1,7 @@
 major=2
 minor=3
 micro=24
-qualifier=
+qualifier=.next
 
 Bundle-Copyright= \
 Copyright 2014-2023 Argeo GmbH, \
index d123aa09c1821b447b76d948c8eebe53b8eaf1c0..851d686d54f75f03568e599ce3b6b95189cb059e 100644 (file)
@@ -95,7 +95,9 @@ public class SwtArgeoApp extends AbstractArgeoApp implements CmsEventSubscriber
 //     private CmsUserManager cmsUserManager;
 
        // TODO make more optimal or via CmsSession/CmsView
-       private static Timer janitorTimer = new Timer(true);
+       // It works if static, but there is no clean way to get rid of it, so we open
+       // one per app
+       private Timer janitorTimer = new Timer(true);
        private Map<String, WeakReference<SwtAppUi>> managedUis = new HashMap<>();
 
        // ACR
@@ -189,6 +191,8 @@ public class SwtArgeoApp extends AbstractArgeoApp implements CmsEventSubscriber
                if (log.isDebugEnabled())
                        log.info("Argeo Suite App stopped");
 
+               // clean janitor timer so that th thread is not kept
+               janitorTimer.cancel();
        }
 
        @Override