tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From na...@apache.org
Subject cvs commit: jakarta-tomcat-connectors/jk/native2/common jk_worker_jni.c
Date Mon, 01 Jul 2002 23:11:42 GMT
nacho       2002/07/01 16:11:42

  Modified:    jk/native2/common jk_worker_jni.c
  Log:
  * set the stdout and stderr files using statics methods from AprImpl
  
  Revision  Changes    Path
  1.22      +46 -12    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.21
  retrieving revision 1.22
  diff -u -r1.21 -r1.22
  --- jk_worker_jni.c	1 Jul 2002 15:44:16 -0000	1.21
  +++ jk_worker_jni.c	1 Jul 2002 23:11:42 -0000	1.22
  @@ -81,7 +81,10 @@
   
   struct jni_worker_data {
       jclass      jk_java_bridge_class;
  +    jclass      jk_java_bridge_apri_class;
       jmethodID   jk_main_method;
  +    jmethodID   jk_setout_method;
  +    jmethodID   jk_seterr_method;
       char *className;
       char *stdout_name;
       char *stderr_name;
  @@ -102,14 +105,32 @@
       p->jk_main_method =
           (*jniEnv)->GetStaticMethodID(jniEnv, p->jk_java_bridge_class,
                                        "main", 
  -                                     "([Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V");
  +                                     "([Ljava/lang/String;)V");
  +    if(!p->jk_main_method) {
  +	    env->l->jkLog(env, env->l, JK_LOG_EMERG, "Can't find main(String [])\n");

  +	    return JK_ERR;
  +    }
   
  -    
  +    p->jk_setout_method =
  +        (*jniEnv)->GetStaticMethodID(jniEnv, p->jk_java_bridge_apri_class,
  +                                     "setOut", 
  +                                     "(Ljava/lang/String;)V");
       if(!p->jk_main_method) {
  -	env->l->jkLog(env, env->l, JK_LOG_EMERG, "Can't find main()\n"); 
  -	return JK_ERR;
  +	    env->l->jkLog(env, env->l, JK_LOG_EMERG, "Can't find AprImpl.setOut(String)");

  +	    return JK_ERR;
       }
   
  +    p->jk_seterr_method =
  +        (*jniEnv)->GetStaticMethodID(jniEnv, p->jk_java_bridge_apri_class,
  +                                     "setErr", 
  +                                     "(Ljava/lang/String;)V");
  +    if(!p->jk_main_method) {
  +	    env->l->jkLog(env, env->l, JK_LOG_EMERG, "Can't find AprImpl.setErr(String)\n");

  +	    return JK_ERR;
  +    }
  +
  +    
  +
       return JK_OK;
   }
   
  @@ -178,7 +199,6 @@
       char *str_config = NULL;
       jk_map_t *props=_this->workerEnv->initData;
       jk_vm_t *vm=_this->workerEnv->vm;
  -    jclass aprImplClass;
       jclass jstringClass;
       jarray jargs;
       int i=0;
  @@ -251,19 +271,18 @@
      XXX Need the way to customize JAVA_BRIDGE_CLASS_APRI, but since
      it's hardcoded in JniHandler.java doesn't matter for now.
   */
  -    aprImplClass =
  +    jniWorker->jk_java_bridge_apri_class =
           (*jniEnv)->FindClass(jniEnv, JAVA_BRIDGE_CLASS_APRI );
   
  -    if( aprImplClass == NULL ) {
  +    if( jniWorker->jk_java_bridge_apri_class == NULL ) {
           env->l->jkLog(env, env->l, JK_LOG_ERROR,
                         "Can't find class %s\n", JAVA_BRIDGE_CLASS_APRI );
           /* [V] the detach here may segfault on 1.1 JVM... */
           vm->detach(env, vm);
           return JK_ERR;
       }
  -    rc = jk_jni_aprImpl_registerNatives( jniEnv, aprImplClass);
  -    
  -   if( rc != 0) {
  +    rc = jk_jni_aprImpl_registerNatives( jniEnv, jniWorker->jk_java_bridge_apri_class);
  +    if( rc != 0) {
        env->l->jkLog(env, env->l, JK_LOG_ERROR,
                         "Can't register native functions for %s \n", JAVA_BRIDGE_CLASS_APRI
); 
           vm->detach(env, vm);
  @@ -293,13 +312,28 @@
           (*jniEnv)->SetObjectArrayElement(jniEnv, jargs, i, arg );        
       }
       
  +    /* Set out and err stadard files */ 
  +
  +    env->l->jkLog(env, env->l, JK_LOG_INFO,
  +                  "jni.init() setting stdout=%s...\n",jniWorker->stdout_name);
  +    (*jniEnv)->CallStaticVoidMethod(jniEnv,
  +                                    jniWorker->jk_java_bridge_apri_class,
  +                                    jniWorker->jk_setout_method,
  +                                    stdout_name);
  +
  +    env->l->jkLog(env, env->l, JK_LOG_INFO,
  +                  "jni.init() setting stderr=%s...\n",jniWorker->stderr_name);
  +    (*jniEnv)->CallStaticVoidMethod(jniEnv,
  +                                    jniWorker->jk_java_bridge_apri_class,
  +                                    jniWorker->jk_seterr_method,
  +                                    stderr_name);
  +
       env->l->jkLog(env, env->l, JK_LOG_INFO,
                     "jni.init() calling main()...\n");
  -    
       (*jniEnv)->CallStaticVoidMethod(jniEnv,
                                       jniWorker->jk_java_bridge_class,
                                       jniWorker->jk_main_method,
  -                                    jargs,stdout_name,stderr_name);
  +                                    jargs);
       
       vm->detach(env, vm);
   
  
  
  

--
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