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: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: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 {
/** 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>());
/** the key used to label the Factory Resource */
protected static final String NOTIFICATOR_RESOURCE_KEY = "RegistryResource";
@Override
protected GCUBEServiceContext getServiceContext() {
return ServiceContext.getContext();
@ -395,7 +397,7 @@ public class RegistryFactory extends GCUBEStartupPortType{
private RegistryFactoryResource getResource() throws RemoteException {
Object resource = null;
try {
resource = FactoryContext.getContext().getWSHome().find(FactoryContext.getContext().makeKey("RegistryResource"));
resource = FactoryContext.getContext().getWSHome().find(FactoryContext.getContext().makeKey(NOTIFICATOR_RESOURCE_KEY));
} catch (Exception 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 {
@ -51,8 +54,7 @@ public class RegistryFactoryResource extends GCUBEWSResource {
@Override
protected String[] getTopicNames() {
// TODO Auto-generated method stub
protected String[] getTopicNames() {
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.GCUBEResource;
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();
private ServiceContext() {}
@ -28,84 +30,80 @@ public class ServiceContext extends GCUBEServiceContext{
public static ServiceContext getContext() {
return cache;
}
public String getJNDIName() {
return JNDI_NAME;
}
@Override
protected void onReady() throws Exception{
protected void onReady() throws Exception {
GCUBERunningInstance RegistryRIProfile = null;
GCUBERunningInstance NotifierRIProfile = null;
GCUBERunningInstance ISICRIProfile = null;
GCUBERunningInstance GHNManagerProfile = null;
GCUBEHostingNode ghnProfile = null;
String ghnName ="";
String ghnName = "";
GCUBERIsFromClassAndName queryRI = null;
GCUBEResourceXPathQuery queryGHN = null;
boolean isNotifierCodeployed = false;
boolean isICCodeployed =false;
boolean isICCodeployed = false;
ISClient client = null;
// create GeneralQueryManager
//creates the single RegistryResource used to raise notifications about profiles' changes
FactoryContext.getContext().getWSHome().create(
FactoryContext.getContext().makeKey(RegistryFactory.NOTIFICATOR_RESOURCE_KEY));
// create GeneralQueryManager
try {
client = GHNContext.getImplementation(ISClient.class);
client = GHNContext.getImplementation(ISClient.class);
queryRI = client.getQuery(GCUBERIsFromClassAndName.class);
queryGHN = client.getQuery(GCUBEResourceXPathQuery.class);
}catch (Exception e) {
} catch (Exception e) {
e.printStackTrace();
}
try {
RegistryRIProfile= ServiceContext.getContext().getInstance();
RegistryRIProfile = ServiceContext.getContext().getInstance();
} catch (Exception e) {
e.printStackTrace();
}
try {
NotifierRIProfile= GHNContext.getContext().getServiceContext("InformationSystem", "IS-Notifier").getInstance();
isNotifierCodeployed= true;
NotifierRIProfile = GHNContext.getContext().getServiceContext(
ROOT_SERVICES.ISNOTIFIER.getClazz(), ROOT_SERVICES.ISNOTIFIER.getName()).getInstance();
isNotifierCodeployed = true;
} catch (Exception e) {
e.printStackTrace();
}
try {
GHNManagerProfile= GHNContext.getContext().getServiceContext("VREManagement", "GHNManager").getInstance();
GHNManagerProfile = GHNContext.getContext().getServiceContext(ROOT_SERVICES.GHNMANAGER.getClazz(), ROOT_SERVICES.GHNMANAGER.getName()).getInstance();
} catch (Exception e) {
e.printStackTrace();
}
try {
ISICRIProfile=GHNContext.getContext().getServiceContext("InformationSystem", "IS-IC").getInstance();
ISICRIProfile = GHNContext.getContext().getServiceContext( ROOT_SERVICES.ISIC.getClazz(), ROOT_SERVICES.ISIC.getName()).getInstance();
isICCodeployed = true;
} catch (Exception e) {
e.printStackTrace();
}
try {
ghnProfile=GHNContext.getContext().getGHN();
ghnName=ghnProfile.getNodeDescription().getName();
ghnProfile = GHNContext.getContext().getGHN();
ghnName = ghnProfile.getNodeDescription().getName();
} catch (Exception e) {
e.printStackTrace();
}
@ -117,64 +115,69 @@ public class ServiceContext extends GCUBEServiceContext{
e1.printStackTrace();
}
//Check if the Registry profile is alerady registered
// Check if the Registry profile is alerady registered
try {
queryRI.setEntryName( "gcube/informationsystem/registry/RegistryFactory");
queryRI.setResourceClass("InformationSystem");
queryRI.setResourceName("IS-Registry");
if (client.execute(queryRI, GHNContext.getContext().getDefaultScope()).size()==0) registerProfile(RegistryRIProfile,GCUBERunningInstance.TYPE);
// registers the my profile
queryRI.setEntryName("gcube/informationsystem/registry/RegistryFactory");
queryRI.setResourceClass(this.getServiceClass());
queryRI.setResourceName(this.getName());
if (client.execute(queryRI,
GHNContext.getContext().getDefaultScope()).size() == 0)
registerProfile(RegistryRIProfile, GCUBERunningInstance.TYPE);
// registers the local IS-Notifier profile
if (isNotifierCodeployed) {
queryRI.setEntryName( "gcube/informationsystem/notifier/Notifier");
queryRI.setResourceClass("InformationSystem");
queryRI.setResourceName("IS-Notifier");
if (client.execute(queryRI, GHNContext.getContext().getDefaultScope()).size()==0) registerProfile(NotifierRIProfile,GCUBERunningInstance.TYPE);
queryRI.setEntryName("gcube/informationsystem/notifier/Notifier");
queryRI.setResourceClass(ROOT_SERVICES.ISNOTIFIER.getClazz());
queryRI.setResourceName(ROOT_SERVICES.ISNOTIFIER.getName());
if (client.execute(queryRI,
GHNContext.getContext().getDefaultScope()).size() == 0)
registerProfile(NotifierRIProfile, GCUBERunningInstance.TYPE);
}
// registers the local IS-IC profile
if (isICCodeployed) {
queryRI.setEntryName( "gcube/informationsystem/isic/ISICFactoryService");
queryRI.setResourceClass("InformationSystem");
queryRI.setResourceName("IS-IC");
if (client.execute(queryRI, GHNContext.getContext().getDefaultScope()).size()==0) registerProfile(ISICRIProfile,GCUBERunningInstance.TYPE);
queryRI.setEntryName("gcube/informationsystem/isic/ISICFactoryService");
queryRI.setResourceClass(ROOT_SERVICES.ISIC.getClazz());
queryRI.setResourceName(ROOT_SERVICES.ISIC.getName());
if (client.execute(queryRI, GHNContext.getContext().getDefaultScope()).size() == 0)
registerProfile(ISICRIProfile, GCUBERunningInstance.TYPE);
}
// registers the local GHNManager profile
queryGHN.setResourceType(GCUBEHostingNode.TYPE);
queryGHN.setXPath("/GHNDescription/Name/string() eq '" + ghnName + "'");
if (client.execute(queryGHN, GHNContext.getContext().getDefaultScope()).size()==0) registerProfile(ghnProfile,GCUBEHostingNode.TYPE);
}catch (Exception e) {
queryGHN.setXPath("/GHNDescription/Name/string() eq '" + ghnName + "'");
if (client.execute(queryGHN, GHNContext.getContext().getDefaultScope()).size() == 0)
registerProfile(ghnProfile, GCUBEHostingNode.TYPE);
} catch (Exception e) {
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 type The profile Type
* @throws Exception
* @throws ISPublisherException
* @param resource
* teh gCUBEResource
* @param type
* The profile Type
* @throws Exception
* @throws ISPublisherException
*/
private void registerProfile(GCUBEResource resource,String type) throws ISPublisherException, Exception {
GHNContext.getImplementation(ISPublisher.class).registerGCUBEResource(resource, GHNContext.getContext().getDefaultScope(), ServiceContext.getContext());
private void registerProfile(GCUBEResource resource, String type)
throws ISPublisherException, Exception {
if (GHNContext.getContext().getMode() == GHNContext.Mode.ROOT)
GHNContext.getImplementation(ISPublisher.class).registerGCUBEResource(
resource, GHNContext.getContext().getDefaultScope(),
ServiceContext.getContext());
}
}