Technology
 

Component Implementation types

From Indus Communities

Components are static abstractions that express reusable logic.

In Indus, components are used by agents to implement functionality. Like agents, components too are defined separately in a file before being implemented by an Indus class.

Agents and Components can also programmatically plug components together using several ‘composition styles’. Programmatic composition of components is possible through Ports in Components. A port indicates whether a component method is a producer or a consumer or both a producer and consumer of data. Composition styles in Indus use connectors that implement logic to plug component ports.

Components are different from Agents in Indus in the following ways

  • Components cannot use Coordination styles whereas Agents can use them to coordinate with other agents.
  • Components use Ports whereas Agents do not.
  • Components do not share states while Agents do.
  • Agents can be invoked from console whereas Component cannot be invoked from console.

A component in Indus may be of two implementation types:

  • Service
  • Session

An Indus component maintains the definitions that we have at present with respect to Service and Session components in J2EE. Service Components do not have any Primary key. They are not persistent and hence not History aware.

        setServantType("SERVICE"); 	//if its service type

Session Components are components that are history aware but do not have any primary key.

	setServantType("SESSION"); 	//if its Session type

Example 4: Service and Session components

  public class CallerAgent implements Caller{

	Context {
		setServantType("PROCESS");
	}

	public static void main(String[] args){
		try{
		SessionClass Session = newType SessionClass(null);
		Session.set("I am a Session Class");
		String sone = Session.get( );
		System.out.println(sone);
		String sthree = Session.setandget("I am a Session Class");
		System.out.println(sthree);
		}catch (Exception e){ }

		try{
		ServiceClass Service = newType ServiceClass(null);
		Service.set("I am a Service Class");
		String stwo = Service.get( ); //this will fetch null
		System.out.println(stwo);
                String sfour = Service.setandget("I am a Service Class"); 
                 //this will work
		System.out.println(sfour);
		}catch(Exception e){ }

		
	}
}

The above example shows the difference between Session and Service components. Set( ) and Get( ) methods work across sessions in a session component but Get( ) methods fail to procure data Set( ) in a previous session in the case of a Service component.

Next : Instantiating Agents and Components