From 578b34406f4f54ca7eebc91adde234bc7423860b Mon Sep 17 00:00:00 2001 From: Lucio Lelii Date: Fri, 22 Aug 2008 19:21:47 +0000 Subject: [PATCH] git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/information-system/gCubeIS/Registry@2983 82a268e6-3cf1-43bd-a215-b396298e98cf --- .../registry/impl/RegistryFactory.java | 2 +- .../impl/contexts/ServiceContext.java | 55 +++++++++---------- 2 files changed, 28 insertions(+), 29 deletions(-) diff --git a/src/org/gcube/informationsystem/registry/impl/RegistryFactory.java b/src/org/gcube/informationsystem/registry/impl/RegistryFactory.java index 1296f58..ce3945b 100644 --- a/src/org/gcube/informationsystem/registry/impl/RegistryFactory.java +++ b/src/org/gcube/informationsystem/registry/impl/RegistryFactory.java @@ -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; diff --git a/src/org/gcube/informationsystem/registry/impl/contexts/ServiceContext.java b/src/org/gcube/informationsystem/registry/impl/contexts/ServiceContext.java index 46d1d02..9d34b35 100644 --- a/src/org/gcube/informationsystem/registry/impl/contexts/ServiceContext.java +++ b/src/org/gcube/informationsystem/registry/impl/contexts/ServiceContext.java @@ -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 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