FileDocCategorySizeDatePackage
CollaboratorMessage.javaAPI DocExample1570Tue Jan 20 22:26:42 GMT 1998dcj.util.Collaborative

CollaboratorMessage

public class CollaboratorMessage extends Message
Source code from "Java Distributed Computing", by Jim Farley. Class: CollaboratorMessage Example: 9-8 Description: A message used by collaborators.

Fields Summary
protected Collaborator
collaborator
Constructors Summary
public CollaboratorMessage(Collaborator c)


     
    collaborator = c;
  
public CollaboratorMessage(String mid)

    super(mid);
  
Methods Summary
public booleanDo()

    boolean success = false;

    try {
      String mtype = messageID();
      Identity from = (Identity)getArg(0);
      try {
        String s = (String)getArg(1);
        collaborator.notify(mtype, s, from);
        success = true;
      }
      catch (ClassCastException cce) {
        // Argument isn't a string, so send it as an object
        Object oarg = getArg(1);
        collaborator.notify(mtype, oarg, from);
        success = true;
      }
    }
    catch (Exception e) {
      success = false;
    }
    return success;
  
public booleanhandles(java.lang.String msgId)

 return true; 
public MessagenewCopy()

    CollaboratorMessage copy;
    if (collaborator != null) {
      // Make a new CollaboratorMessage with the same Collaborator
      copy = new CollaboratorMessage(collaborator);
      copy.setId(messageID());
    }
    else {
      copy = new CollaboratorMessage(messageID());
    }
    return copy;