Methods Summary |
---|
public boolean | broadcast(Identity from, java.lang.String mtag, java.lang.String msg)
System.out.println("Broadcasting...");
boolean success = true;
Enumeration ids;
synchronized (clients) {
ids = clients.keys();
}
RMICollaborator target = null;
while (ids.hasMoreElements()) {
Identity i = (Identity)ids.nextElement();
synchronized (clients) {
target = (RMICollaborator)clients.get(i);
}
synchronized (target) {
if (target == null ||
!target.notify(mtag, msg, from)) {
success = false;
}
}
}
return success;
|
public boolean | broadcast(Identity from, java.lang.String mtag, java.lang.Object data)
boolean success = true;
Enumeration ids;
synchronized (clients) {
ids = clients.keys();
}
RMICollaborator target = null;
while (ids.hasMoreElements()) {
Identity i = (Identity)ids.nextElement();
synchronized (clients) {
target = (RMICollaborator)clients.get(i);
}
synchronized (target) {
if (target == null ||
!target.notify(mtag, data, from)) {
success = false;
}
}
}
return success;
|
protected RMICollaborator | getMember(Identity i)
Enumeration ids;
synchronized (clients) {
ids = clients.keys();
}
RMICollaborator c = null;
Identity tmp;
while (c == null && ids.hasMoreElements()) {
tmp = (Identity)ids.nextElement();
if (tmp.equals(i)) {
synchronized (clients) {
c = (RMICollaborator)clients.get(tmp);
}
}
}
return c;
|
public java.util.Vector | getMembers()
synchronized (idList) {
return (Vector)idList.clone();
}
|
public static void | main(java.lang.String[] argv)
// Install a security manager
System.setSecurityManager(new RMISecurityManager());
try {
String name = "TheMediator";
System.out.println("Registering RMIMediatorImpl as \""
+ name + "\"");
RMIMediatorImpl mediator = new RMIMediatorImpl();
System.out.println("Created mediator, binding...");
Naming.rebind(name, mediator);
System.out.println("Remote mediator ready...");
}
catch (Exception e) {
System.out.println("Caught exception while registering: "
+ e);
}
|
public Identity | newMember()
int max = -1;
boolean found = true;
Enumeration enum = idList.elements();
// Find max identity num given out thus far
while (enum.hasMoreElements()) {
Identity id = (Identity)enum.nextElement();
int i = id.getId();
if (i > max) {
max = i;
}
}
// New identity
Identity newId = new Identity(max + 1);
synchronized (idList) {
idList.addElement(newId);
}
return newId;
|
public boolean | register(Identity i, RMICollaborator c)
System.out.println("Registering member " + i.getId()
+ " as " + c.getIdentity().getName());
clients.put(i, c);
return true;
|
public boolean | remove(Identity i)
boolean success = true;
synchronized (idList) {
synchronized (clients) {
if (idList.removeElement(i) && clients.remove(i) != null) {
success = true;
}
else {
success = false;
}
}
}
return success;
|
public boolean | send(Identity to, Identity from, java.lang.String mtag, java.lang.String msg)
boolean success = false;
RMICollaborator c = getMember(to);
synchronized (c) {
if (c != null) {
success = c.notify(mtag, msg, from);
}
}
return success;
|
public boolean | send(Identity to, Identity from, java.lang.String mtag, java.lang.Object data)
boolean success = false;
RMICollaborator c = getMember(to);
synchronized (c) {
if (c != null) {
success = c.notify(mtag, data, from);
}
}
return success;
|