Ajouter un commentaire

Prototype d'interface Java <=> 4GL (1/2)

Dans le cadre de la mise en place du site d'e-commerce d'une filiale, j'ai pu travailler sur la refonte des interfaces Java <-> Back Office.

En effet, actuellement, le site d'e-commerce de la filiale France communique avec l'ensemble des magasins. Le futur site internet de la Suisse communiquera de la même manière avec l'ensemble des magasins Suisses.

Ayant une bonne connaissance de l'existant pour la France, il était clair qu'une refonte était necessaire pour le futur site, ceci pour reprendre la main sur la maintenance des interfaces ainsi que pour garantir un meilleur niveau de performances. Compte tenu des enjeux du Web, une montée en puissance des flux temps rééls n'est pas à exclure. Il était donc impossible de partir sur les interfaces existantes...

Deux solutions ont été envisagées :

  1. Attaquer les programmes 4GL au travers de Java en utilisant JNI
  2. Trouver une autre solution en cas d'impossibilité... :)

J'ai donc commencé par la solution 1 (;), on trouve plein de tutos sur le net concernant JNI, en gros c'est super simple, il faut créer une méthode native qui sera le déclencheur de l'appel à la fonction C. Ensuite on appelle l'utilitaire javah sur la classe créée afin de générer le fichier prototype (.h) qui sera utilisé dans le programme C :

public class TestJNI {
   static {
     System.loadLibrary("testjni");
   }
   private native void helloWorld();
   private native void processMessage(String aMessageId);
   public static void main(String[] args) {
     new TestJNI().helloWorld();
     new TestJNI().processMessage("bidon");
   }
 }

Le fichier .h généré est de la forme :

/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class TestJNI */
 
#ifndef _Included_TestJNI
#define _Included_TestJNI
#ifdef __cplusplus
extern "C" {
#endif
/*
 * Class:     TestJNI
 * Method:    processMessage
 * Signature: (Ljava/lang/String;)V
 */
JNIEXPORT void JNICALL Java_TestJNI_processMessage
  (JNIEnv *, jobject, jstring);
 
/*
 * Class:     TestJNI
 * Method:    helloWorld
 * Signature: ()V
 */
JNIEXPORT void JNICALL Java_TestJNI_helloWorld
  (JNIEnv *, jobject);
 
#ifdef __cplusplus
}
#endif
#endif

Bon, donc voilà pour la partie Java, reste à développer un petit programme C qui implémente les deux fonctions :

/* testjni.c */
 
#include <jni.h>
#include "testjni.h"
#include <fglapi.h>
#include <fglsys.h>
 
JNIEXPORT void JNICALL Java_TestJNI_print
  (JNIEnv *env, jobject obj) {
    printf("COUCOU !!\n");
    return;
}
 
void appel4GL() {
    fgl_start();
 
    int1 res[80];
 
    printf("AVANT PUSH\n");
    ibm_lib4gl_pushQuotedStr(res, strlen(res));
 
    printf("AVANT get_server_today\n");
    fgl_call(get_server_today, 0);
 
    printf("AVANT POP\n");
    ibm_lib4gl_popQuotedStr(res, 80);
 
    printf("get_server_today: %s\n", res);
 
    free(res);
 
    fgl_end();
}
 
JNIEXPORT void JNICALL Java_TestJNI_processMessage
  (JNIEnv *env, jobject obj, jstring str) {
    /* Get the native string from str */
    const char *nativeString = (char *) GetStringUTFChars(env, str, 0);
    printf("ID message : %s\n", nativeString);
    /* DON'T FORGET THIS LINE!!! */
    ReleaseStringUTFChars(env, str, nativeString);
    appel4GL();
}
 
int main()
{
    printf("COUCOU !!\n");
    appel4GL();
    return 0;
}

Je vais tuer tout de suite le suspens inhérent à la mise en œuvre de tout ça, une fois que j'ai eu vaincu les directives de compilation et donc compilé mes petits programmes... ... ...Ça ne marche pas...

Chaque appel aux fonctions 4GL au travers de Java se solde par une erreur :

[oa@XRF4]  : java -Djava.compiler=NONE -Djava.library.path=$LIBPATH
COUCOU !!
ID message : bidon
Unhandled exception
Type=Illegal instruction vmState=0x00040000
J9Generic_Signal_Number=00000010 Signal_Number=00000004 Error_Value=00000000 Signal_Code=0000001e
Handler1=F10FF238 Handler2=F10FB064
R0=00000000 R1=2FF21300 R2=00000000 R3=2FF21340
R4=00000001 R5=F0FD85CC R6=00000000 R7=4D343000
R8=3430004D R9=00008000 R10=7F7F7F7F R11=00000003
R12=00000000 R13=30151900 R14=3017FBF8 R15=304A5A9C
R16=00000007 R17=00000000 R18=F1100F48 R19=30151940
R20=3047E260 R21=3017FC10 R22=00000000 R23=DEADBEEF
R24=1000F868 R25=30000330 R26=30151900 R27=300105A8
R28=EC065B50 R29=0000007E R30=00000001 R31=00000001
IAR=00000000 LR=D31B8BC0 MSR=0000D0B2 CTR=00000000
CR=22424284 FPSCR=82008000 XER=00000000 TID=00000000
MQ=DEADBEEF
FPR0 4a39524f4d434c41 (f: 1296256128.000000, d: 3.700745e+49)
FPR1 5353434f4f4b4945 (f: 1330334080.000000, d: 2.511314e+93)
FPR2 c1e0000000000000 (f: 0.000000, d: -2.147484e+09)
FPR3 408f400000000000 (f: 0.000000, d: 1.000000e+03)
FPR4 4330080000000000 (f: 0.000000, d: 4.512396e+15)
FPR5 3f60624de0000000 (f: 3758096384.000000, d: 2.000000e-03)
FPR6 3ff0000000000000 (f: 0.000000, d: 1.000000e+00)
FPR7 0000000000000000 (f: 0.000000, d: 0.000000e+00)
FPR8 0000000000000000 (f: 0.000000, d: 0.000000e+00)
FPR9 0000000000000000 (f: 0.000000, d: 0.000000e+00)
FPR10 0000000000000000 (f: 0.000000, d: 0.000000e+00)
FPR11 4030000000000000 (f: 0.000000, d: 1.600000e+01)
FPR12 3fe8000000000000 (f: 0.000000, d: 7.500000e-01)
FPR13 4028000000000000 (f: 0.000000, d: 1.200000e+01)
FPR14 0000000000000000 (f: 0.000000, d: 0.000000e+00)
FPR15 0000000000000000 (f: 0.000000, d: 0.000000e+00)
FPR16 0000000000000000 (f: 0.000000, d: 0.000000e+00)
FPR17 0000000000000000 (f: 0.000000, d: 0.000000e+00)
FPR18 0000000000000000 (f: 0.000000, d: 0.000000e+00)
FPR19 0000000000000000 (f: 0.000000, d: 0.000000e+00)
FPR20 0000000000000000 (f: 0.000000, d: 0.000000e+00)
FPR21 0000000000000000 (f: 0.000000, d: 0.000000e+00)
FPR22 0000000000000000 (f: 0.000000, d: 0.000000e+00)
FPR23 0000000000000000 (f: 0.000000, d: 0.000000e+00)
FPR24 0000000000000000 (f: 0.000000, d: 0.000000e+00)
FPR25 0000000000000000 (f: 0.000000, d: 0.000000e+00)
FPR26 0000000000000000 (f: 0.000000, d: 0.000000e+00)
FPR27 0000000000000000 (f: 0.000000, d: 0.000000e+00)
FPR28 0000000000000000 (f: 0.000000, d: 0.000000e+00)
FPR29 0000000000000000 (f: 0.000000, d: 0.000000e+00)
FPR30 0000000000000000 (f: 0.000000, d: 0.000000e+00)
FPR31 0000000000000000 (f: 0.000000, d: 0.000000e+00)
Target=2_30_20070420_12448_bHdSMR (AIX 5.3)
CPU=ppc (4 logical CPUs) (0x80000000 RAM)
JVMDUMP006I Processing Dump Event "gpf", detail "" - Please Wait.
JVMDUMP007I JVM Requesting System Dump using '/var/oa/v3/core.20081125.102624.245960.dmp'
JVMDUMP010I System Dump written to /var/oa/v3/core.20081125.102624.245960.dmp
JVMDUMP007I JVM Requesting Snap Dump using '/var/oa/v3/Snap0002.20081125.102624.245960.trc'
JVMDUMP010I Snap Dump written to /var/oa/v3/Snap0002.20081125.102624.245960.trc
JVMDUMP007I JVM Requesting Java Dump using '/var/oa/v3/javacore.20081125.102624.245960.txt'
JVMDUMP010I Java Dump written to /var/oa/v3/javacore.20081125.102624.245960.txt
JVMDUMP013I Processed Dump Event "gpf", detail "".
[oa@XRF4]  : 

...la suite dans un prochain billet ;)

Filtered HTML

  • Flickr Filter options. expand / collapse
    Insert a Flickr photo. A working example:
    • [flickr-photo:id=7357144724, size=m, mintitle=999, minmetadata=999] (accepts only the parameters id, class, style, size, mintitle and minmetadata)
    To float single photos use [flickr-photo:id=9247386562, class="floatright"], [flickr-photo:id=9247388074, style="float:left;"] or use the AutoFloat module (recommended).

    Insert a Flickr album. Working examples:
    • [flickr-photoset:id=72157634563269642, size=s, num=8, tags=kids/men, media=all, sort=random, count=false, mintitle=999, minmetadata=999, heading=none]
    • [flickr-gallery:id=72157648989290536, size=q, num=4, sort=views]
    • [flickr-group:id=91484156@N00, size=q, num=8, tags=flowers, media=all, sort=random, count=false, mintitle=999, minmetadata=999, heading=none]
    • [flickr-user:id=lolandese1, size=q, num=6, tags=kids/men, media=all, sort=random, count=false, mintitle=999, minmetadata=999, heading=none]
    • [flickr-user:id=public, size=q, num=10,tags=Augusto Canario, filter=interesting, sort=views, extend=true]
    • [flickr-user:id=public, size=q, num=8,location=48.867556/2.364088, date=2015-01-11, filter=interesting, sort=views]
    • [flickr-favorites:id=lolandese, size=q, num=4, tags=tomosborn/people, media=all, sort=random, count=false, mintitle=999, minmetadata=999, heading=none]

    Common sizes:
    s : small square 75
    t : thumbnail, 100 on longest side
    q : big square 150
    m : small, 240 on longest side
    n : small, 320 on longest side
    - : medium, 500 on longest side
    x: Responsive slideshow (for group, set and user IDs only)
    y: Basic responsive slideshow (for set and user IDs only)
    The 'c' size (800px) is missing on Flickr images uploaded before March 1, 2012. Photos with non existing sizes will be skipped in albums.

    TIP: Not only the node body but also blocks make use of a text format. Build your own custom Flickr album block using the Flickr Filter syntax.

    PARAMETER EXAMPLES. Omitting a parameter will result in the default value to be used.
    id=lolandese1 : A photo, set, user or group ID. id=public grabs CC licensed public photos (only for [flickr-user:...]). Default: id=k4cy (set in config).
      Find a Flickr group ID. Valid ID values: numeric ID (the one that contains a '@'), path alias, Flickr username or the user's email.
    class="floatleft foo bar" : Syntax as in HTML. Wrap the value in quotes (or not) and put spaces between multiple classes.
      Applies to the outer HTML element of a photo or album.
    style="float:left; border:solid 2px;" : Syntax as in HTML. Wrap the value in quotes (or not) and put semicolons between different style declarations.
      Applies to the outer HTML element of a photo or album.
    size=q : Big square (150px). The sizes x and y display a slideshow and ignore number, media, tags, location and sort settings.
      Default single photo: size=m, album photo: size=s (both set in config).
    num=4 : Display 4 photos. Default: num=30 (set in config). For albums only.
      If set to 1, the single image will behave as such. Heading and counter will be omitted, and float might apply.
      Used to display a single changing random or recent image.
    media=all : Display both photos and videos. Default: media=photos. For albums only.
    tags=kids/men : Separate multiple tags with a slash (/). Display all set, group or user photos that contain the indicated tags.
      Case insensitive, matches any tag, for photosets and galleries even partial. You can exclude results that match a term by prepending it with a - character.
      Public albums will only display photos that match all tags. Like on Flickr spaces are removed from tags (e.g. 'Victoria park' becomes 'victoriapark').
      For albums only.
    extend=true : Extend the tag filter to search for matching terms also in the Flickr photo title and description besides Flickr tags.
      Default: extend=true (set in config). For albums only.
    tag_mode=all : Matches 'all' defined tags (AND). The other possible value is 'any' (OR).
      If this parameter is omitted, 'all' is used if no Flickr user ID is known (public search), otherwise 'any' is used. For albums only.
    location=48.85837/2.294481/0.2 : Display photos within 200 mt from the Eiffel Tower. Lat/lon/radius (in km). Separate values with a slash (/).
      To get the coordinates for a location, right-click on a Google map and choose 'What's here?' or copy/paste it from the URL.
      Substitute the comma (,) with a slash (/). Optionally add a radius to force a major number of results to filter on (max. 32 km).
      If the radius is omitted it defaults to 14 meter and gradually expands to 32 km until a sufficient number of results are returned.
      Besides decimal coordinates also degrees are accepted, e.g. 2° 21' 50.72". For user and group albums only, also public.
    date=2015-01-11 : Display photos taken on 11 January 2015.
      Many accepted date formats (e.g. '11 Jan 2015'), also relative formats (e.g. 'first day of last month | last day of last month').
      Separate two date values with a vertical bar (|) to cover a timespan of multiple days. For user and group albums only, also public.
      Tip: Use a date in combination with a location to grab public photos of an event.
    heading=h3 : Wraps the album title in HTML tags. Use 'p' to apply no style or 'none' to suppress the title. Default heading=p (set in config). For albums only.
    sort=views : Display the most viewed Flickr photos first (popularity, slower response after cache clear).
      Other values: unsorted = recent as delivered by the Flickr API (fastest response),
      random (slower response after cache clear), taken (newest first), posted (newest first) , added (for groups only, newest first) and id (on photo ID, newest first).
      Default: sort=unsorted. For albums only.
    filter=interesting : Display the most interesting photos. Other possible value: relevant. For user and group albums only, also public.
    count=false : Suppress display of the counter under the album (e.g. 5 out of 124 on Flickr). Default: count=true (set in config). For albums only.
    mintitle=999 : Suppress display of the title in the photo captions for images below a width of 999 px. Default: mintitle=100 (set in config).
    minmetadata=999 : Suppress display of the metadata in the photo captions for images below a width of 999 px. Default: minmetadata=150 (set in config).
  • Tags HTML autorisés : <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <img> <p> <code> <bash> <java> <apache>
  • Les lignes et les paragraphes vont à la ligne automatiquement.
  • Vous pouvez activer la coloration syntaxique du code source à l'aide des balises suivantes: <code>, <blockcode>, <apache>, <bash>, <html>, <ini>, <java>, <php>, <properties>, <sql>. The supported tag styles are: <foo>, [foo].
  • Les adresses de pages web et de courriels sont transformées en liens automatiquement.

Plain text

  • Aucune balise HTML autorisée.
  • Les adresses de pages web et de courriels sont transformées en liens automatiquement.
  • Les lignes et les paragraphes vont à la ligne automatiquement.
CAPTCHA
Cette question permet de s'assurer que vous êtes un utilisateur humain et non un logiciel automatisé de relou.
3 + 5 =
Trouvez la solution de ce problème mathématique simple et saisissez le résultat. Par exemple, pour 1 + 3, saisissez 4.