This commit is contained in:
Manuele Simi 2008-04-11 20:18:43 +00:00
parent 25a098e7c8
commit 891d56017c
5 changed files with 100 additions and 87 deletions

View File

@ -38,13 +38,6 @@
<agg:ResourcePropertyNames>registry:MetadataCollection</agg:ResourcePropertyNames> <agg:ResourcePropertyNames>registry:MetadataCollection</agg:ResourcePropertyNames>
<agg:ResourcePropertyNames>registry:TransformationProgram</agg:ResourcePropertyNames> <agg:ResourcePropertyNames>registry:TransformationProgram</agg:ResourcePropertyNames>
<agg:ResourcePropertyNames>provider:RI</agg:ResourcePropertyNames>
<agg:ResourcePropertyNames>provider:ServiceID</agg:ResourcePropertyNames>
<agg:ResourcePropertyNames>provider:ServiceName</agg:ResourcePropertyNames>
<agg:ResourcePropertyNames>provider:ServiceClass</agg:ResourcePropertyNames>
<agg:ResourcePropertyNames>provider:VO</agg:ResourcePropertyNames>
<agg:ResourcePropertyNames>provider:GHN</agg:ResourcePropertyNames>
<agg:ResourcePropertyNames>provider:Scope</agg:ResourcePropertyNames>
</agg:GetMultipleResourcePropertiesPollType> </agg:GetMultipleResourcePropertiesPollType>
</agg:AggregatorConfig> </agg:AggregatorConfig>

View File

@ -2,12 +2,25 @@ package org.gcube.informationsystem.registry.impl.core;
/** /**
* *
* @author Andrea Manzi * Local Configuration of the IS-Registry
*
* @author Andrea Manzi, Manuele Simi (CNR)
* *
*/ */
public class RegistryConfiguration { public class RegistryConfiguration {
/** The root service to take care at service's startup */
public static enum ROOT_SERVICES {
ISIC() {String getName() {return "InformationSystem";} String getClazz() {return "IS-IC";}},
ISNOTIFIER() {String getName() {return "InformationSystem";} String getClazz() {return "IS-Notifier";}},
GHNMANAGER() {String getName() {return "VREManagement";} String getClazz() {return "GHNManager";}};
abstract String getName();
abstract String getClazz();
}
/** /**
* *
*/ */

View File

@ -81,7 +81,9 @@ public class RegistryFactory extends GCUBEStartupPortType{
*/ */
public static List<GCUBEWSResourceKey> notificationMap = Collections.synchronizedList(new ArrayList<GCUBEWSResourceKey>()); public static List<GCUBEWSResourceKey> notificationMap = Collections.synchronizedList(new ArrayList<GCUBEWSResourceKey>());
/** the key used to label the Factory Resource */
protected static final String NOTIFICATOR_RESOURCE_KEY = "RegistryResource";
@Override @Override
protected GCUBEServiceContext getServiceContext() { protected GCUBEServiceContext getServiceContext() {
return ServiceContext.getContext(); return ServiceContext.getContext();
@ -395,7 +397,7 @@ public class RegistryFactory extends GCUBEStartupPortType{
private RegistryFactoryResource getResource() throws RemoteException { private RegistryFactoryResource getResource() throws RemoteException {
Object resource = null; Object resource = null;
try { try {
resource = FactoryContext.getContext().getWSHome().find(FactoryContext.getContext().makeKey("RegistryResource")); resource = FactoryContext.getContext().getWSHome().find(FactoryContext.getContext().makeKey(NOTIFICATOR_RESOURCE_KEY));
} catch (Exception e) { } catch (Exception e) {
logger.error(" Unable to access resource", e); logger.error(" Unable to access resource", e);
} }

View File

@ -13,8 +13,11 @@ import org.globus.wsrf.ResourceException;
/** /**
* *
* The <em>RegistryFactoryResource</em> has the role to maintain WS-Topics used to notify changes each time
* a GCUBEResource profile is created/removed/updated. A single instance of this class is created within
* each instance of the IS-Registry service.
* *
* @author Andrea Manzi * @author Andrea Manzi, Manuele Simi (CNR)
* *
*/ */
public class RegistryFactoryResource extends GCUBEWSResource { public class RegistryFactoryResource extends GCUBEWSResource {
@ -51,8 +54,7 @@ public class RegistryFactoryResource extends GCUBEWSResource {
@Override @Override
protected String[] getTopicNames() { protected String[] getTopicNames() {
// TODO Auto-generated method stub
return RPNames; return RPNames;
} }

View File

@ -10,17 +10,19 @@ import org.gcube.common.core.informationsystem.publisher.ISPublisherException;
import org.gcube.common.core.resources.GCUBEHostingNode; import org.gcube.common.core.resources.GCUBEHostingNode;
import org.gcube.common.core.resources.GCUBEResource; import org.gcube.common.core.resources.GCUBEResource;
import org.gcube.common.core.resources.GCUBERunningInstance; import org.gcube.common.core.resources.GCUBERunningInstance;
import org.gcube.informationsystem.registry.impl.core.RegistryConfiguration.ROOT_SERVICES;
/** /**
* IS-Registry service context * IS-Registry service context
*
* @author Andrea Manzi, Manuele SImi (CNR)
* *
* @author Andrea Manzi (ISTI-CNR)
*
*/ */
public class ServiceContext extends GCUBEServiceContext{ public class ServiceContext extends GCUBEServiceContext {
public static final String JNDI_NAME = "gcube/informationsystem/registry";
public static final String JNDI_NAME="gcube/informationsystem/registry";
protected static ServiceContext cache = new ServiceContext(); protected static ServiceContext cache = new ServiceContext();
private ServiceContext() {} private ServiceContext() {}
@ -28,84 +30,80 @@ public class ServiceContext extends GCUBEServiceContext{
public static ServiceContext getContext() { public static ServiceContext getContext() {
return cache; return cache;
} }
public String getJNDIName() { public String getJNDIName() {
return JNDI_NAME; return JNDI_NAME;
} }
@Override @Override
protected void onReady() throws Exception{ protected void onReady() throws Exception {
GCUBERunningInstance RegistryRIProfile = null; GCUBERunningInstance RegistryRIProfile = null;
GCUBERunningInstance NotifierRIProfile = null; GCUBERunningInstance NotifierRIProfile = null;
GCUBERunningInstance ISICRIProfile = null; GCUBERunningInstance ISICRIProfile = null;
GCUBERunningInstance GHNManagerProfile = null; GCUBERunningInstance GHNManagerProfile = null;
GCUBEHostingNode ghnProfile = null; GCUBEHostingNode ghnProfile = null;
String ghnName =""; String ghnName = "";
GCUBERIsFromClassAndName queryRI = null; GCUBERIsFromClassAndName queryRI = null;
GCUBEResourceXPathQuery queryGHN = null; GCUBEResourceXPathQuery queryGHN = null;
boolean isNotifierCodeployed = false; boolean isNotifierCodeployed = false;
boolean isICCodeployed =false; boolean isICCodeployed = false;
ISClient client = null; ISClient client = null;
//creates the single RegistryResource used to raise notifications about profiles' changes
// create GeneralQueryManager FactoryContext.getContext().getWSHome().create(
FactoryContext.getContext().makeKey(RegistryFactory.NOTIFICATOR_RESOURCE_KEY));
// create GeneralQueryManager
try { try {
client = GHNContext.getImplementation(ISClient.class); client = GHNContext.getImplementation(ISClient.class);
queryRI = client.getQuery(GCUBERIsFromClassAndName.class); queryRI = client.getQuery(GCUBERIsFromClassAndName.class);
queryGHN = client.getQuery(GCUBEResourceXPathQuery.class); queryGHN = client.getQuery(GCUBEResourceXPathQuery.class);
}catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
try { try {
RegistryRIProfile= ServiceContext.getContext().getInstance(); RegistryRIProfile = ServiceContext.getContext().getInstance();
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
try { try {
NotifierRIProfile= GHNContext.getContext().getServiceContext("InformationSystem", "IS-Notifier").getInstance(); NotifierRIProfile = GHNContext.getContext().getServiceContext(
isNotifierCodeployed= true; ROOT_SERVICES.ISNOTIFIER.getClazz(), ROOT_SERVICES.ISNOTIFIER.getName()).getInstance();
isNotifierCodeployed = true;
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
try { try {
GHNManagerProfile= GHNContext.getContext().getServiceContext("VREManagement", "GHNManager").getInstance(); GHNManagerProfile = GHNContext.getContext().getServiceContext(ROOT_SERVICES.GHNMANAGER.getClazz(), ROOT_SERVICES.GHNMANAGER.getName()).getInstance();
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
try { try {
ISICRIProfile=GHNContext.getContext().getServiceContext("InformationSystem", "IS-IC").getInstance(); ISICRIProfile = GHNContext.getContext().getServiceContext( ROOT_SERVICES.ISIC.getClazz(), ROOT_SERVICES.ISIC.getName()).getInstance();
isICCodeployed = true; isICCodeployed = true;
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
try { try {
ghnProfile=GHNContext.getContext().getGHN(); ghnProfile = GHNContext.getContext().getGHN();
ghnName = ghnProfile.getNodeDescription().getName();
ghnName=ghnProfile.getNodeDescription().getName();
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
@ -117,64 +115,69 @@ public class ServiceContext extends GCUBEServiceContext{
e1.printStackTrace(); e1.printStackTrace();
} }
//Check if the Registry profile is alerady registered // Check if the Registry profile is alerady registered
try { try {
// registers the my profile
queryRI.setEntryName( "gcube/informationsystem/registry/RegistryFactory"); queryRI.setEntryName("gcube/informationsystem/registry/RegistryFactory");
queryRI.setResourceClass("InformationSystem"); queryRI.setResourceClass(this.getServiceClass());
queryRI.setResourceName("IS-Registry"); queryRI.setResourceName(this.getName());
if (client.execute(queryRI, GHNContext.getContext().getDefaultScope()).size()==0) registerProfile(RegistryRIProfile,GCUBERunningInstance.TYPE); if (client.execute(queryRI,
GHNContext.getContext().getDefaultScope()).size() == 0)
registerProfile(RegistryRIProfile, GCUBERunningInstance.TYPE);
// registers the local IS-Notifier profile
if (isNotifierCodeployed) { if (isNotifierCodeployed) {
queryRI.setEntryName( "gcube/informationsystem/notifier/Notifier"); queryRI.setEntryName("gcube/informationsystem/notifier/Notifier");
queryRI.setResourceClass("InformationSystem"); queryRI.setResourceClass(ROOT_SERVICES.ISNOTIFIER.getClazz());
queryRI.setResourceName("IS-Notifier"); queryRI.setResourceName(ROOT_SERVICES.ISNOTIFIER.getName());
if (client.execute(queryRI, GHNContext.getContext().getDefaultScope()).size()==0) registerProfile(NotifierRIProfile,GCUBERunningInstance.TYPE); if (client.execute(queryRI,
GHNContext.getContext().getDefaultScope()).size() == 0)
registerProfile(NotifierRIProfile, GCUBERunningInstance.TYPE);
} }
// registers the local IS-IC profile
if (isICCodeployed) { if (isICCodeployed) {
queryRI.setEntryName( "gcube/informationsystem/isic/ISICFactoryService"); queryRI.setEntryName("gcube/informationsystem/isic/ISICFactoryService");
queryRI.setResourceClass("InformationSystem"); queryRI.setResourceClass(ROOT_SERVICES.ISIC.getClazz());
queryRI.setResourceName("IS-IC"); queryRI.setResourceName(ROOT_SERVICES.ISIC.getName());
if (client.execute(queryRI, GHNContext.getContext().getDefaultScope()).size()==0) registerProfile(ISICRIProfile,GCUBERunningInstance.TYPE); if (client.execute(queryRI, GHNContext.getContext().getDefaultScope()).size() == 0)
registerProfile(ISICRIProfile, GCUBERunningInstance.TYPE);
} }
// registers the local GHNManager profile
queryGHN.setResourceType(GCUBEHostingNode.TYPE); queryGHN.setResourceType(GCUBEHostingNode.TYPE);
queryGHN.setXPath("/GHNDescription/Name/string() eq '" + ghnName + "'"); queryGHN.setXPath("/GHNDescription/Name/string() eq '" + ghnName + "'");
if (client.execute(queryGHN, GHNContext.getContext().getDefaultScope()).size()==0) registerProfile(ghnProfile,GCUBEHostingNode.TYPE); if (client.execute(queryGHN, GHNContext.getContext().getDefaultScope()).size() == 0)
registerProfile(ghnProfile, GCUBEHostingNode.TYPE);
}catch (Exception e) {
} catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
}
@Override
protected void onInitialisation() throws Exception {
FactoryContext.getContext().getWSHome().create(FactoryContext.getContext().makeKey("RegistryResource"));
} }
@Override
protected void onInitialisation() throws Exception {
}
/** /**
* Register the Profile * Register the Profile
* *
* @param resource teh gCUBEResource * @param resource
* @param type The profile Type * teh gCUBEResource
* @throws Exception * @param type
* @throws ISPublisherException * The profile Type
* @throws Exception
* @throws ISPublisherException
*/ */
private void registerProfile(GCUBEResource resource,String type) throws ISPublisherException, Exception { private void registerProfile(GCUBEResource resource, String type)
GHNContext.getImplementation(ISPublisher.class).registerGCUBEResource(resource, GHNContext.getContext().getDefaultScope(), ServiceContext.getContext()); throws ISPublisherException, Exception {
if (GHNContext.getContext().getMode() == GHNContext.Mode.ROOT)
GHNContext.getImplementation(ISPublisher.class).registerGCUBEResource(
resource, GHNContext.getContext().getDefaultScope(),
ServiceContext.getContext());
} }
} }