git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/information-system/gCubeIS/Registry@34690 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
f97788792f
commit
6986f187d2
|
@ -12,6 +12,7 @@ import java.util.Calendar;
|
|||
import org.apache.axis.components.uuid.UUIDGen;
|
||||
import org.apache.axis.components.uuid.UUIDGenFactory;
|
||||
import org.gcube.common.core.contexts.GCUBEServiceContext;
|
||||
import org.gcube.common.core.contexts.GCUBEServiceContext.Status;
|
||||
import org.gcube.common.core.faults.GCUBEFault;
|
||||
import org.gcube.common.core.porttypes.GCUBEPortType;
|
||||
import org.gcube.common.core.resources.GCUBEResource;
|
||||
|
@ -71,21 +72,31 @@ public class RegistryFactory extends GCUBEPortType {
|
|||
|
||||
@Override
|
||||
public void run() {
|
||||
while (true) {
|
||||
int attempts = 0;
|
||||
boolean created = false;
|
||||
while (attempts++ < 10) {
|
||||
try {
|
||||
Thread.sleep(1000);
|
||||
} catch (InterruptedException e1) {
|
||||
RegistryFactory.logger.error("Failed to sleep in between factory creation");
|
||||
ServiceContext.getContext().setStatus(Status.FAILED);
|
||||
break;
|
||||
}
|
||||
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();
|
||||
|
||||
singletonResource.store();
|
||||
}
|
||||
created = true;
|
||||
break;
|
||||
} catch (Exception e) {
|
||||
RegistryFactory.logger.error("Failed to create the resource", e);
|
||||
Thread.sleep(1000);
|
||||
RegistryFactory.logger.error("Failed to create the resource", e);
|
||||
}
|
||||
}
|
||||
if (!created)
|
||||
ServiceContext.getContext().setStatus(Status.FAILED);
|
||||
}
|
||||
|
||||
}.start();
|
||||
|
|
Loading…
Reference in New Issue