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

Membership Service Tutorial 1 - Creating a Group

How to create a Membership Group using the Membership Service
Tutorials on how to use the GRIA Client Interface API
Page 9 of 15.

In order to create a Membership Group we must first contact the Membership service and try to call 'createGroup' on it.First, define the location of the Membership Service

private static String MEMBERSHIP_SERVICE_ENDPOINT = "https://hostname:8443/gria-client-mgt/services/MembershipService";

Declare a new state repoitory

StateRepository repository = new MemoryStateRepository();		

Create a proxy to the membership service

RemoteMembershipService membershipService = 
	repository.getOrCreateObject(RemoteMembershipService.class, ConversationID.getEPR(MEMBERSHIP_SERVICE_ENDPOINT));

Try to call 'createGroup' on the membership service

MembershipGroupConversation group = membershipService.createGroup("My Group");

System.out.println(group.getEndpointRef());

Full java code (cut and paste)

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.membership.MembershipGroupConversation;
import uk.ac.soton.itinnovation.grid.client.membership.RemoteMembershipService;
import uk.ac.soton.itinnovation.grid.types.ConversationID;

public class MembershipGroupTutorial1 {

	private static String MEMBERSHIP_SERVICE_ENDPOINT 
			= "https://hostname:8443/gria-client-mgt/services/MembershipService";

	public static void main(String[] args) {
		StateRepository repository = new MemoryStateRepository();
		RemoteMembershipService membershipService =   
			repository.getOrCreateObject(RemoteMembershipService.class,
					ConversationID.getEPR(MEMBERSHIP_SERVICE_ENDPOINT));
		MembershipGroupConversation group = null;
		try {
			group = membershipService.createGroup("My Group");
		} catch (RemoteException e) {
			throw new RuntimeException(e);
		} catch (ObjectAlreadyExists e) {
			throw new RuntimeException(e);
		}
		
		System.out.println(group.getEndpointRef());
	}

}