swarm-support
[Top][All Lists]
Advanced

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

Re: selectors in Java


From: Juan A Rodriguez
Subject: Re: selectors in Java
Date: Wed, 15 Dec 1999 15:44:28 -0500


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.)


The example below works for me also. I've also tried adding actions to a 
schedule of methods with no arguments and that works fine also (so it's not a 
problem with packages). The exception is exclusively risen when considering 
methods including arguments. I dont't have a clue (why methods without 
arguments in the very same object work and methods with arguments don't?) but I 
keep trying to figure out what's going on. 
 
Tones of thanks.

---------------------------------------------------------------------------------

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.




                  ==================================
   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]