diff --git a/src/org/gcube/informationsystem/registry/impl/porttypes/RegistryFactory.java b/src/org/gcube/informationsystem/registry/impl/porttypes/RegistryFactory.java index 71c75c8..ab694b9 100644 --- a/src/org/gcube/informationsystem/registry/impl/porttypes/RegistryFactory.java +++ b/src/org/gcube/informationsystem/registry/impl/porttypes/RegistryFactory.java @@ -67,19 +67,29 @@ public class RegistryFactory extends GCUBEPortType { if (singletonResource != null) return;//cannot create the state twice logger.info("Initialising the factory state..."); - try { - for (GCUBEScope scope: ServiceContext.getContext().getInstance().getScopes().values()){ - logger.info("Creating the notification resource " + RegistryFactory.NOTIFICATOR_RESOURCE_KEY + " within the scope " + scope.getName()); - ServiceContext.getContext().setScope(scope); - singletonResource = (RegistryFactoryResource) FactoryContext.getContext().getWSHome().create(FactoryContext.getContext().makeKey(RegistryFactory.NOTIFICATOR_RESOURCE_KEY)); - singletonResource.store(); - } + new Thread() { - } catch (Exception e) { - logger.error("Failed to create the resource", e); - throw e; - } - + @Override + public void run() { + while (true) { + try { + for (GCUBEScope scope: ServiceContext.getContext().getInstance().getScopes().values()){ + RegistryFactory.logger.info("Creating the notification resource " + RegistryFactory.NOTIFICATOR_RESOURCE_KEY + " within the scope " + scope.getName()); + ServiceContext.getContext().setScope(scope); + singletonResource = (RegistryFactoryResource) FactoryContext.getContext().getWSHome().create(FactoryContext.getContext().makeKey(RegistryFactory.NOTIFICATOR_RESOURCE_KEY)); + singletonResource.store(); + + } + break; + } catch (Exception e) { + RegistryFactory.logger.error("Failed to create the resource", e); + Thread.sleep(1000); + } + } + } + + }.start(); + } /**