A better example of Pipes

Component simulating a lot of people gossiping among themselves. public Component GossipComponent {

public Source firstgossip = String firstgossip; public Handler gossip = String gossip(String id);

}

Component definition file : GossipComponent.indus

public class Gossip implements GossipComponent {

private Map userMap = new HashMap;

Context{ setServantType("SERVICE"); }

// takes as input a string "She has an affair with x guys" // return a string "She has an affair with x+1 guys"

public String gossip(String id) {		String [] tokens = id.split(" "); int num = Integer.valueOf(tokens[5]).intValue; tokens[5] = String.valueOf(num+1); String newgossip = ""; for (int i = 0; i < tokens.length; i++) {			newgossip += tokens[i]; newgossip += " "; }				return newgossip; }

public String firstgossip {		return "She has an affair with 2 guys"; }

}

Component implementation file : Gossip.indus

The Agent that composes several gossipers.

public Agent MonitoringInterface {

public void start; }

Agent definition file : MonitoringInterface.indus

public class MonitoringPipe implements MonitoringInterface{

Context { setServantType("USER");

}

public void start{}

public static void main(String args[]){ try{ Gossip auth = newType Gossip(null); // simple pipe String gossip = auth.firstgossip -> auth.gossip; System.out.println(gossip);

// series of pipes

String gossip1 = auth.firstgossip -> auth.gossip -> auth.gossip -> auth.gossip  -> auth.gossip -> auth.gossip -> auth.gossip  -> auth.gossip -> auth.gossip -> auth.gossip; System.out.println(gossip1);

}catch(Exception e){ e.printStackTrace; }

}

}

Agent implementation file : Monitoring.indus