git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/information-system/gCubeIS/Registry@2983 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
20ae0c709d
commit
578b34406f
|
@ -351,7 +351,7 @@ public class RegistryFactory extends GCUBEStartupPortType{
|
||||||
return (ProfileResource) ProfileContext.getContext().getWSHome().find(ProfileContext.getContext().makeKey(id));
|
return (ProfileResource) ProfileContext.getContext().getWSHome().find(ProfileContext.getContext().makeKey(id));
|
||||||
}
|
}
|
||||||
catch (Exception e ){
|
catch (Exception e ){
|
||||||
logger.debug("A profile with the given id has not been created yet");
|
logger.debug("A profile with the given id "+ id+" has not been created yet");
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package org.gcube.informationsystem.registry.impl.contexts;
|
package org.gcube.informationsystem.registry.impl.contexts;
|
||||||
|
|
||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import javax.xml.namespace.QName;
|
import javax.xml.namespace.QName;
|
||||||
import org.apache.axis.encoding.TypeMappingRegistry;
|
import org.apache.axis.encoding.TypeMappingRegistry;
|
||||||
|
@ -95,10 +96,31 @@ public class ServiceContext extends GCUBEServiceContext {
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public void run() throws Exception {
|
public void run() throws Exception {
|
||||||
|
|
||||||
ServiceContext.getContext().setScope(ServiceContext.getContext().getInstance().getScopes().values().toArray(new GCUBEScope[0])[0]);
|
List<String> pt = GHNContext.getContext().getActivePortTypes();
|
||||||
RegistryFactoryResource resource = (RegistryFactoryResource) FactoryContext.getContext().getWSHome().create(
|
if ( (pt == null) || (pt.size() < 1))
|
||||||
FactoryContext.getContext().makeKey(RegistryFactory.NOTIFICATOR_RESOURCE_KEY));
|
throw new Exception();
|
||||||
resource.getPersistenceDelegate().store(resource );
|
|
||||||
|
try {
|
||||||
|
// register my profile
|
||||||
|
GCUBERunningInstance RegistryRIProfile = ServiceContext.getContext().getInstance();
|
||||||
|
GCUBERIQuery query = client.getQuery(GCUBERIQuery.class);
|
||||||
|
query.addAtomicConditions(new AtomicCondition("//ServiceClass", ServiceContext.this.getServiceClass()),new AtomicCondition("//ServiceName", this.getName()));
|
||||||
|
if (ServiceContext.this.client.execute(query, GHNContext.getContext().getDefaultScope()).size() == 0)
|
||||||
|
registerProfile(RegistryRIProfile, GCUBERunningInstance.TYPE);
|
||||||
|
|
||||||
|
ServiceContext. this.checkCodeployedServices();
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("Failed to register co-deployed services", e);
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
ServiceContext.getContext().setScope(ServiceContext.getContext().getInstance().getScopes().values().toArray(new GCUBEScope[0])[0]);
|
||||||
|
RegistryFactoryResource resource = (RegistryFactoryResource) FactoryContext.getContext().getWSHome().create(
|
||||||
|
FactoryContext.getContext().makeKey(RegistryFactory.NOTIFICATOR_RESOURCE_KEY));
|
||||||
|
resource.getPersistenceDelegate().store(resource );
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -120,34 +142,11 @@ public class ServiceContext extends GCUBEServiceContext {
|
||||||
GHNContext.getContext().setMode(Mode.PRODUCTION);
|
GHNContext.getContext().setMode(Mode.PRODUCTION);
|
||||||
|
|
||||||
//creates the single RegistryResource used to raise notifications about profiles' changes
|
//creates the single RegistryResource used to raise notifications about profiles' changes
|
||||||
logger.info("Creating IS-Registry notification resource...");
|
logger.info("Scheduling IS-Registry notification resource...");
|
||||||
|
|
||||||
NotificationResourceScheduler scheduler = new NotificationResourceScheduler(10, GCUBEScheduledHandler.Mode.LAZY);
|
NotificationResourceScheduler scheduler = new NotificationResourceScheduler(10, GCUBEScheduledHandler.Mode.LAZY);
|
||||||
scheduler.setHandled(new NotificationResource());
|
scheduler.setHandled(new NotificationResource());
|
||||||
scheduler.run();
|
scheduler.run();
|
||||||
|
|
||||||
logger.info("IS-Registry notification resource registered");
|
|
||||||
|
|
||||||
try {Thread.sleep(20000);} catch (InterruptedException e1) {
|
|
||||||
logger.error("Unable to get the service instance profile", e1);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check if the Registry profile is already registered
|
|
||||||
|
|
||||||
try {
|
|
||||||
// register my profile
|
|
||||||
GCUBERunningInstance RegistryRIProfile = ServiceContext.getContext().getInstance();
|
|
||||||
GCUBERIQuery query = client.getQuery(GCUBERIQuery.class);
|
|
||||||
query.addAtomicConditions(new AtomicCondition("//ServiceClass", this.getServiceClass()),new AtomicCondition("//ServiceName", this.getName()));
|
|
||||||
if (this.client.execute(query, GHNContext.getContext().getDefaultScope()).size() == 0)
|
|
||||||
registerProfile(RegistryRIProfile, GCUBERunningInstance.TYPE);
|
|
||||||
|
|
||||||
this.checkCodeployedServices();
|
|
||||||
} catch (Exception e) {
|
|
||||||
logger.error("Failed to register co-deployed services", e);
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in New Issue