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
This commit is contained in:
parent
99ee7ae64d
commit
f97788792f
|
@ -67,18 +67,28 @@ public class RegistryFactory extends GCUBEPortType {
|
||||||
if (singletonResource != null)
|
if (singletonResource != null)
|
||||||
return;//cannot create the state twice
|
return;//cannot create the state twice
|
||||||
logger.info("Initialising the factory state...");
|
logger.info("Initialising the factory state...");
|
||||||
try {
|
new Thread() {
|
||||||
for (GCUBEScope scope: ServiceContext.getContext().getInstance().getScopes().values()){
|
|
||||||
logger.info("Creating the notification resource " + RegistryFactory.NOTIFICATOR_RESOURCE_KEY + " within the scope " + scope.getName());
|
@Override
|
||||||
ServiceContext.getContext().setScope(scope);
|
public void run() {
|
||||||
singletonResource = (RegistryFactoryResource) FactoryContext.getContext().getWSHome().create(FactoryContext.getContext().makeKey(RegistryFactory.NOTIFICATOR_RESOURCE_KEY));
|
while (true) {
|
||||||
singletonResource.store();
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (Exception e) {
|
}.start();
|
||||||
logger.error("Failed to create the resource", e);
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue