costin      02/03/18 10:45:25

  Modified:    jk/native2/common jk_vm_default.c jk_worker_jni.c
  Log:
  Update to the new config mechanism.
  
  Revision  Changes    Path
  1.6       +55 -48    jakarta-tomcat-connectors/jk/native2/common/jk_vm_default.c
  
  Index: jk_vm_default.c
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native2/common/jk_vm_default.c,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- jk_vm_default.c   11 Mar 2002 11:41:11 -0000      1.5
  +++ jk_vm_default.c   18 Mar 2002 18:45:25 -0000      1.6
  @@ -75,6 +75,8 @@
    */
   
   #include "jk_vm.h"
  +#include "jk_config.h"
  +
   
   #if !defined(WIN32) && !defined(NETWARE)
   #include <dlfcn.h>
  @@ -325,27 +327,18 @@
      than we do ).
   */
   char* jk2_vm_guessJvmDll(jk_env_t *env, jk_map_t *props,
  -                         jk_vm_t *jniw, char *prefix)
  +                         jk_vm_t *jniw)
   {
       char *jvm;
       jk_pool_t *p=props->pool;
       const char **current=defaultVM_PATH;
       char *libp;
       
  -    /* Maybe he knows more */
  -    jvm =jk2_map_getStrProp( env, props, NULL, prefix,
  -                            "jvm_lib", NULL );
  -    if( jvm!=NULL && jk2_file_exists(env, jvm)) {
  -        env->l->jkLog(env, env->l, JK_LOG_INFO,
  -                      "jni.guessJvmDll() - user specified %s\n", jvm);
  -        return jvm;
  -    }
  -
       /* We need at least JAVA_HOME ( either env or in settings )
        */
       while( *current != NULL ) {
  -        jvm = jk2_map_replaceProperties(env, props, p,
  -                                   (char *)p->pstrdup( env, p, *current ) );
  +        jvm = jk2_config_replaceProperties(env, props, p,
  +                                           (char *)p->pstrdup( env, p, *current ) );
   
           if( jvm!=NULL && jk2_file_exists(env, jvm)) {
               env->l->jkLog(env, env->l, JK_LOG_INFO,
  @@ -683,7 +676,7 @@
       jk2_guessTomcatHome( env, props );
       
       while( *current != NULL ) {
  -        jkJar = jk2_map_replaceProperties(env, props, p,
  +        jkJar = jk2_config_replaceProperties(env, props, p,
                                          (char *)p->pstrdup( env, p, *current ));
           
           if( jkJar!=NULL && jk2_file_exists(env, jkJar)) {
  @@ -703,21 +696,49 @@
       return NULL;
   }
   
  +static int 
  +jk2_jk_vm_setProperty(jk_env_t *env, jk_bean_t *mbean, char *name, void *valueP )
  +{
  +    jk_vm_t *_this=mbean->object;
  +    char *value=valueP;
  +    
  +    if( strcmp( name, "mx" )==0 ) {
  +        /* atoi + K, M */
  +        _this->tomcat_mx = jk2_config_str2int(env, value);
  +    } else if( strcmp( name, "ms" )==0 ) {
  +        _this->tomcat_ms = jk2_config_str2int(env, value);
  +    } else if( strcmp( name, "class_path" )==0 ) {
  +        _this->tomcat_classpath=value;
  +    } else if( strcmp( name, "jvm_lib" )==0 ) {
  +        _this->jvm_dll_path=value;
  +    } else if( strcmp( name, "sysprops" )==0 ) {
  +        _this->sysprops  = jk2_config_split( env, _this->pool,
  +                                          value, "*", NULL);
  +#ifdef JNI_VERSION_1_2
  +    } else if( strcmp( name, "java2opts" )==0 ) {
  +     env->l->jkLog(env, env->l, JK_LOG_INFO,
  +                      "jni.validate() java2opts %s\n", value); 
  +        _this->java2opts = jk2_config_split( env, _this->pool,
  +                                             value, "*", NULL);
  +    } else if( strcmp( name, "java2lax" )==0 ) {
  +        int int_config=atoi( value );
  +        _this->java2lax = int_config ? JK_TRUE : JK_FALSE;
  +#endif
  +    } else {
  +        return JK_FALSE;
  +    }
  +
  +    return JK_TRUE;
  +}
   
   /** Initialize the vm properties
    */
  -int jk2_jk_vm_init(jk_env_t *env, jk_vm_t *_this,
  -                   jk_map_t *props, char *prefix)
  +int jk2_jk_vm_init(jk_env_t *env, jk_vm_t *_this)
   {
       char *str_config;
       int int_config;
  +    jk_map_t *props=_this->properties;
       
  -    _this->tomcat_mx= jk2_map_getIntProp( env, props, NULL, prefix, "mx", 0 );
  -    _this->tomcat_ms= jk2_map_getIntProp( env, props, NULL, prefix, "ms", 0 );
  -
  -    _this->tomcat_classpath= jk2_map_getStrProp( env, props, NULL, prefix,
  -                                                "class_path", NULL );
  -
       if(_this->tomcat_classpath == NULL ) {
           _this->tomcat_classpath = jk2_guessClassPath( env, props );
       }
  @@ -734,7 +755,10 @@
           return JK_FALSE;
       }
   
  -    _this->jvm_dll_path=jk2_vm_guessJvmDll( env, props, _this, prefix  );
  +    if( _this->jvm_dll_path ==NULL ||
  +        ! jk2_file_exists(env, _this->jvm_dll_path )) {
  +        _this->jvm_dll_path=jk2_vm_guessJvmDll( env, props, _this  );
  +    }
   
       if(!_this->jvm_dll_path ) {
           env->l->jkLog(env, env->l, JK_LOG_EMERG,
  @@ -744,32 +768,12 @@
       env->l->jkLog(env, env->l, JK_LOG_INFO, "Jni lib: %s\n",
                     _this->jvm_dll_path);
   
  -    str_config=  jk2_map_getStrProp( env, props, NULL, prefix,
  -                                    "sysprops", NULL ); 
  -    if(str_config!= NULL ) {
  -        _this->sysprops  = jk2_map_split( env, NULL, _this->pool,
  -                                         str_config, "*", NULL);
  -    }
  -
  -#ifdef JNI_VERSION_1_2
  -    str_config= jk2_map_getStrProp(env, props, NULL,prefix ,"java2opts",NULL );
  -    if( str_config != NULL ) {
  -     env->l->jkLog(env, env->l, JK_LOG_INFO,
  -                      "jni.validate() java2opts %s\n", str_config); 
  -        _this->java2opts = jk2_map_split( env, NULL, _this->pool,
  -                                     str_config, "*", NULL);
  -    }
  -    int_config= jk2_map_getIntProp( env, props, NULL, prefix, "java2lax", -1 );
  -    if(int_config != -1 ) {
  -        _this->java2lax = int_config ? JK_TRUE : JK_FALSE;
  -    }
  -#endif
       return JK_TRUE;
   }
        
   int jk2_jk_vm_factory(jk_env_t *env, jk_pool_t *pool,
  -                   void **result,
  -                   char *type, char *name)
  +                      jk_bean_t *result,
  +                      char *type, char *name)
   {
       jk_vm_t *_this;
   
  @@ -793,7 +797,10 @@
       _this->attach=jk2_vm_attach;
       _this->detach=jk2_vm_detach;
       
  -    *result=_this;
  +    result->object=_this;
  +    result->setAttribute=jk2_jk_vm_setProperty;
  +    _this->mbean=result;
  +    
       return JK_TRUE;
   }
   
  @@ -857,15 +864,15 @@
   
   
   static void jk2_addDefaultLibPaths(jk_env_t *env, jk_map_t *props,
  -                                   jk_vm_t *jniw, char *prefix)
  +                                   jk_vm_t *jniw)
   {
       jk_pool_t *p=props->pool;
       const char **current=defaultLIB_PATH;
       char *libp;
   
       while( *current != NULL ) {
  -        libp = jk2_map_replaceProperties(env, props, p,
  -                                        p->pstrdup( env, p, *current ));
  +        libp = jk2_config_replaceProperties(env, props, p,
  +                                            p->pstrdup( env, p, *current ));
           if( libp!=NULL && jk2_jk_dir_exists(env, libp)) {
               env->l->jkLog(env, env->l, JK_LOG_INFO,
                             "jni.jk2_addDefaultLibPaths() %s\n", libp);
  
  
  
  1.5       +36 -30    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.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- jk_worker_jni.c   2 Mar 2002 06:13:42 -0000       1.4
  +++ jk_worker_jni.c   18 Mar 2002 18:45:25 -0000      1.5
  @@ -123,14 +123,15 @@
   }
   
   
  -static int JK_METHOD jk2_jni_worker_setProperty(jk_env_t *env, jk_worker_t *pThis,
  -                                                char *name, char *value)
  +static int JK_METHOD jk2_jni_worker_setProperty(jk_env_t *env, jk_bean_t *mbean,
  +                                                char *name, void *valueP)
   {
  +    jk_worker_t *pThis=mbean->object;
  +    char *value=valueP;
       jni_worker_data_t *jniWorker;
       int mem_config = 0;
       int rc;
       JNIEnv *jniEnv;
  -    char *prefix;
   
       if(! pThis || ! pThis->worker_private) {
           env->l->jkLog(env, env->l, JK_LOG_ERROR,
  @@ -140,6 +141,20 @@
   
       jniWorker = pThis->worker_private;
   
  +    if( strcmp( name, "class" )==0 ) {
  +        jniWorker->className = value;
  +    } else if( strcmp( name, "cmd_line" )==0 ) {
  +        jniWorker->tomcat_cmd_line = value;
  +    } else if( strcmp( name, "stdout" )==0 ) {
  +        jniWorker->stdout_name=value;
  +    } else if( strcmp( name, "lb_factor" )==0 ) {
  +        pThis->lb_factor=atof( value );
  +    } else if( strcmp( name, "stderr" )==0 ) {
  +        jniWorker->stderr_name=value;
  +    } else {
  +        return rc=jniWorker->vm->mbean->setAttribute(env, jniWorker->vm->mbean,
  +                                                     name, value );
  +    }
   
       return JK_TRUE;
   }
  @@ -163,13 +178,9 @@
   
       jniWorker = _this->worker_private;
       {
  -        char *prefix=(char *)_this->pool->alloc( env, _this->pool,
  -                                                 strlen( _this->name ) + 10 );
  -        strcpy( prefix, "worker." );
  -        strcat( prefix, _this->name );
  -        fprintf(stderr, "Prefix= %s\n", prefix );
  +        jniWorker->vm->properties=_this->workerEnv->initData;
           
  -        rc=jniWorker->vm->init(env, jniWorker->vm, _this->workerEnv->initData, 
prefix );
  +        rc=jniWorker->vm->init(env, jniWorker->vm );
           
           if( rc!=JK_TRUE ) {
               env->l->jkLog(env, env->l, JK_LOG_ERROR,
  @@ -177,19 +188,9 @@
               return JK_FALSE;
           }
       }
  -    
  -    jniWorker->className = jk2_map_getStrProp( env, props, "worker",
  -                                               _this->name,
  -                                               "class", JAVA_BRIDGE_CLASS_NAME);
  -    
  -    jniWorker->tomcat_cmd_line = jk2_map_getStrProp( env, props, "worker",
  -                                                    _this->name,
  -                                                    "cmd_line", NULL ); 
  -
  -    jniWorker->stdout_name= jk2_map_getStrProp( env, props, "worker",
  -                                               _this->name, "stdout", NULL ); 
  -    jniWorker->stderr_name= jk2_map_getStrProp( env, props, "worker",
  -                                               _this->name, "stderr", NULL );
  +        
  +    if( jniWorker->className==NULL )
  +        jniWorker->className=JAVA_BRIDGE_CLASS_NAME;
       
       env->l->jkLog(env, env->l, JK_LOG_INFO,
                     "jni.validate() cmd: %s %s %s %s\n",
  @@ -293,9 +294,11 @@
       jniWorker->vm->detach(env, jniWorker->vm); 
   
       _this->workerEnv->vm= jniWorker->vm;
  -        
  -    _this->channel=env->getInstance(env, _this->pool,"channel",
  -                                    "jni" );
  +
  +    /* We can have a single jni channel per instance, the name is
  +       hardcoded */
  +    _this->channel=env->createInstance(env, _this->pool,"channel.jni",
  +                                       "channel.jni");
       
       if( _this->channel == NULL ) {
           env->l->jkLog(env, env->l, JK_LOG_ERROR,
  @@ -355,7 +358,7 @@
   }
   
   int JK_METHOD jk2_worker_jni_factory(jk_env_t *env, jk_pool_t *pool,
  -                                     void **result,
  +                                     jk_bean_t *result,
                                        const char *type, const char *name)
   {
       jk_worker_t *_this;
  @@ -383,10 +386,9 @@
       _this->worker_private=jniData;
   
       _this->pool=pool;
  -    _this->name = _this->pool->pstrdup(env, _this->pool, name);
   
       /* XXX split it in VM11 and VM12 util */
  -    jk2_jk_vm_factory( env, pool, &jniData->vm, "vm", "default" );
  +    jniData->vm=env->createInstance( env, pool, "vm", "vm" );
       
       jniData->jk_java_bridge_class  = NULL;
       jniData->jk_startup_method     = NULL;
  @@ -396,13 +398,17 @@
       jniData->stdout_name           = NULL;
       jniData->stderr_name           = NULL;
   
  -    _this->setProperty       = jk2_jni_worker_setProperty;
       _this->init           = jk2_jni_worker_init;
       _this->destroy        = jk2_jni_worker_destroy;
       _this->service = jk2_jni_worker_service;
   
  -    *result = _this;
  +    result->object = _this;
  +    result->setAttribute = jk2_jni_worker_setProperty;
  +    _this->mbean=result;
   
  +    _this->workerEnv=env->getByName( env, "workerEnv" );
  +    _this->workerEnv->addWorker( env, _this->workerEnv, _this );
  +    
       env->l->jkLog(env, env->l, JK_LOG_INFO,
                     "jni.worker_factory() done\n");
   
  
  
  

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to