Technology
 

Simple Indus Program

From Indus Communities

Agents and Components are new reference types in Indus.

Agents represent objects that are active, that is, they control their own thread of execution. Components represent objects that are passive, that is, they are static abstractions that are not context aware and can be reused in different execution contexts. Read more about Agent implementation types and Component implementation types

Any application implemented in Indus need to be modeled as and later implemented as a set of concurrently executing Agents that communicate and coordinate with each other. Agents reuse Components to implement static functionality.

Agents are easy to implement. Define what the Agent does in an Agent definition file and then author the Class that implements the Agent.

Example 1 : Writing the first Agent

Agent Teacher{
	public String SayHello();
}

File : Teacher.indus

public class Class_Teacher implements Teacher{
	
	Context{
		// set the implementation type of MyTeacher
		setServantType("USER");
	}
	
public static void main(String[ ] args){
		Class_Teacher Physics = newType Class_Teacher(args[0]);
		String hi = Physics.SayHello( );
		System.out.println(hi);
	}
	
public String SayHello(){
		return "Hi ! I am your new Physics teacher";
	}

}

File : Class_Teacher.Indus

Note : Agent definitions and implementations have to be present in separate files.

Next : Compile and Run an Indus program