APAM/APAM Details/APAM OBR Interaction

From Wiki Adele Team
< APAM‎ | APAM Details
Revision as of 13:21, 10 January 2013 by Mehdi (talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
This APAM Wiki is no longer maintained. Please switch to the following github Wiki for newest APAM information:
http://github.com/AdeleResearchGroup/ApAM/wiki



Any component definition can make references to other components (provided resources, dependencies, property definitions and so on). In order to compile a component, the definition of these other Apam components must made available to be read.

Compilation

For building APAM projects we use the Apache Maven project management software. Maven compiles the Java code, adds the appropriated metadata to the components and creates OSGi standard bundles (jar files). To have an idea about Maven you can follow the Maven in 5 minutes tutorial.

To use ApAM plugin in your maven project you have to add the following repository :

  <!-- Repositories List -->
 
  <pluginRepositories>
    <pluginRepository>
      <id>apam-plugin-repository</id>
      <url>https://repository-apam.forge.cloudbees.com/snapshot/</url>
      <snapshots>
	<enabled>true</enabled>
      </snapshots>
    </pluginRepository>
  </pluginRepositories>

Default behavior

Apam does its best to synchronize the Maven and the Obr repositories when compiling. By default, these definitions will be searched in the default Maven repository which is supposed to contain the OBR repository (i.e. the “repository.xml” file). If using the maven plugins in the usual way, there is nothing to indicate to Apam.

Customize compilation

For advanced users, if you indicate in your component .pom different Maven repositories in which your bundle will be deployed, and different OBR repositories in directories different from the Maven directories, you must also provide the information to Apam. The Obr repository can be set for in the component .pom, in the “maven-bundle-plugin” using the <obrRepository> tag as follows:

</plugin>
   <groupId>org.apache.felix</groupId>
   <artifactId>maven-bundle-plugin</artifactId>
    <configuration>
	<obrRepository>
           file:/…/apamRepo.xml
	</obrRepository>
    </configuration>
</plugin>

Apam will use the same repository, nothing more is needed if all the components are in this repository. However, if more than one repository are needed, you should use the <dependencyObrList> tag in the “ApamMavenPlugin “ as follows:

<plugin>
    <groupId>fr.imag.adele.apam</groupId>
    <artifactId>ApamMavenPlugin</artifactId>
       <configuration>
         <noLocalObr>true</noLocalObr>
         <dependencyObrList>
            <param>file:/F:/Maven/.m2/repository.xml</param>
	    <param>http:/…. /repository.xml</param>
	    <param>https:… </param>
	</dependencyObrList>
       </configuration>
</plugin>

The <noLocalObr> tag indicates if the Maven local repository should be considered. By default the value is false.

At compilation, the Apam Maven plug-in adds in the OBR repository all the attributes initialized, the default values and the final attributes, exactly in the same way as found in Apam ASM. Therefore the filter indicated in a resolution can find the right component, in the same way, in the ASM or in the Obr repository. The Apam Maven plug-in also adds in the OBR repository the dependency toward the provided specification, along with the right version.

Runtime : Execution and OBR repositories

At execution, Apam (more exactly managers like OBRMan), can deploy dynamically Apam components (more exactly the bundles containing these components) potentially from remote repositories. These managers receive their model each time a composite type is deployed, and should resolve the dependencies with respect to the current composite type model.

In the special case of ObrMan, the model associated with composite type “Compo” is found in the file location “${basedir}/src/main/resources/Compo.ObrMan.cfg”.

That file has the following syntax:

LocalMavenRepository=[true | false]
DefaultOSGiRepositories=[true | false]
Repositories=http:/……../repository.xml \
 File:/F:/…… \
 https:/…..
Composites=S1CompoMain CompoXY …

Attribute LocalMavenRepository is a Boolean meaning if yes or not, the local Maven repository, if existing, should be considered. Attribute DefaultOSGiRepositories is a Boolean meaning if yes or not, the Obr repository mentioned in the OSGi configuration should be considered. Attribute Repositories is a list, space separated, of OBR repository files to consider. The order of this list defines the priority of the repositories. Attribute Composites is a list, space separated, of Apam composite types. It means that the repositories defined for that composite type should be considered. The order of this list defines the priority of composites repositories. These composites must be present in Apam at the time the composite is installed, they are ignored otherwise.

The list of repositories defined by this file is the list of repositories to associate with that composite type.

The order of the attributes in the file defines the priority in which the resolution will be done by the OBR, for example:

In this model:

LocalMavenRepository=true
DefaultOSGiRepositories=true
Repositories=http:/……../repository.xml 
Composites=S1CompoMain

First, we will check the LocalMavenRepository, then DefaultOSGiRepositories then Repositories and finally Composites.

The default models associated with the Apam root composite type are found in the OSGi platform under directory “./conf/root.OBRMAN.cfg”. If this file is missing, its content is assumed to be LocalMavenRepository=true DefaultOSGiRepositories=true. For composites types that do not indicate an OBRMAN.cfg model, ObrMan uses the root model.

Apam relies on the OBR mechanism for dynamically deploying the bundles containing the required packages. For that reason the Apam Maven plug-in adds in the OBR repository the dependency toward the Apam specifications, along with the right version.