1 24 25 package org.objectweb.tribe.channel; 26 27 import java.io.Serializable ; 28 import java.util.ArrayList ; 29 30 import org.objectweb.tribe.common.Group; 31 import org.objectweb.tribe.common.GroupIdentifier; 32 import org.objectweb.tribe.common.Member; 33 import org.objectweb.tribe.exceptions.AlreadyMemberException; 34 import org.objectweb.tribe.exceptions.ChannelException; 35 import org.objectweb.tribe.exceptions.NotConnectedException; 36 import org.objectweb.tribe.gms.GroupMembershipService; 37 38 45 public class ReliableGroupChannelWithGms extends ReliableGroupChannel 46 { 47 protected GroupMembershipService gms = null; 48 49 55 public ReliableGroupChannelWithGms(GroupMembershipService gms) 56 { 57 super(); 58 this.gms = gms; 59 } 60 61 69 public void join(GroupIdentifier gid) throws AlreadyMemberException, 70 ChannelException, NotConnectedException 71 { 72 Group g = getGroup(gid); 73 if (g == null) 74 g = new Group(gid); 75 super.join(g); 76 me = gms.join(this, gid); 77 currentGroup = getGroup(gid); 78 } 79 80 86 public void quit() throws ChannelException, NotConnectedException 87 { 88 if (currentGroup == null) 89 throw new NotConnectedException(); 90 try 91 { 92 gms.quit(this, currentGroup.getGroupIdentifier()); 93 } 94 catch (ChannelException ignore) 95 { 96 } 97 super.quit(); 98 me = null; 99 } 100 101 108 public Group getGroup(GroupIdentifier gid) 109 { 110 return gms.getGroup(gid); 111 } 112 113 125 public ArrayList send(Serializable msg, GroupIdentifier gid, ArrayList members) 126 throws ChannelException, NotConnectedException 127 { 128 ArrayList failed = super.send(msg, gid, members); 129 if (failed != null) 130 { for (int i = 0; i < failed.size(); i++) 132 gms.quitMember((Member) failed.get(i), gid); 133 } 134 return failed; 135 } 136 137 } | Popular Tags |