From f97788792f67512c14b8ce34ea389b9cb9fa8bcb Mon Sep 17 00:00:00 2001 From: Manuele Simi Date: Sat, 5 Feb 2011 20:41:01 +0000 Subject: [PATCH] Asynch creation of the factory resource git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/information-system/gCubeIS/Registry@34689 82a268e6-3cf1-43bd-a215-b396298e98cf --- .../impl/porttypes/RegistryFactory.java | 34 ++++++++++++------- 1 file changed, 22 insertions(+), 12 deletions(-) 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(); + } /**