From de21abb21ccf19ec4625d73ec1e7bbc8f630bad3 Mon Sep 17 00:00:00 2001 From: "roberto@oneiric64" Date: Mon, 6 Feb 2012 17:17:26 +0100 Subject: [PATCH] ported jvm plugin to the new options api --- plugins/jvm/jvm.h | 9 +-------- plugins/jvm/jvm_plugin.c | 38 +++++++------------------------------- plugins/jvm/uwsgiplugin.py | 4 ++-- uwsgi.c | 3 ++- 4 files changed, 12 insertions(+), 42 deletions(-) diff --git a/plugins/jvm/jvm.h b/plugins/jvm/jvm.h index 507c8f1c..02deb536 100644 --- a/plugins/jvm/jvm.h +++ b/plugins/jvm/jvm.h @@ -1,16 +1,9 @@ #include "../../uwsgi.h" #include -#define MAX_CLASSPATH 64 - -#define LONG_ARGS_JVM_BASE 17000 + (300 * 100) -#define LONG_ARGS_JVM_CLASS LONG_ARGS_JVM_BASE + 1 -#define LONG_ARGS_JVM_CLASSPATH LONG_ARGS_JVM_BASE + 2 - struct uwsgi_jvm { - char *classpath[MAX_CLASSPATH]; - int classpath_cnt; + struct uwsgi_string_list *classpath; JNIEnv *env; char *class; diff --git a/plugins/jvm/jvm_plugin.c b/plugins/jvm/jvm_plugin.c index 1546994a..0444bf12 100644 --- a/plugins/jvm/jvm_plugin.c +++ b/plugins/jvm/jvm_plugin.c @@ -12,8 +12,8 @@ This plugin is the core for all of the JVM-based ones struct uwsgi_jvm ujvm; struct uwsgi_option uwsgi_jvm_options[] = { - {"jvm-main-class", required_argument, 0, LONG_ARGS_JVM_CLASS}, - {"jvm-classpath", required_argument, 0, LONG_ARGS_JVM_CLASSPATH}, + {"jvm-main-class", required_argument, 0, "load the specified class", uwsgi_opt_set_str, &ujvm.class, 0}, + {"jvm-classpath", required_argument, 0, "add the specified directory to the classpath", uwsgi_opt_add_string_list, &ujvm.classpath, 0}, {0, 0, 0, 0}, }; @@ -89,7 +89,6 @@ int jvm_init(void) { JavaVMOption options[1]; jmethodID mmid; - int i; char *old_cp = NULL ; @@ -99,17 +98,17 @@ int jvm_init(void) { options[0].optionString = "-Djava.class.path=."; - if (ujvm.classpath_cnt > 0) { - for(i=0;ivalue); free(old_cp); } else { - options[0].optionString = uwsgi_concat3(options[0].optionString, ":", ujvm.classpath[i]); + options[0].optionString = uwsgi_concat3(options[0].optionString, ":", cp->value); } old_cp = options[0].optionString ; - } + cp = cp->next; } vm_args.options = options; @@ -201,34 +200,11 @@ int uwsgi_jvm_strlen2c(jobject obj) { return (*ujvm.env)->GetStringUTFLength(ujvm.env, obj); } -/* -int uwsgi_jvm_manage_opt(int i, char *optarg) { - - switch(i) { - case LONG_ARGS_JVM_CLASS: - ujvm.class = optarg; - return 1; - case LONG_ARGS_JVM_CLASSPATH: - if (ujvm.classpath_cnt < MAX_CLASSPATH) { - ujvm.classpath[ujvm.classpath_cnt] = optarg; - ujvm.classpath_cnt++; - } - else { - uwsgi_log( "you can specify at most %d --jvm-classpath options\n", MAX_CLASSPATH); - } - return 1; - } - - return 0; -} -*/ - struct uwsgi_plugin jvm_plugin = { .name = "jvm", .init = jvm_init, .options = uwsgi_jvm_options, - .manage_opt = uwsgi_jvm_manage_opt, }; diff --git a/plugins/jvm/uwsgiplugin.py b/plugins/jvm/uwsgiplugin.py index 578e7d28..8bb06c3c 100644 --- a/plugins/jvm/uwsgiplugin.py +++ b/plugins/jvm/uwsgiplugin.py @@ -13,8 +13,8 @@ NAME='jvm' # UWSGICONFIG_JVM_INCPATH="/usr/java/include -I /usr/java/include/solaris" UWSGICONFIG_JVM_LIBPATH="/usr/java/jre/lib/i386/" python uwsgiconfig.py --plugin plugins/jvm # Ubuntu -JVM_INCPATH = "/usr/lib/jvm/java-6-sun-1.6.0.15/include/ -I/usr/lib/jvm/java-6-sun-1.6.0.15/include/linux" -JVM_LIBPATH = "/usr/lib/jvm/java-6-sun-1.6.0.15/jre/lib/i386/server/" +JVM_INCPATH = "/usr/lib/jvm/java-6-openjdk/include/ -I/usr/lib/jvm/java-6-openjdk/include/linux" +JVM_LIBPATH = "/usr/lib/jvm/java-6-openjdk/jre/lib/amd64/server/" try: JVM_INCPATH = os.environ['UWSGICONFIG_JVM_INCPATH'] diff --git a/uwsgi.c b/uwsgi.c index 3d1d6b57..8923b86e 100644 --- a/uwsgi.c +++ b/uwsgi.c @@ -2,7 +2,7 @@ *** uWSGI *** - Copyright (C) 2009-2011 Unbit S.a.s. + Copyright (C) 2009-2012 Unbit S.a.s. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -327,6 +327,7 @@ static struct uwsgi_option uwsgi_base_options[] = { {"reuse-port", no_argument, 0, "enable REUSE_PORT flag on socket (BSD only)", uwsgi_opt_true, &uwsgi.reuse_port, 0}, {"zerg", required_argument, 0, "attach to a zerg server", uwsgi_opt_set_str, &uwsgi.zerg_node, 0}, {"zerg-server", required_argument, 0, "enable the zerg server on the specified UNIX socket", uwsgi_opt_set_str, &uwsgi.zerg_server, UWSGI_OPT_MASTER}, + // FUTURE additions //{"zerg-pool", required_argument, 0, "create a zerg pool", uwsgi_opt_zerg_pool, NULL, 0}, {"cron", required_argument, 0, "add a cron task", uwsgi_opt_add_cron, NULL, UWSGI_OPT_MASTER}, {"loop", required_argument, 0, "select the uWSGI loop engine", uwsgi_opt_set_str, &uwsgi.loop, 0},