Objectif

Avantages

Limites

Pour commencer par quelque chose de simple, ce projet se limite à la conversion des services NatStar.
La conversion du code applicatif sera traitée dans le projet n°2.

Principe

Développer une couche intermédiaire entre les programmes Java et le runtime NatStar.
C'est à dire, permettre, depuis du code Java, l'appel à du code Natif (le runtime NatStar).

Exemple de code

Voici un exemple de code NCL, et son équivalent Java.
... code NCL à insérer ...
01 /*
02  * Created on 15 november 2005
03  */
04 
05 package fr.phe.ncl2java.prototype.test;
06 
07 import fr.phe.ncl2java.runtime.types.NsCString;
08 import fr.phe.ncl2java.runtime.types.NsInt1;
09 import fr.phe.ncl2java.runtime.types.NsInt2;
10 import fr.phe.ncl2java.runtime.types.NsInt4;
11 
12 /**
13  @author Patrick Hénin
14  *
15  */
16 public class LectureDictionnaireNatstar extends NsApplication {
17 
18   public static void main(String[] args) {
19     try {
20       init();
21 
22       final NsInt2 ENTITY_LIBRARY = new NsInt2(24);
23       final NsInt2 ENTITY_CLASS = new NsInt2(1);
24 
25       NsCString szNomGlob = new NsCString(System.getenv().get("NSDICT"));
26       lireEntitesDuDictionnaire(szNomGlob, ENTITY_LIBRARY);
27       lireEntitesDuDictionnaire(szNomGlob, ENTITY_CLASS);
28 
29       done();
30     catch (Exception e) {
31       e.printStackTrace();
32     }
33   }
34 
35   static void lireEntitesDuDictionnaire(NsCString nomGlob, NsInt2 typeEntite) {
36     // --- Init dictionnaire
37     nsDict.DICT_INITIALIZE(NsInt4.zero(), NsInt2.zero(), nomGlob);
38 
39     // --- Ouverture transaction (Lecture seule)
40     NsInt2 err = nsDict.iDICT_START_TRANS(NsInt1.TRUE());
41     if (err.shortValue() == 0) {
42       NsInt4 handleEntity = NsInt4.zero();
43 
44       // --- Lecture de la première entité
45       NsInt4 handleRech = nsDict.iDICT_FIRST_ENTITY(typeEntite, handleEntity);
46       // --- Tant qu'il existe des entités...
47       while (handleRech.intValue() 0) {
48         NsInt4 idEnt = NsInt4.zero();
49         NsCString nEnt = NsCString.empty();
50         NsCString descr = NsCString.empty();
51         NsInt2 dataSize = NsInt2.zero();
52         NsInt4 data = NsInt4.zero();
53         // --- Récupérer les informations sur l'entité
54         nsDict.DICT_INFOS_ENTITY(handleEntity, idEnt, new NsInt2(), nEnt, descr, dataSize, data);
55         nsThform.THINGS_TRACE("Nom entité:" + nEnt);
56         nsThform.THINGS_TRACE("Handle rech:" + handleRech);
57         nsThform.THINGS_TRACE("Handle entité:" + Integer.toHexString(handleEntity.intValue()) " " + handleEntity);
58         nsThform.THINGS_TRACE("Descr:" + descr);
59         // --- Passer à l'entité suivante
60         handleRech = nsDict.iDICT_NEXT_ENTITY(typeEntite, handleEntity, handleRech);
61       }
62     else
63       nsThform.THINGS_TRACE("erreur ouverture transaction");
64 
65     // --- Fin utilisation du dictionnaire
66     nsDict.DICT_TERMINATE();
67   }
68 }