Changeset 771 for trunk/zoo-project


Ignore:
Timestamp:
Jun 10, 2016, 1:40:44 AM (9 years ago)
Author:
djay
Message:

Remove the default java.library.path definition and use an optional [java] section instead (where the key java.library.path, amongst other, may be defined). Change _ function name to translate in the Java ZOO-API. Use a ogr.zoo_project package containing the ZOO class. Fix the hello-java service and update doc consequently

Location:
trunk/zoo-project
Files:
2 added
6 edited
1 moved

Legend:

Unmodified
Added
Removed
  • trunk/zoo-project/zoo-api/java/Makefile

    r612 r771  
    2020all: libZOO.${ext}
    2121
    22 ZOO.class: ZOO.java
    23         javac ZOO.java
     22org/zoo_project/ZOO.class: org/zoo_project/ZOO.java
     23        javac org/zoo_project/ZOO.java
    2424
    25 ZOO.h: ZOO.java ZOO.class
    26         javah ZOO
     25org_zoo_project_ZOO.h: org/zoo_project/ZOO.java org/zoo_project/ZOO.class
     26        javah org.zoo_project.ZOO
    2727
    28 zoo-api.o: zoo-api.c ZOO.h
     28zoo-api.o: zoo-api.c org_zoo_project_ZOO.h
    2929        gcc -fPIC -c zoo-api.c ${JAVACFLAGS} ${XML2CFLAGS} -I../../zoo-kernel/ -I../../../thirds/cgic206/
    3030
    3131libZOO.${ext}: zoo-api.o
    32         gcc zoo-api.o -shared -o libZOO.${ext} -Wl,../../zoo-kernel/service_internal.o,${JAVA_FILES},${MS_FILES}${JS_FILES}../../zoo-kernel/ulinet.o ${GDAL_LIBS} ${XML2LDFLAGS} ${PYTHONLDFLAGS} ${PERLLDFLAGS}  ${PHPLDFLAGS} ${JAVALDFLAGS} ${JSLDFLAGS} -lcrypto ${MS_LDFLAGS} ${MACOS_LD_FLAGS} -lcurl -lfcgi ${MACOS_LD_NET_FLAGS}
     32        gcc zoo-api.o -shared -o libZOO.${ext} -Wl,../../zoo-kernel//service_yaml.o,../../zoo-kernel/lex.cr.o,../../zoo-kernel/main_conf_read.tab.o,../../zoo-kernel/lex.sr.o,../../zoo-kernel/service_conf.tab.o,../../zoo-kernel/service_internal.o,../../zoo-kernel/server_internal.o,../../zoo-kernel/response_print.o,${JAVA_FILES},${MS_FILES}${JS_FILES}../../zoo-kernel/ulinet.o ${GDAL_LIBS} ${XML2LDFLAGS} ${PYTHONLDFLAGS} ${PERLLDFLAGS}  ${PHPLDFLAGS} ${JAVALDFLAGS} ${JSLDFLAGS} -lcrypto ${MS_LDFLAGS} ${MACOS_LD_FLAGS} -lcurl -lfcgi ${MACOS_LD_NET_FLAGS} -lzoo_service -lyaml
    3333
    3434clean:
    35         rm -f *${ext} *o *.h *class
     35        rm -f *${ext} *o *.h *class org/zoo_project/*.class
  • trunk/zoo-project/zoo-api/java/org/zoo_project/ZOO.java

    r766 r771  
     1package org.zoo_project;
     2
    13import java.lang.*;
    24import java.util.*;
     
    68    public static Integer SERVICE_SUCCEEDED=3;
    79    public static Integer SERVICE_FAILED=4;
    8     public static native String _(String a);
     10    public static native String translate(String a);
    911    public static native Integer updateStatus(HashMap conf,String pourcent,String message);
    1012}
  • trunk/zoo-project/zoo-api/java/zoo-api.c

    r766 r771  
    1 #include "ZOO.h"
     1#include "org_zoo_project_ZOO.h"
    22#include "service.h"
    33#include "service_internal.h"
    44#include "service_internal_java.h"
    55
    6 JNIEXPORT jstring JNICALL Java_ZOO__1
     6JNIEXPORT jstring JNICALL Java_org_zoo_1project_ZOO_translate
    77  (JNIEnv *env, jclass _class, jstring msg){
    88  const char *message =
     
    1717}
    1818
    19 JNIEXPORT jobject JNICALL Java_ZOO_updateStatus
     19JNIEXPORT jobject JNICALL Java_org_zoo_1project_ZOO_updateStatus
    2020  (JNIEnv *env, jclass _class, jobject conf, jstring pourc, jstring msg){
    2121
  • trunk/zoo-project/zoo-kernel/main_conf_read.l

    r676 r771  
    3434%}
    3535
    36 attname [a-zA-Z0-9_\-:]+
     36attname [a-zA-Z0-9_\-:.]+
    3737
    3838attvalue1       [%\*,;@a-zA-Z0-9_\-.:" "\"\'/\\\(\)\+\x41-\xff?&=]+
  • trunk/zoo-project/zoo-kernel/service_internal_java.c

    r767 r771  
    9292#endif
    9393#ifndef WIN32
    94   int nb=3+njdb;
    95 #endif
     94  int nb=2+njdb;
     95#endif
     96  int nbs[3]={0,0,0};
     97  maps* javaMap=getMaps(*main_conf,"java");
     98  if(javaMap!=NULL){
     99    nbs[0]+=count(javaMap->content);
     100  }
     101  int nbc1=0;
     102  maps* javaXMap=getMaps(*main_conf,"javax");
     103  if(javaXMap!=NULL){
     104    nbs[1]+=count(javaXMap->content);
     105  }
    96106  int nbc0=0;
    97107  maps* javaXXMap=getMaps(*main_conf,"javaxx");
    98108  if(javaXXMap!=NULL){
    99     nbc0+=count(javaXXMap->content);
    100   }
    101   int nbc1=0;
    102   maps* javaXMap=getMaps(*main_conf,"javax");
    103   if(javaXMap!=NULL){
    104     nbc1+=count(javaXMap->content);
     109    nbs[2]+=count(javaXXMap->content);
    105110  }
    106111#ifdef WIN32
    107   //#define nb (2+nbc0+nbc1)
    108   const int nb=2+nbc0+nbc1;
     112  const int nb=2+nbs[1]+nbs[2]+nbs[0];
    109113  JavaVMOption *options=(JavaVMOption*)malloc(nb*sizeof(JavaVMOption));
    110114#else
    111   JavaVMOption options[nb+nbc0+nbc1+1];
     115  JavaVMOption options[nb+nbs[1]+nbs[2]+nbs[0]+1];
    112116#endif
    113117  JavaVMInitArgs vm_args;
     
    123127#endif
    124128  int i,start;
    125   map *cursorxx=NULL;
    126   if(javaXXMap!=NULL)
    127     cursorxx=javaXXMap->content;
    128   map *cursorx=NULL;
    129   if(javaXMap!=NULL)
    130     cursorx=javaXMap->content;
    131129  options[0].optionString = oclasspath;
    132130  options[0].extraInfo=NULL;
    133131  options[1].optionString = "-server";
    134132  options[1].extraInfo=NULL;
    135   char tmp1[100];
    136   sprintf(tmp1,"-Djava.library.path=%s",cwdMap->value);
    137   fprintf(stderr,"%s\n",tmp1);
    138   options[2].optionString = tmp1;
     133#ifdef USE_JDB
     134  options[2].optionString = "-Xdebug";
    139135  options[2].extraInfo=NULL;
    140 #ifdef USE_JDB
    141   options[3].optionString = "-Xdebug";
     136  options[3].optionString = "-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=7896";
    142137  options[3].extraInfo=NULL;
    143   options[4].optionString = "-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=7896";
    144   options[4].extraInfo=NULL;
    145138#endif
    146139#ifdef WIN32
     
    148141  options[1].optionString = "-Xmx512m";
    149142#else
    150   start=3+njdb;
    151 #endif
    152   for(i=0;i<nbc0;i++){
    153     char *tmp=parseJVMXXOption(cursorxx);
     143  start=2+njdb;
     144#endif
     145  map *cursors[3]={NULL,NULL,NULL};
     146  if(javaMap!=NULL)
     147    cursors[0]=javaMap->content;
     148  if(javaXMap!=NULL)
     149    cursors[1]=javaXMap->content;
     150  if(javaXXMap!=NULL)
     151    cursors[2]=javaXXMap->content;
     152  for(i=0;i<nbs[0];i++){
     153    char *tmp=parseJVMOption(cursors[0]);
    154154    options[start+i].optionString = zStrdup(tmp);
    155155    options[start+i].extraInfo=NULL;
    156156    free(tmp);
    157     cursorxx=cursorxx->next;
    158   }
    159   for(;i<nbc1+nbc0;i++){
    160     char *tmp=parseJVMXOption(cursorx);
     157    cursors[0]=cursors[0]->next;
     158  }
     159  for(;i<nbs[0]+nbs[1];i++){
     160    char *tmp=parseJVMXOption(cursors[1]);
    161161    options[start+i].optionString = zStrdup(tmp);
    162162    options[start+i].extraInfo=NULL;
    163163    free(tmp);
    164     cursorx=cursorx->next;
     164    cursors[1]=cursors[1]->next;
     165  }
     166  for(;i<nbs[0]+nbs[2]+nbs[1];i++){
     167    char *tmp=parseJVMXXOption(cursors[2]);
     168    options[start+i].optionString = zStrdup(tmp);
     169    options[start+i].extraInfo=NULL;
     170    free(tmp);
     171    cursors[2]=cursors[2]->next;
    165172  }
    166173
     
    168175  vm_args.version = JNI_VERSION_1_6;
    169176  vm_args.options = options;
    170   vm_args.nOptions = start+nbc0+nbc1;
     177  vm_args.nOptions = start+nbs[0]+nbs[1]+nbs[2];
    171178  vm_args.ignoreUnrecognized = JNI_TRUE;
    172179
     
    209216  if (cls != NULL) {
    210217#ifdef JAVA7
    211     (*env).ExceptionClear();
     218@    (*env).ExceptionClear();
    212219    pmid=(*env).GetStaticMethodID(cls, s->name, "(Ljava/util/HashMap;Ljava/util/HashMap;Ljava/util/HashMap;)I");
    213220#else
     
    281288  (*jvm)->DestroyJavaVM(jvm);
    282289#endif
    283   for(i=0;i<nbc1+nbc0;i++){
     290  for(i=0;i<nbs[2]+nbs[1]+nbs[0];i++){
    284291    free(options[start+i].optionString);
    285292  }
     
    334341
    335342/**
     343 * Create a string containing the JVM -D* options for a given map
     344 * The result will be : -Dname=value
     345 *
     346 * @param m the map containing the option
     347 * @return a char* containing the valide JVM option (-D*)
     348 */
     349char *parseJVMOption(map* m){
     350  char *res=(char*)malloc((strlen(m->name)+strlen(m->value)+4)*sizeof(char));
     351  sprintf(res,"-D%s=%s",m->name,m->value);
     352  return res;
     353}
     354
     355/**
    336356 * Create a string containing the JVM -XX:* option for a given map
    337357 * Depending on the map' name:
     
    458478           
    459479            for(i=0;i<alen1;i++){
    460               map* vMap=getMapArray(tmp->content,"value",i);       
     480              map* vMap=getMapArray(tmp->content,"value",i);
    461481              map* sMap=getMapArray(tmp->content,"size",i);
    462482              map* mMap=getMapArray(tmp->content,tmap->value,i);
  • trunk/zoo-project/zoo-kernel/service_internal_java.h

    r580 r771  
    4545  char *parseJVMXOption(map*);
    4646
     47  char *parseJVMOption(map*);
     48
    4749  int zoo_java_support(maps**,map*,service*,maps**,maps**);
    4850
  • trunk/zoo-project/zoo-services/hello-java/HelloJava.java

    r537 r771  
    2525import java.lang.*;
    2626import java.util.*;
     27import org.zoo_project.*;
    2728
    2829public class HelloJava {
     
    3132        String v=tmp.get("value").toString();
    3233        HashMap hm1 = (HashMap)(outputs.get("Result"));
    33         hm1.put("value",ZOO._("Hello "+v+" from JAVA World !!"));
     34        hm1.put("value",ZOO.translate("Hello "+v+" from JAVA World !!"));
    3435        return ZOO.SERVICE_SUCCEEDED;
    3536    }
     
    4748        }
    4849        HashMap hm1 = (HashMap)(outputs.get("Result"));
    49         hm1.put("value",ZOO._("Hello "+v+" from JAVA World !!"));
     50        hm1.put("value",ZOO.translate("Hello "+v+" from JAVA World !!"));
    5051        return ZOO.SERVICE_SUCCEEDED;
    5152    }
Note: See TracChangeset for help on using the changeset viewer.

Search

Context Navigation

ZOO Sponsors

http://www.zoo-project.org/trac/chrome/site/img/geolabs-logo.pnghttp://www.zoo-project.org/trac/chrome/site/img/neogeo-logo.png http://www.zoo-project.org/trac/chrome/site/img/apptech-logo.png http://www.zoo-project.org/trac/chrome/site/img/3liz-logo.png http://www.zoo-project.org/trac/chrome/site/img/gateway-logo.png

Become a sponsor !

Knowledge partners

http://www.zoo-project.org/trac/chrome/site/img/ocu-logo.png http://www.zoo-project.org/trac/chrome/site/img/gucas-logo.png http://www.zoo-project.org/trac/chrome/site/img/polimi-logo.png http://www.zoo-project.org/trac/chrome/site/img/fem-logo.png http://www.zoo-project.org/trac/chrome/site/img/supsi-logo.png http://www.zoo-project.org/trac/chrome/site/img/cumtb-logo.png

Become a knowledge partner

Related links

http://zoo-project.org/img/ogclogo.png http://zoo-project.org/img/osgeologo.png