]> git.argeo.org Git - lgpl/argeo-commons.git/blobdiff - org.argeo.cms/src/org/argeo/cms/internal/kernel/CmsDeployment.java
Fix issue with CMS deployment marked twice as available when state has
[lgpl/argeo-commons.git] / org.argeo.cms / src / org / argeo / cms / internal / kernel / CmsDeployment.java
index 67abe90fa65911006881752e476396e5ffa25246..30d283c580583ed090df96b2694ad093bd414b89 100644 (file)
@@ -192,11 +192,18 @@ public class CmsDeployment implements NodeDeployment {
        public void shutdown() {
                if (nodeHttp != null)
                        nodeHttp.destroy();
-               if (deployConfig != null)
-                       deployConfig.save();
+               if (deployConfig != null) {
+                       new Thread(() -> deployConfig.save(), "Save Argeo Deploy Config").start();
+               }
        }
 
-       private void checkReadiness() {
+       /**
+        * Checks whether the deployment is available according to expectations, and
+        * mark it as available.
+        */
+       private synchronized void checkReadiness() {
+               if (isAvailable())
+                       return;
                if (nodeAvailable && userAdminAvailable && (httpExpected ? httpAvailable : true)) {
                        String data = KernelUtils.getFrameworkProp(KernelUtils.OSGI_INSTANCE_AREA);
                        String state = KernelUtils.getFrameworkProp(KernelUtils.OSGI_CONFIGURATION_AREA);
@@ -363,15 +370,19 @@ public class CmsDeployment implements NodeDeployment {
                        properties.put(Constants.SERVICE_RANKING, Integer.MAX_VALUE);
                LocalRepository localRepository = new LocalRepository(repository, dataModelName);
                bc.registerService(Repository.class, localRepository, properties);
-               if (log.isDebugEnabled())
-                       log.debug("Published data model " + dataModelName);
+               if (log.isTraceEnabled())
+                       log.trace("Published data model " + dataModelName);
        }
 
        @Override
-       public Long getAvailableSince() {
+       public synchronized Long getAvailableSince() {
                return availableSince;
        }
 
+       public synchronized boolean isAvailable() {
+               return availableSince != null;
+       }
+
        private class RepositoryContextStc extends ServiceTracker<RepositoryContext, RepositoryContext> {
 
                public RepositoryContextStc() {