Difference between revisions of "APAM/APAM Details/APAM Components"

From Wiki Adele Team
Jump to: navigation, search
(Callback method)
Line 49: Line 49:
=Callback method=
=Callback method=
Callback methods are called at initialization and/or disappear of the component. They can be declared in the specification or in the implementation as follow:
Callback methods are called at initialization and/or disappear of the component. They are declared in the implementation as follow:
<source lang="xml">
<source lang="xml">
<implementation name="S1Impl" classname="XY.java" specification="S1"  
<implementation name="S1Impl" classname="XY.java" specification="S1" shared="false">
   <callback onInit="start" onRemoved="stop" />
   <callback onInit="start" onRemoved="stop" />

Revision as of 18:21, 17 October 2012

Apam is based on the concept of component. Components can be of three types: Specification, Implementations and Instances, which share most of their characteristics.



A specification is a first class object that defines a set of provided and required resources (in the Java sense). Complete compositions can be designed and developed only in term of specifications.

<specification name="S2" interfaces="apam.test.S2, apam.test.AB" 
                          messages="apam.test.M1, apam.Test.M2" >

The example shows how are declared specifications. Specification S2 provides two interfaces, apam.test.S2 and apam.test.AB and produces two messages of type apam.test.M1 and apam.Test.M2. Requires resources will be discussed later !!!!!!!.


An implementation is related by an “implements” relationship with one and only one specification. An implementation is an executable entity (in Java) that implements all the resources defined by its associated specification, and that requires at least the resources required by its associated specification.

In practice, an implementation must define a main class that implements (in the Javasense) the interfaces of its specification.

<implementation name="S2Impl" specification="S2" 
                              message-methods="produceM1, produceM2"
                              interfaces="apam.test.AC" >	

In this example, the implementation S2Impl implements specification S2 and therefore provides the same interfaces (apam.test.S2 and apam.test.AB) and messages (apam.test.M1 and apam.Test.M2 ) as S2, additionally it also provides interface apam.test.AC and message apam.test.M3. Message field will be discussed alter.


An instance is related by an instanceOf relationship with one and only one implementation. An instance is a run-time entity, represented in the run-time platform (OSGi) as a set of Java objects, one of which is an instance (in the Java sense) of its associated main class implementation.

In the underlying service platform, an instance can be seen as a set of services, one for each of the associated specification resource; in Apam it is an object. Instances are essentially created automatically at run-time, but they can also be declared, as follows:

<instance name="InstS2Impl" implementation="S2Impl" >
	<property name="XY" value="false" >

When the bundle containing this declaration will be loaded, an instance called InstS2Impl of implementation S2Impl will be created with the properties indicated (here XY=false).

The group concept

As shown in the metamodel, components are related by a “group-members” relationship. A specification is a group whose members are implementations, and an implementation is a group whose members are instances.

A group-member relationship established a de facto inheritance between the group and its members. More precisely, all the characteristics of the group (its properties, its provided and requires resources) are automatically inherited by all its members, like in a class-instance relationship.

Component life cycle

During execution, in Apam, a component has a single state: it is either existing (and therefore available and active), or non-existing.

Callback method

Callback methods are called at initialization and/or disappear of the component. They are declared in the implementation as follow:

<implementation name="S1Impl" classname="XY.java" specification="S1" shared="false">
   <callback onInit="start" onRemoved="stop" />

The Java program must contain methods start and stop (names are fully arbitrary):

	    public void start () { }
/*or*/	    public void start (Instance inst) { }
	    public void stop () {}

The start method can have, as parameter, the actual Apam instance (this == inst.getServiceObject()).