commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mt...@apache.org
Subject cvs commit: jakarta-commons-sandbox/daemon/src/native/nt/procrun procrun.c procrun.h
Date Mon, 17 Feb 2003 18:19:08 GMT
mturk       2003/02/17 10:19:08

  Modified:    daemon/src/native/nt/procrun procrun.c procrun.h
  Log:
  Enable using both JVM and redirected Java.
  Only the shutdown class will be called using inprocess JVM.
  
  Revision  Changes    Path
  1.8       +38 -20    jakarta-commons-sandbox/daemon/src/native/nt/procrun/procrun.c
  
  Index: procrun.c
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/daemon/src/native/nt/procrun/procrun.c,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- procrun.c	17 Feb 2003 16:42:00 -0000	1.7
  +++ procrun.c	17 Feb 2003 18:19:07 -0000	1.8
  @@ -909,18 +909,20 @@
       }
       if (has_java) {
           UINT em;
  -        DBPRINTF1("jvm_path %s", jvm_path);
  -        if (strlen(jvm_path) && (stricmp(jvm_path, "auto") == 0))
  -            proc->java.path = procrun_guess_jvm(proc);
  -        else if (strlen(jvm_path) && (strnicmp(jvm_path, "java", 4) == 0)) {
  -            proc->java.path = procrun_guess_java(proc, jvm_path);
  -            return proc->java.path ? 0 : -1;
  +        if (strlen(jvm_path)) {
  +            if (strlen(jvm_path) < 6)
  +                proc->java.path = procrun_guess_jvm(proc);
  +            else
  +                proc->java.path = pool_strdup(proc->pool, jvm_path);
  +            if (strnicmp(jvm_path, "java", 4) == 0) {
  +                proc->java.jpath = procrun_guess_java(proc, jvm_path);
  +            }
           }
  -        else
  -            proc->java.path = pool_strdup(proc->pool, jvm_path);
  +        DBPRINTF1("jvm dll path %s", proc->java.path);
  +        DBPRINTF1("java    path %s", proc->java.jpath);
           if (!proc->java.path || !proc->java.start_method)
               return -1;
  -        /* Try to load the jvm dll */
  +        /* Try to load the jvm dll */ 
           em = SetErrorMode(SEM_FAILCRITICALERRORS);
           proc->java.dll = LoadLibraryEx(proc->java.path, NULL, 0); 
           if (!proc->java.dll)
  @@ -1020,6 +1022,8 @@
       if (proc->java.stop_bridge && proc->java.stop_mid) {
           jclass strclass;
           jarray jargs = NULL;
  +        DBPRINTF1("Calling shutdown %s", proc->java.stop_class); 
  +
           strclass = (*env)->FindClass(env, "java/lang/String");
           if (proc->java.stop_param) {
               jstring arg = (*env)->NewStringUTF(env, proc->java.stop_param);
  @@ -1031,7 +1035,7 @@
                                        proc->java.stop_mid,
                                        jargs);
       }
  -    else {
  +    else if (!proc->java.jpath) {
           /* Call java.lang.System.exit(0) */
           jclass sysclass;
           jmethodID exitid;
  @@ -1043,7 +1047,8 @@
               goto cleanup;
           report_service_status(SERVICE_STOPPED, 0, 0,
                                 g_env->m);
  -
  +        DBPRINTF0("Forcing shutdown using System.exit(0)");
  + 
           (*env)->CallStaticVoidMethod(env, sysclass, exitid, 0);
       }
   cleanup:
  @@ -1149,6 +1154,12 @@
                                                           "([Ljava/lang/String;)V");
       }
       
  +    /* check if we have java.exe as worker process 
  +     * in that case don't call the startup class. 
  +     */
  +    if (proc->java.jpath != NULL) {
  +        return 0;
  +    } 
       strclass = (*env)->FindClass(env, "java/lang/String");
       if (proc->java.start_param) {
           jstring arg = (*env)->NewStringUTF(env, proc->java.start_param);
  @@ -1406,7 +1417,7 @@
       DBPRINTF1("Creating process %s.\n", program);
       DBPRINTF1("Creating process %s.\n", env->m->argw);
       /* for java.exe merge Arguments and Java options */
  -    if (env->m->java.path) {
  +    if (env->m->java.jpath) {
           int i, j, len = strlen(env->m->argw) + 8192;
           char *opts[64], *nargw;
   
  @@ -1437,7 +1448,7 @@
               strcat(nargw, env->m->java.start_param);
           }
           env->m->argw = nargw;
  -        program = env->m->java.path;
  +        program = env->m->java.jpath;
       }
       DBPRINTF2("RUN [%s] %s\n", program, env->m->argw);
       if (env->m->service.account && env->m->service.password &&
  @@ -1755,7 +1766,6 @@
       char *display = NULL;
       char *java = NULL;
   
  -    int i, n;
       if (!proc->service.name) {
           return -1;
       }
  @@ -2214,12 +2224,20 @@
       report_service_status(SERVICE_START_PENDING, NO_ERROR, 3000,
                             g_env->m);
       if (g_env->m->java.dll) {
  -        DWORD id;
  -        HANDLE jh;
  -        jh = CreateThread(NULL, 0, java_thread, g_env, 0, &id);
  -        pool_handle(g_env->m->pool, jh);
  -        rv = 0;
  -    }
  +        if (g_env->m->java.jpath == NULL) {
  +            DWORD id;
  +            HANDLE jh;
  +            jh = CreateThread(NULL, 0, java_thread, g_env, 0, &id);
  +            pool_handle(g_env->m->pool, jh);
  +            rv = 0;
  +        }
  +        else {
  +            if ((rv = procrun_init_jvm(g_env->m)) == 0) {
  +                rv = procrun_redirect(g_env->m->service.image,
  +                                      g_env->m->envp, g_env);    
  +            }
  +        }
  +    } 
       else {
           rv = procrun_redirect(g_env->m->service.image,
                                 g_env->m->envp, g_env);    
  
  
  
  1.7       +1 -0      jakarta-commons-sandbox/daemon/src/native/nt/procrun/procrun.h
  
  Index: procrun.h
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/daemon/src/native/nt/procrun/procrun.h,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- procrun.h	17 Feb 2003 15:09:24 -0000	1.6
  +++ procrun.h	17 Feb 2003 18:19:07 -0000	1.7
  @@ -216,6 +216,7 @@
       typedef struct java_t java_t;
       struct java_t {
           char         *path;
  +        char         *jpath;
           char         *start_class;
           char         *stop_class;
           HMODULE      dll;
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message