APAM/APAM Getting Started Tutorial/APAM Hello World

From Wiki Adele Team
< APAM‎ | APAM Getting Started Tutorial
Revision as of 14:16, 10 October 2012 by Mehdi (talk | contribs) (Run using your compiled project)

Jump to: navigation, search

Hello World Sample

In this lesson, you will manipulate basic apam components. We will create a simple Hello World Service with ApAM components.


The goal of this section is to create basic components (without composite) which provide the "Hello World" service. This service receives an input string and displays "Hello, ..." message into the standard output console.


Hello World Service

A service in ApAM is realized through a three level component model : specification, implementation and instance (for more details see the ApAM overview. In this section, we will implements the Hello World service using our three level component model.


The specification is the description the service. it contains the description of resources to be provided, like interfaces. the java interface corresponding to the Hello World service is as follow :

package fr.imag.adele.apam.hello.world.spec;

public interface HelloService {
     * Method printing text into the output console with "Hello, " prefix
     * @param texte the string received, 
    public void sayHello(String texte);

Each Specification ApAM must be described using the ApAM DSL language. This description provide information about the resources provided and required, the specification component can be customized using definitions and properties.

  <specification name="Hello-Spec" 


The implementation component is in charge to provide an the code implementation of the service. The Java class implementation corresponding to this implementation is as follows:

package fr.imag.adele.apam.hello.world.impl;

public class HelloImplementation implements HelloService{

     * @see HelloService#sayHello(String) 
    public void sayHello(String texte) {
        System.out.println("Hello, " + texte);

As Specification component, each implementation in ApAM must be described using the ApAM DSL language. This description provide information about the class implementing this component, the service provided or required.

This description is realized as follows:

  <implementation name="Hello-Impl" 

Instance Description

ApAM allow the creation of instances using a description. in our example, to create the instance of Hello-Impl the description is realized as follow :

<instance name="Hello-Inst" 
   implementation="Hello-Impl" >

Build (Compilation and Packaging)

For build process we use Maven as presented in the prevoius lesson . To launch the build of this project the command “mvn clean install” must be executed in an OS console or using a maven eclipse plugin.

If the build process ends successfully the bundle "HelloWorld-1.0.0-SNAPSHOT.jar" must be in the target directory of the project.

Use Hello World Service

Now we will create a client "TextGui" which depend on Hello World service. This client show a Gui to write a texte, then TextGui called the "Hello World service" with the entered text.



We will not explain the code of TextGui but if you want a snapshot of the code you can have look [here]

Run using the compiled bundle

Download APAM-Runtime

Install Hello-Service : copy the following command to the ApamRuntime


Install TextGui : copy the following command to the ApamRuntime


Run using your compiled project

if you have already download source code of the example, you can compile it using Maven then, Download APAM-Runtime.

tape the command :

put TextGui

Example Resources

Source code in the Git repository

Browse the Git code

Snapshot of source code

Get a snapshot of the Git project here.

List of compiled artefacts