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: Thu, 16 Dec 1999 10:08:39 -0500


>>>>> "JR" == Juan A Rodriguez <address@hidden> writes:

JR> The crash rises when invoking at$createActionTo$message for a
JR> given shedule.

>>Would you try today's DLL/swarm.jar in
>>ftp://ftp.santafe.edu/pub/swarm/2.0.1-fixes?

>>The source is ftp://ftp.santafe.edu/pub/swarm/testing/swarm-1999-12-15.tar.gz.

I tried the example below and it doesn't work for me. I get the same exception.
I'm using linux. I guess that the dll is a windows thing, am I right?
I guess also that all I have to do is to copy the .jar file and try again, am I 
right?
At least I know now that the code is right and there's something wrong with my 
installation.
Thanks.


juan

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

Here's a test-case that works for me:

import swarm.Globals;
import swarm.Selector;
import swarm.objectbase.SwarmObjectImpl;
import swarm.objectbase.SwarmImpl;
import swarm.objectbase.Swarm;
import swarm.activity.Schedule;
import swarm.activity.ScheduleImpl;
import swarm.activity.Activity;
import swarm.defobj.Zone;

public class TestSelectorSwarm extends SwarmImpl {
  class Agent {
    public Object idHandleEvent (Integer event, Long time) {
      System.out.println (this + " handling event " + event.toString () + 
                          " at time " + time.toString ());
      return this;
    }
  }
  Agent agent;
  Schedule modelSchedule;
  
  public TestSelectorSwarm (Zone aZone) {
    super (aZone);
  }

  public Object buildObjects () {
    super.buildObjects ();
    agent = new Agent ();
    return this;
  }

  public Object buildActions () {
    super.buildActions ();
    modelSchedule = new ScheduleImpl (getZone (), true);
    Integer a = new Integer (1);
    Long b = new Long (2);
    
    try {
      modelSchedule.at$createActionTo$message
        (0, agent,
         new Selector (agent.getClass (), "idHandleEvent", false),
         (Object) a, (Object) b);
    } catch (Exception e) {
      e.printStackTrace (System.err);
    }
    return this;
  }

  public Activity activateIn (Swarm swarmContext) {
    super.activateIn (swarmContext);

    modelSchedule.activateIn (this);
    return getActivity ();
  }

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

    TestSelectorSwarm testSelectorSwarm =
      new TestSelectorSwarm (Globals.env.globalZone);
    
    testSelectorSwarm.buildObjects ();
    testSelectorSwarm.buildActions ();
    testSelectorSwarm.activateIn (null);
    testSelectorSwarm.getActivity ().run ();
  }
}

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