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,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();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue