tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mt...@apache.org
Subject cvs commit: jakarta-tomcat-connectors/jk/native2/common jk_worker_jni.c
Date Mon, 01 Jul 2002 15:44:16 GMT
mturk       2002/07/01 08:44:16

  Modified:    jk/native2/common jk_worker_jni.c
  Log:
  On worker destroy call the TomcatStarter with the stop arg
  to gracefuly shutdown the Tomcat.
  
  Revision  Changes    Path
  1.21      +36 -23    jakarta-tomcat-connectors/jk/native2/common/jk_worker_jni.c
  
  Index: jk_worker_jni.c
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native2/common/jk_worker_jni.c,v
  retrieving revision 1.20
  retrieving revision 1.21
  diff -u -r1.20 -r1.21
  --- jk_worker_jni.c	29 Jun 2002 18:29:09 -0000	1.20
  +++ jk_worker_jni.c	1 Jul 2002 15:44:16 -0000	1.21
  @@ -152,6 +152,10 @@
           } else {
               jniWorker->className = value;
           }
  +    /* XXX Instead of ARG=start split to something like:
  +     * startup=start
  +     * shutdown=stop
  +     */
       } else if( strcmp( name, "ARG" )==0 ) {
           jniWorker->args[jniWorker->nArgs]=value;
           jniWorker->nArgs++;
  @@ -308,7 +312,14 @@
       jk_worker_t *_this=bean->object;
       jni_worker_data_t *jniWorker;
       jk_vm_t *vm=_this->workerEnv->vm;
  -
  +    JNIEnv *jniEnv;
  +    jstring cmd_line = NULL;
  +    jstring stdout_name = NULL;
  +    jstring stderr_name = NULL;
  +    jclass jstringClass;
  +    jarray jargs;
  +    jstring arg=NULL;
  +    
       if(!_this  || ! _this->worker_private) {
           env->l->jkLog(env, env->l, JK_LOG_EMERG,
                         "In destroy, assert failed - invalid parameters\n");
  @@ -317,28 +328,30 @@
   
       jniWorker = _this->worker_private;
   
  -    /* A MUCH better solution is to use the standard JDK1.3 mechanism.
  -       Or Ajp13 shutdown.
  -       I'll implement JDK1.3 after I check if I do need to do anything
  -       on the C side ( i.e. call System.exit() explicitely - I have a feeling
  -       the smart VM guys have added a hook to at_exit ). 
  -    */
  -    
  -/*     if(! jniWorker->jk_shutdown_method) { */
  -/*         env->l->jkLog(env, env->l, JK_LOG_EMERG, */
  -/*                       "In destroy, Tomcat not intantiated\n"); */
  -/*         return JK_ERR; */
  -/*     } */
  -
  -/*     if((jniEnv = vm->attach(env, vm))) { */
  -/*         env->l->jkLog(env, env->l, JK_LOG_INFO,  */
  -/*                       "jni.destroy(), shutting down Tomcat...\n"); */
  -/*         (*jniEnv)->CallStaticVoidMethod(jniEnv, */
  -/*                                   jniWorker->jk_java_bridge_class, */
  -/*                                   jniWorker->jk_shutdown_method); */
  -/*         vm->detach(env, vm); */
  -/*     } */
  -
  +    if((jniEnv = vm->attach(env, vm))) {
  +        env->l->jkLog(env, env->l, JK_LOG_INFO,
  +                       "jni.destroy(), shutting down Tomcat...\n");
  +
  +        jstringClass=(*jniEnv)->FindClass(jniEnv, "java/lang/String" );
  +        jargs=(*jniEnv)->NewObjectArray(jniEnv, 1, jstringClass, NULL);
  +
  +        /* XXX Need to make that arg customizable 
  +        */
  +        arg=(*jniEnv)->NewStringUTF(jniEnv, "stop" );
  +        env->l->jkLog(env, env->l, JK_LOG_INFO,
  +                          "jni.destroy() ARG stop\n");
  +        (*jniEnv)->SetObjectArrayElement(jniEnv, jargs, 0, arg );        
  +    
  +        env->l->jkLog(env, env->l, JK_LOG_INFO,
  +                      "jni.destroy() calling main()...\n");
  +    
  +        (*jniEnv)->CallStaticVoidMethod(jniEnv,
  +                                    jniWorker->jk_java_bridge_class,
  +                                    jniWorker->jk_main_method,
  +                                    jargs,stdout_name,stderr_name);
  +        
  +        vm->destroy(env, vm);
  +    }
       env->l->jkLog(env, env->l, JK_LOG_INFO, "jni.destroy() done\n");
   
       return JK_OK;
  
  
  

--
To unsubscribe, e-mail:   <mailto:tomcat-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:tomcat-dev-help@jakarta.apache.org>


Mime
View raw message