This commit is contained in:
Lucio Lelii 2008-08-22 19:21:47 +00:00
parent 20ae0c709d
commit 578b34406f
2 changed files with 28 additions and 29 deletions

View File

@ -351,7 +351,7 @@ public class RegistryFactory extends GCUBEStartupPortType{
return (ProfileResource) ProfileContext.getContext().getWSHome().find(ProfileContext.getContext().makeKey(id));
}
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;

View File

@ -1,6 +1,7 @@
package org.gcube.informationsystem.registry.impl.contexts;
import java.io.ByteArrayInputStream;
import java.util.List;
import javax.xml.namespace.QName;
import org.apache.axis.encoding.TypeMappingRegistry;
@ -95,10 +96,31 @@ public class ServiceContext extends GCUBEServiceContext {
@SuppressWarnings("unchecked")
public void run() throws Exception {
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 );
List<String> pt = GHNContext.getContext().getActivePortTypes();
if ( (pt == null) || (pt.size() < 1))
throw new Exception();
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);
//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);
scheduler.setHandled(new NotificationResource());
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