swarm-support
[Top][All Lists]
Advanced

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

Re: [Swarm-Support] Java swarm help with Log File


From: durga bhavani
Subject: Re: [Swarm-Support] Java swarm help with Log File
Date: Wed, 9 Nov 2005 00:39:33 -0800 (PST)

Hello
 
This program really makes sense
but when i am trying to add one more method it doesn't do anything
I did declraed a new selector,
Selector sel2=null;
leaderList.add(new MyMathsClass1());
changed to modelActions.createActionTo$message (leaderList.get(1), sel2);
 modelActions.createActionTo$message (leaderList.get(1), sel2);
 
Thanks a lot
Durga


"Marcus G. Daniels" <address@hidden> wrote:
durga bhavani wrote:
> Could you please clear the idea of adding methods to the list and
> also the objects that are in the leaderlist should have the method
> which I have to call
>
> I am very new to Java swarm could you please provide an example for
> the same
Here is an example that illustrates the difference between a List target
(ForEach send) and a simple target.


import swarm.SwarmEnvironmentImpl;
import swarm.Globals;
import swarm.defobj.Zone;
import swarm.activity.ActionGroupImpl;
import swarm.activity.ActionGroup;
import swarm.activity.Activity;
import swarm.objectbase.SwarmImpl;
import swarm.objectbase.Swarm;
import swarm.Selector;

import java.util.LinkedList;
import java.util.List;

public class TestList extends SwarmImpl {
List leaderList;
ActionGroup modelActions;

class MyMathsClass{
public int addEmUp(){
int i,j;
int value=0;
for(i=0;i<10;i++){
for(j=0;j<10;j++){
value=i+j;
}
}
System.out.println ("addEmUp result:" + value);
return value;
}
}

public Object buildObjects () {
super.buildObjects ();

leaderList = new LinkedList ();
leaderList.add (new MyMathsClass ());
return this;
}

public Object buildActions () {
super.buildActions ();
Selector sel = null;

try {
sel = new Selector (MyMathsClass.class, "addEmUp", false);
} catch (Exception e) {
System.exit (1);
}
modelActions = new ActionGroupImpl (this);
modelActions.createActionForEach$message (leaderList, sel);
modelActions.createActionTo$message (leaderList.get(0), sel);
return this;
}

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

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

TestList (Zone aZone) {
super (aZone);
}

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

Swarm swarm = new TestList (Globals.env.globalZone);
swarm.buildObjects ();
swarm.buildActions ();
swarm.activateIn (null).run();
}
}
_______________________________________________
Support mailing list
address@hidden
http://www.swarm.org/mailman/listinfo/support


Yahoo! FareChase - Search multiple travel sites in one click.
reply via email to

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