Index: trunk/zoo-project/zoo-kernel/service_internal_java.c
===================================================================
--- trunk/zoo-project/zoo-kernel/service_internal_java.c	(revision 360)
+++ trunk/zoo-project/zoo-kernel/service_internal_java.c	(revision 364)
@@ -40,5 +40,9 @@
       classpath=(char*) malloc((strlen(ntmp)+strlen(tmp->value)+strlen(cclasspath)+4)*sizeof(char));
       oclasspath=(char*) malloc((strlen(ntmp)+strlen(tmp->value)+strlen(cclasspath)+22)*sizeof(char));
+#ifndef WIN32
       sprintf(classpath,"%s/%s/:%s",ntmp,tmp->value,cclasspath);
+#else
+      sprintf(classpath,"%s/%s/;%s",ntmp,tmp->value,cclasspath);
+#endif
     }
     else{
@@ -54,5 +58,9 @@
 #endif
 
+#ifdef WIN32
+  JavaVMOption options[2];
+#else
   JavaVMOption options[1];
+#endif
   JavaVMInitArgs vm_args;
   JavaVM *jvm;
@@ -62,14 +70,26 @@
   jfieldID fid;
   jobject jobj;
-  jclass cls,cls_gr;
+  jclass cls;
+#ifdef JAVA7
+  jobject cls_gr;
+#else
+  jclass cls_gr;
+#endif
   int i;
 
   options[0].optionString = strdup(oclasspath);
+#ifdef WIN32
+  options[1].optionString = "-Xmx512M";
+#endif
 
   JNI_GetDefaultJavaVMInitArgs(&vm_args);
   vm_args.version = JNI_VERSION_1_6;
   vm_args.options = options;
+#ifdef WIN32
+  vm_args.nOptions = 2;
+#else
   vm_args.nOptions = 1;
-  vm_args.ignoreUnrecognized = JNI_FALSE;
+#endif
+  vm_args.ignoreUnrecognized = JNI_TRUE;
 
   result = JNI_CreateJavaVM(&jvm,(void **)&env, &vm_args);
@@ -79,14 +99,21 @@
   }
 #ifdef DEBUG
-  else  
+  else
     fprintf(stderr,"JAVA VM Started\n");
 #endif
 
   tmp=getMap(s->content,"serviceProvider");
+#ifdef JAVA7
+  cls = env->FindClass(tmp->value);
+  cls_gr = env->NewGlobalRef(cls);
+#else
   cls = (*env)->FindClass(env,tmp->value);
   cls_gr = (*env)->NewGlobalRef(env, cls);
+#endif
   if( cls == NULL ) {
     char pbt[10240];
     sprintf(pbt,"can't find class %s\n",tmp->value);
+    fprintf(stderr,pbt);
+    fflush(stderr);
     map* err=createMap("text",pbt);
     addToMap(err,"code","NoApplicableCode");
@@ -94,5 +121,9 @@
     freeMap(&err);
     free(err);
+#ifdef JAVA7
+    (*jvm).DestroyJavaVM();
+#else
     (*jvm)->DestroyJavaVM(jvm);
+#endif
     return -1;
   }
@@ -104,6 +135,11 @@
 
   if (cls != NULL) {
+#ifdef JAVA7
+    (*env).ExceptionClear();
+    pmid=(*env).GetStaticMethodID(cls, s->name, "(Ljava/util/HashMap;Ljava/util/HashMap;Ljava/util/HashMap;)I");
+#else
     (*env)->ExceptionClear(env);
     pmid=(*env)->GetStaticMethodID(env,cls_gr, s->name, "(Ljava/util/HashMap;Ljava/util/HashMap;Ljava/util/HashMap;)I");
+#endif
     if (pmid!=0){
 #ifdef DEBUG
@@ -112,7 +148,13 @@
       jclass scHashMapClass,scHashMap_class;
       jmethodID scHashMap_constructor;
+#ifdef JAVA7
+      scHashMapClass = (*env).FindClass("java/util/HashMap");
+      scHashMap_class = (jclass)(*env).NewGlobalRef(scHashMapClass);
+      scHashMap_constructor = (*env).GetMethodID(scHashMap_class, "<init>", "()V");
+#else
       scHashMapClass = (*env)->FindClass(env, "java/util/HashMap");
       scHashMap_class = (*env)->NewGlobalRef(env, scHashMapClass);
       scHashMap_constructor = (*env)->GetMethodID(env, scHashMap_class, "<init>", "()V");
+#endif
       /**
        * The 3 standard parameter for each services
@@ -123,5 +165,9 @@
       jint pValue=0;
 
+#ifdef JAVA7
+      pValue=(*env).CallStaticIntMethod(cls,pmid,arg1,arg2,arg3);
+#else
       pValue=(*env)->CallStaticIntMethod(env,cls,pmid,arg1,arg2,arg3);
+#endif
       if (pValue != (jint)NULL){
 	res=pValue;
@@ -146,5 +192,9 @@
 	FILE* new_stdout=fopen(tmps,"w+");
 	dup2(fileno(new_stdout),fileno(stdout));
+#ifdef JAVA7
+	(*env).ExceptionDescribe();
+#else
 	(*env)->ExceptionDescribe(env);
+#endif
 	fflush(stdout);
 	dup2(old_stdout,fileno(stdout));
@@ -152,8 +202,8 @@
 	long flen=ftell(new_stdout);
 	rewind(new_stdout);
-	char tmps1[flen];
+	char *tmps1=(char*)malloc((flen+1)*sizeof(char));
 	fread(tmps1,flen,1,new_stdout);
 	fclose(new_stdout);
-	char pbt[100+flen];
+	char *pbt=(char*)malloc((100+flen+1)*sizeof(char));
 	sprintf(pbt,"Unable to run your java process properly. Server returns : %s",tmps1);
 	map* err=createMap("text",pbt);
@@ -162,5 +212,9 @@
 	freeMap(&err);
 	free(err);
+#ifdef JAVA7
+	(*jvm).DestroyJavaVM();
+#else
 	(*jvm)->DestroyJavaVM(jvm);
+#endif
 	return -1;
       }
@@ -173,5 +227,9 @@
       freeMap(&err);
       free(err);
+#ifdef JAVA7
+      (*jvm).DestroyJavaVM();
+#else
       (*jvm)->DestroyJavaVM(jvm);
+#endif
       return -1;
     }
@@ -183,8 +241,16 @@
     freeMap(&err);
     free(err);
+#ifdef JAVA7
+    (*jvm).DestroyJavaVM();
+#else
     (*jvm)->DestroyJavaVM(jvm);
+#endif
     return -1;
   }
+#ifdef JAVA7
+      (*jvm).DestroyJavaVM();
+#else
   (*jvm)->DestroyJavaVM(jvm);
+#endif
   return res;
 }
@@ -193,15 +259,29 @@
   jobject scObject,scObject1;
   if(scHashMap_constructor!=NULL){
+#ifdef JAVA7
+    scObject = (*env).NewObject(scHashMap_class, scHashMap_constructor);
+#else
     scObject = (*env)->NewObject(env, scHashMap_class, scHashMap_constructor);
+#endif
     jmethodID put_mid = 0;
 
+#ifdef JAVA7
+    put_mid = (*env).GetMethodID(scHashMapClass, "put",
+				  "(Ljava/lang/Object;Ljava/lang/Object;)"
+				  "Ljava/lang/Object;");
+#else
     put_mid = (*env)->GetMethodID(env,scHashMapClass, "put",
 				  "(Ljava/lang/Object;Ljava/lang/Object;)"
 				  "Ljava/lang/Object;");
+#endif
     maps* tmp=t;
     while(tmp!=NULL){
       map* tmap=getMapType(tmp->content);
       map* tmp1=tmp->content;
+#ifdef JAVA7
+      scObject1 = (*env).NewObject(scHashMap_class, scHashMap_constructor);
+#else
       scObject1 = (*env)->NewObject(env, scHashMap_class, scHashMap_constructor);
+#endif
       map* sizeV=getMap(tmp1,"size");
       map* isArray=getMap(tmp1,"isArray");
@@ -211,9 +291,19 @@
 	  if(isArray==NULL){
 	    if(sizeV!=NULL && strcmp(tmp1->name,"value")==0){
+#ifdef JAVA7
+	      jbyteArray tmpData=(*env).NewByteArray(atoi(sizeV->value));
+	      (*env).SetByteArrayRegion(tmpData,0,atoi(sizeV->value),(const jbyte *)tmp1->value);
+	      (*env).CallObjectMethod(scObject1, put_mid, (*env).NewStringUTF(tmp1->name), tmpData);
+#else
 	      jbyteArray tmpData=(*env)->NewByteArray(env,atoi(sizeV->value));
 	      (*env)->SetByteArrayRegion(env,tmpData,0,atoi(sizeV->value),tmp1->value);
 	      (*env)->CallObjectMethod(env,scObject1, put_mid, (*env)->NewStringUTF(env,tmp1->name), tmpData);
+#endif
 	    }else
+#ifdef JAVA7
+	      (*env).CallObjectMethod(scObject1, put_mid, (*env).NewStringUTF(tmp1->name), (*env).NewStringUTF(tmp1->value));
+#else
 	      (*env)->CallObjectMethod(env,scObject1, put_mid, (*env)->NewStringUTF(env,tmp1->name), (*env)->NewStringUTF(env,tmp1->value));
+#endif
 	  }
 	  else{
@@ -224,4 +314,16 @@
 	    jmethodID scArrayList_constructor;
 	    jobject scObject2,scObject3,scObject4;
+#ifdef JAVA7
+	    scArrayListClass = (*env).FindClass("java/util/ArrayList");
+	    scArrayList_class = (jclass)(*env).NewGlobalRef(scArrayListClass);
+	    scArrayList_constructor = (*env).GetMethodID(scArrayList_class, "<init>", "()V");
+	    jmethodID add_mid = 0;
+	    scObject2 = (*env).NewObject(scArrayList_class, scArrayList_constructor);
+	    scObject3 = (*env).NewObject(scArrayList_class, scArrayList_constructor);
+	    scObject4 = (*env).NewObject(scArrayList_class, scArrayList_constructor);
+
+	    add_mid = (*env).GetMethodID(scArrayListClass,
+					  "add","(Ljava/lang/Object;)Z");
+#else
 	    scArrayListClass = (*env)->FindClass(env, "java/util/ArrayList");
 	    scArrayList_class = (*env)->NewGlobalRef(env, scArrayListClass);
@@ -234,5 +336,5 @@
 	    add_mid = (*env)->GetMethodID(env,scArrayListClass,
 					  "add","(Ljava/lang/Object;)Z");
-	    
+#endif	    
 	    int i;
 	    
@@ -243,23 +345,46 @@
 	      
 	      if(sMap!=NULL && vMap!=NULL && strncmp(vMap->name,"value",5)==0){
+#ifdef JAVA7
+		jbyteArray tmpData=(*env).NewByteArray(atoi(sMap->value));
+		(*env).SetByteArrayRegion(tmpData,0,atoi(sMap->value),(const jbyte *)vMap->value);
+		(*env).CallObjectMethod(scObject2, add_mid, tmpData);
+#else
 		jbyteArray tmpData=(*env)->NewByteArray(env,atoi(sMap->value));
 		(*env)->SetByteArrayRegion(env,tmpData,0,atoi(sMap->value),vMap->value);
 		(*env)->CallObjectMethod(env,scObject2, add_mid, tmpData);
+#endif
 	      }else{
+#ifdef JAVA7
+		jobject tmpData=(*env).NewStringUTF(vMap->value);
+		(*env).CallObjectMethod(scObject2, add_mid, tmpData);
+#else
 		jobject tmpData=(*env)->NewStringUTF(env,vMap->value);
 		(*env)->CallObjectMethod(env,scObject2, add_mid, tmpData);
+#endif
 	      }
 	      
 	    }
-	    
+
+#ifdef JAVA7
+	    (*env).CallObjectMethod(scObject1, put_mid, (*env).NewStringUTF(tmp1->name), scObject2);
+#else	    
 	    (*env)->CallObjectMethod(env,scObject1, put_mid, (*env)->NewStringUTF(env,tmp1->name), scObject2);
-	    
+#endif
+
 	  }
 	}
 	else
+#ifdef JAVA7
+	  (*env).CallObjectMethod(scObject1, put_mid, (*env).NewStringUTF(tmp1->name), (*env).NewStringUTF(tmp1->value));
+#else
 	  (*env)->CallObjectMethod(env,scObject1, put_mid, (*env)->NewStringUTF(env,tmp1->name), (*env)->NewStringUTF(env,tmp1->value));
+#endif
 	tmp1=tmp1->next;
       }
+#ifdef JAVA7
+      (*env).CallObjectMethod(scObject, put_mid, (*env).NewStringUTF(tmp->name), scObject1);
+#else
       (*env)->CallObjectMethod(env,scObject, put_mid, (*env)->NewStringUTF(env,tmp->name), scObject1);
+#endif
       tmp=tmp->next;
     }
@@ -292,7 +417,13 @@
     return NULL;
   }
+#ifdef JAVA7
+  entrySet_mid = (*env).GetMethodID(scHashMapClass, "entrySet", "()Ljava/util/Set;"); 
+  containsKey_mid = (*env).GetMethodID(scHashMapClass, "containsKey", "(Ljava/lang/Object;)Z");
+  get_mid = (*env).GetMethodID(scHashMapClass, "get", "(Ljava/lang/Object;)Ljava/lang/Object;"); 
+#else
   entrySet_mid = (*env)->GetMethodID(env, scHashMapClass, "entrySet", "()Ljava/util/Set;"); 
   containsKey_mid = (*env)->GetMethodID(env, scHashMapClass, "containsKey", "(Ljava/lang/Object;)Z");
   get_mid = (*env)->GetMethodID(env, scHashMapClass, "get", "(Ljava/lang/Object;)Ljava/lang/Object;"); 
+#endif
 
   if(containsKey_mid==0){
@@ -319,36 +450,74 @@
 #endif
 
+#ifdef JAVA7
+  scSetClass = (*env).FindClass("java/util/Set");
+  iterator_mid = (*env).GetMethodID(scSetClass, "iterator", "()Ljava/util/Iterator;"); 
+#else
   scSetClass = (*env)->FindClass(env, "java/util/Set");
   iterator_mid = (*env)->GetMethodID(env, scSetClass, "iterator", "()Ljava/util/Iterator;"); 
+#endif
 #ifdef DEBUG
   fprintf(stderr,"mapsFromHashMap 1 (%d) \n",iterator_mid);
 #endif
 
+#ifdef JAVA7
+  scIteratorClass = (*env).FindClass("java/util/Iterator");
+  hasNext_mid = (*env).GetMethodID(scIteratorClass, "hasNext", "()Z");
+#else
   scIteratorClass = (*env)->FindClass(env, "java/util/Iterator");
   hasNext_mid = (*env)->GetMethodID(env, scIteratorClass, "hasNext", "()Z");
+#endif
+
 #ifdef DEBUG
   fprintf(stderr,"mapsFromHashMap 2 (%d)\n",hasNext_mid);
 #endif
+
+#ifdef JAVA7
+  next_mid = (*env).GetMethodID(scIteratorClass, "next", "()Ljava/lang/Object;");
+#else
   next_mid = (*env)->GetMethodID(env, scIteratorClass, "next", "()Ljava/lang/Object;");
+#endif
 #ifdef DEBUG
   fprintf(stderr,"mapsFromHashMap 3 (%d)\n",next_mid);
 #endif
 
+#ifdef JAVA7
+  scMapEntryClass = (*env).FindClass("java/util/Map$Entry");
+  getKey_mid = (*env).GetMethodID(scMapEntryClass, "getKey", "()Ljava/lang/Object;");
+#else
   scMapEntryClass = (*env)->FindClass(env, "java/util/Map$Entry");
   getKey_mid = (*env)->GetMethodID(env, scMapEntryClass, "getKey", "()Ljava/lang/Object;");
+#endif
 #ifdef DEBUG
   fprintf(stderr,"mapsFromHashMap 4 (%d)\n",getKey_mid);
 #endif
+#ifdef JAVA7
+  getValue_mid = (*env).GetMethodID(scMapEntryClass, "getValue", "()Ljava/lang/Object;");
+#else
   getValue_mid = (*env)->GetMethodID(env, scMapEntryClass, "getValue", "()Ljava/lang/Object;");
+#endif
 #ifdef DEBUG
   fprintf(stderr,"mapsFromHashMap 5 (%d)\n",getValue_mid);
 #endif
 
+#ifdef JAVA7
+  jobject final_set=(*env).CallObjectMethod(t,entrySet_mid);
+  jobject final_iterator=(*env).CallObjectMethod(final_set,iterator_mid);
+#else
   jobject final_set=(*env)->CallObjectMethod(env,t,entrySet_mid);
   jobject final_iterator=(*env)->CallObjectMethod(env,final_set,iterator_mid);
-
+#endif
 
   maps* final_res=NULL;
   map* res=NULL;
+#ifdef JAVA7
+  while((*env).CallBooleanMethod(final_iterator,hasNext_mid)){
+    jobject tmp=(*env).CallObjectMethod(final_iterator,next_mid);
+
+    jobject imap=(*env).CallObjectMethod(tmp,getValue_mid);
+    jobject set=(*env).CallObjectMethod(imap,entrySet_mid);
+    jobject iterator=(*env).CallObjectMethod(set,iterator_mid);
+
+#else
   while((*env)->CallBooleanMethod(env,final_iterator,hasNext_mid)){
     jobject tmp=(*env)->CallObjectMethod(env,final_iterator,next_mid);
@@ -358,13 +527,32 @@
     jobject iterator=(*env)->CallObjectMethod(env,set,iterator_mid);
 
+#endif
     int size=-1;
+#ifdef JAVA7
+    if((*env).CallBooleanMethod(imap,containsKey_mid,(*env).NewStringUTF("size"))){
+      jobject sizeV=(*env).CallObjectMethod(imap, get_mid,(*env).NewStringUTF("size"));
+      const char* sizeVS=(*env).GetStringUTFChars((jstring)sizeV, NULL);
+#else
     if((*env)->CallBooleanMethod(env,imap,containsKey_mid,(*env)->NewStringUTF(env,"size"))){
       jobject sizeV=(*env)->CallObjectMethod(env, imap, get_mid,(*env)->NewStringUTF(env,"size"));
       const char* sizeVS=(*env)->GetStringUTFChars(env, sizeV, NULL);
+#endif
       size=atoi(sizeVS);
       fprintf(stderr,"SIZE : %s\n",sizeVS);
+#ifdef JAVA7
+      (*env).ReleaseStringUTFChars((jstring)sizeV, sizeVS);
+#else
       (*env)->ReleaseStringUTFChars(env, sizeV, sizeVS);
+#endif
     }
     
+#ifdef JAVA7
+    while((*env).CallBooleanMethod(iterator,hasNext_mid)){
+      jobject tmp1=(*env).CallObjectMethod(iterator,next_mid);
+      jobject jk=(*env).CallObjectMethod(tmp1,getKey_mid);
+      jobject jv=(*env).CallObjectMethod(tmp1,getValue_mid);
+
+      const char* jkd=(*env).GetStringUTFChars((jstring)jk, NULL);
+#else
     while((*env)->CallBooleanMethod(env,iterator,hasNext_mid)){
       jobject tmp1=(*env)->CallObjectMethod(env,iterator,next_mid);
@@ -373,6 +561,11 @@
 
       const char* jkd=(*env)->GetStringUTFChars(env, jk, NULL);
+#endif
       if(size>=0 && strcmp(jkd,"value")==0){
+#ifdef JAVA7
+	jobject value=(jobject)(*env).GetByteArrayElements((jbyteArray)jv, NULL);
+#else
 	jobject value=(*env)->GetByteArrayElements(env, jv, NULL);
+#endif
 	if(res==NULL){
 	  res=createMap(jkd,"");
@@ -390,5 +583,9 @@
       }
       else{
+#ifdef JAVA7
+	const char* jvd=(*env).GetStringUTFChars((jstring)jv, NULL);
+#else
 	const char* jvd=(*env)->GetStringUTFChars(env, jv, NULL);
+#endif
 	if(res==NULL){
 	  res=createMap(jkd,jvd);
@@ -396,13 +593,29 @@
 	  addToMap(res,jkd,jvd);
 	}
+#ifdef JAVA7
+	(*env).ReleaseStringUTFChars((jstring)jv, jvd);
+#else
 	(*env)->ReleaseStringUTFChars(env, jv, jvd);
+#endif
       }
 
+#ifdef JAVA7
+      (*env).ReleaseStringUTFChars((jstring)jk, jkd);
+#else
       (*env)->ReleaseStringUTFChars(env, jk, jkd);
+#endif
 
     }
+#ifdef JAVA7
+    jobject jk=(*env).CallObjectMethod(tmp,getKey_mid);
+#else
     jobject jk=(*env)->CallObjectMethod(env,tmp,getKey_mid);
+#endif
     maps* cmap=(maps*)malloc(sizeof(maps));
+#ifdef JAVA7
+    cmap->name=(char*)(*env).GetStringUTFChars((jstring)jk, NULL);
+#else
     cmap->name=(*env)->GetStringUTFChars(env, jk, NULL);
+#endif
 #ifdef DEBUG
     fprintf(stderr," / %s \n",cmap->name);
