1 3 package org.jgroups.protocols; 4 5 import org.jgroups.Event; 6 import org.jgroups.Message; 7 import org.jgroups.View; 8 import org.jgroups.stack.Protocol; 9 10 import java.io.Serializable ; 11 import java.util.Vector ; 12 13 14 15 class ExampleHeader implements Serializable { 16 18 public ExampleHeader() { 19 } 20 21 public String toString() { 22 return "[EXAMPLE: <variables> ]"; 23 } 24 } 25 26 27 30 31 public class EXAMPLE extends Protocol { 32 final Vector members=new Vector (); 33 34 35 public String getName() {return "EXAMPLE";} 36 37 38 39 40 41 42 public void reset() {} 43 44 45 46 47 public void up(Event evt) { 48 Message msg; 49 50 switch(evt.getType()) { 51 52 case Event.MSG: 53 msg=(Message)evt.getArg(); 54 break; 57 } 58 59 passUp(evt); } 61 62 63 64 65 66 public void down(Event evt) { 67 Message msg; 68 69 switch(evt.getType()) { 70 case Event.TMP_VIEW: 71 case Event.VIEW_CHANGE: 72 Vector new_members=((View)evt.getArg()).getMembers(); 73 synchronized(members) { 74 members.removeAllElements(); 75 if(new_members != null && new_members.size() > 0) 76 for(int i=0; i < new_members.size(); i++) 77 members.addElement(new_members.elementAt(i)); 78 } 79 passDown(evt); 80 break; 81 82 case Event.MSG: 83 msg=(Message)evt.getArg(); 84 break; 87 } 88 89 passDown(evt); } 91 92 93 94 } 95 | Popular Tags |