Code

core: Changed internal API to allow for per-plugin intervals.
[collectd.git] / src / java.c
index b69ca946b301c36a367c114e98666c7b33e69acd..5d5893c2f645dfd0694787f8771d17e0096f7e00 100644 (file)
@@ -1325,7 +1325,7 @@ static int jtoc_notification (JNIEnv *jvm_env, notification_t *n, /* {{{ */
 static jint JNICALL cjni_api_dispatch_values (JNIEnv *jvm_env, /* {{{ */
     jobject this, jobject java_vl)
 {
-  value_list_t vl = VALUE_LIST_INIT;
+  value_list_t vl = VALUE_LIST_INIT (plugin_interval);
   int status;
 
   DEBUG ("cjni_api_dispatch_values: java_vl = %p;", (void *) java_vl);
@@ -1410,6 +1410,8 @@ static jint JNICALL cjni_api_register_read (JNIEnv *jvm_env, /* {{{ */
   user_data_t ud;
   cjni_callback_info_t *cbi;
 
+  struct timespec cb_interval;
+
   cbi = cjni_callback_info_create (jvm_env, o_name, o_read, CB_TYPE_READ);
   if (cbi == NULL)
     return (-1);
@@ -1420,8 +1422,13 @@ static jint JNICALL cjni_api_register_read (JNIEnv *jvm_env, /* {{{ */
   ud.data = (void *) cbi;
   ud.free_func = cjni_callback_info_destroy;
 
-  plugin_register_complex_read (/* group = */ NULL, cbi->name, cjni_read,
-      /* interval = */ NULL, &ud);
+  CDTIME_T_TO_TIMESPEC (plugin_interval, &cb_interval);
+
+  plugin_register_complex_read (/* group = */ NULL,
+      /* name = */ cbi->name,
+      /* callback = */ cjni_read,
+      /* interval = */ (plugin_interval != 0) ? &cb_interval : NULL,
+      /* user_data = */ &ud);
 
   (*jvm_env)->DeleteLocalRef (jvm_env, o_read);
 
@@ -3101,11 +3108,12 @@ static int cjni_init (void) /* {{{ */
   return (0);
 } /* }}} int cjni_init */
 
-void module_register (void)
+void module_register (plugin_loaddata_t *data)
 {
+  PLUGIN_INIT_INTERVAL (data);
   plugin_register_complex_config ("java", cjni_config_callback);
   plugin_register_init ("java", cjni_init);
   plugin_register_shutdown ("java", cjni_shutdown);
-} /* void module_register (void) */
+} /* void module_register (plugin_loaddata_t *data) */
 
 /* vim: set sw=2 sts=2 et fdm=marker : */