swarm-support
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

selectors in Java


From: Marcus G. Daniels
Subject: selectors in Java
Date: Wed, 15 Dec 1999 12:44:43 -0700 (MST)

JR> I've changed that but I still get the same exception.

Strange, it works for me.  The only thing that comes to mind
is that maybe you have Agent in another package?  Note that
the string you give to Class.forName should include the package. 
(I used getClass, since I had the object handy.)

import swarm.Globals;
import swarm.Selector;
import swarm.objectbase.SwarmObjectImpl;

public class TestSelector {
  class Agent extends SwarmObjectImpl {
    public Object idHandleEvent (Integer event, Long time) {
      System.out.println (this + " handling event " + event.toString () + 
                          " at time " + time.toString ());
      return this;
    }
  }

  public TestSelector () {
    Integer a = new Integer (1);
    Long b = new Long (2);
    Agent agent = new Agent ();

    try {
      agent.perform$with$with
        (new Selector (agent.getClass (), "idHandleEvent", true),
         (Object) a, (Object) b);
    } catch (Exception e) {
      e.printStackTrace (System.err);
    }
  }

  static public void main (String args []) {
    Globals.env.initSwarm ("TestSelector", "0.0", "address@hidden", args);

    new TestSelector ();
  }
}

                  ==================================
   Swarm-Support is for discussion of the technical details of the day
   to day usage of Swarm.  For list administration needs (esp.
   [un]subscribing), please send a message to <address@hidden>
   with "help" in the body of the message.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]