Personal tools
You are here: Home GRIA Documentation Documentation 5.2 Tutorials Java Interface Tutorial Registry Service Tutorial 1 - Creating a Registry

Registry Service Tutorial 1 - Creating a Registry

How to create a registry
Tutorials on how to use the GRIA Client Interface API
Page 13 of 15.

In order to create a Registry we must first contact the Registry Service and try to call 'createRegistry' on it. First, define the location of the Registry Service.

private static String REGISTRY_SERVICE_ENDPOINT 
			= "https://hostname:port/gria-client-mgt/services/CltMgtRegistryService";

Then create a proxy to the Registry Service.

		
StateRepository repository = new MemoryStateRepository();
RemoteCltMgtRegistryService registryService = (RemoteCltMgtRegistryService)  
	repository.getOrCreateObject(RemoteCltMgtRegistryService.class,
			ConversationID.getEPR(REGISTRY_SERVICE_ENDPOINT));

Then try to call 'createRegistry' and print out the EPR

try {
	CltMgtRegistryResourceConversation reg = registryService.createRegistry("Registry 1");
	System.out.println("Created Registry '"+ConversationID.getLabel(reg.getEndpointRef())+"'"+"\n"+reg.getEndpointRef());
} catch (RemoteException e) {
	throw new RuntimeException(e);
} catch (ObjectAlreadyExists e){
	throw new RuntimeException(e);
}

Full Java code

import java.rmi.RemoteException;
import uk.ac.soton.ecs.iam.grid.client.staterepos.MemoryStateRepository;
import uk.ac.soton.ecs.iam.grid.comms.client.ObjectAlreadyExists;
import uk.ac.soton.ecs.iam.grid.comms.client.StateRepository;
import uk.ac.soton.itinnovation.grid.client.registry.CltMgtRegistryResourceConversation;
import uk.ac.soton.itinnovation.grid.client.registry.RemoteCltMgtRegistryService;
import uk.ac.soton.itinnovation.grid.types.ConversationID;

public class RegistryTutorial1 {

	private static String REGISTRY_SERVICE_ENDPOINT 
			= "https://hostname:port/gria-client-mgt/services/CltMgtRegistryService";

	public static void main(String[] args) {
		
		StateRepository repository = new MemoryStateRepository();
		RemoteCltMgtRegistryService registryService = (RemoteCltMgtRegistryService)  
			repository.getOrCreateObject(RemoteCltMgtRegistryService.class,
					ConversationID.getEPR(REGISTRY_SERVICE_ENDPOINT));

		try {
			CltMgtRegistryResourceConversation reg = registryService.createRegistry("Registry 1");
			System.out.println("Created Registry '"+ConversationID.getLabel(reg.getEndpointRef())+"'"+"\n"+reg.getEndpointRef());
		} catch (RemoteException e) {
			throw new RuntimeException(e);
		} catch (ObjectAlreadyExists e){
			throw new RuntimeException(e);
		}
	}

}