From: Florian Forster Date: Sun, 22 Feb 2009 18:10:56 +0000 (+0100) Subject: java plugin: Rename `CollectdAPI' to `Collectd'. X-Git-Tag: collectd-4.7.0~127^2~21 X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=d3733caf0686008ac5130e2f81fa30d60993c63c;p=collectd.git java plugin: Rename `CollectdAPI' to `Collectd'. --- diff --git a/bindings/java/org/collectd/api/Collectd.java b/bindings/java/org/collectd/api/Collectd.java new file mode 100644 index 00000000..70629595 --- /dev/null +++ b/bindings/java/org/collectd/api/Collectd.java @@ -0,0 +1,109 @@ +/* + * collectd/java - org/collectd/api/Collectd.java + * Copyright (C) 2009 Florian octo Forster + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; only version 2 of the License is applicable. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * Authors: + * Florian octo Forster + */ + +package org.collectd.api; + +/** + * Java API to internal functions of collectd. + * + * @author Florian Forster <octo at verplant.org> + */ +public class Collectd +{ + private static final int LOG_ERR = 3; + private static final int LOG_WARNING = 4; + private static final int LOG_NOTICE = 5; + private static final int LOG_INFO = 6; + private static final int LOG_DEBUG = 7; + + /** + * Java representation of collectd/src/plugin.h:plugin_register_config + */ + native public static int registerConfig (String name, + CollectdConfigInterface object); + + /** + * Java representation of collectd/src/plugin.h:plugin_register_init + */ + native public static int registerInit (String name, + CollectdInitInterface object); + + /** + * Java representation of collectd/src/plugin.h:plugin_register_read + */ + native public static int registerRead (String name, + CollectdReadInterface object); + + /** + * Java representation of collectd/src/plugin.h:plugin_register_write + */ + native public static int registerWrite (String name, + CollectdWriteInterface object); + + /** + * Java representation of collectd/src/plugin.h:plugin_register_shutdown + */ + native public static int registerShutdown (String name, + CollectdShutdownInterface object); + + /** + * Java representation of collectd/src/plugin.h:plugin_dispatch_values + */ + native public static int dispatchValues (ValueList vl); + + /** + * Java representation of collectd/src/plugin.h:plugin_get_ds + */ + native public static DataSet getDS (String type); + + /** + * Java representation of collectd/src/plugin.h:plugin_log + */ + native private static void log (int severity, String message); + + public static void logError (String message) + { + log (LOG_ERR, message); + } /* void logError */ + + public static void logWarning (String message) + { + log (LOG_WARNING, message); + } /* void logWarning */ + + public static void logNotice (String message) + { + log (LOG_NOTICE, message); + } /* void logNotice */ + + public static void logInfo (String message) + { + log (LOG_INFO, message); + } /* void logInfo */ + + public static void logDebug (String message) + { + log (LOG_DEBUG, message); + } /* void logDebug */ + +} /* class Collectd */ + +/* vim: set sw=2 sts=2 et fdm=marker : */ diff --git a/bindings/java/org/collectd/api/CollectdAPI.java b/bindings/java/org/collectd/api/CollectdAPI.java deleted file mode 100644 index 3d713bac..00000000 --- a/bindings/java/org/collectd/api/CollectdAPI.java +++ /dev/null @@ -1,109 +0,0 @@ -/* - * collectd/java - org/collectd/api/CollectdAPI.java - * Copyright (C) 2009 Florian octo Forster - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; only version 2 of the License is applicable. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * Authors: - * Florian octo Forster - */ - -package org.collectd.api; - -/** - * Java API to internal functions of collectd. - * - * @author Florian Forster <octo at verplant.org> - */ -public class CollectdAPI -{ - private static final int LOG_ERR = 3; - private static final int LOG_WARNING = 4; - private static final int LOG_NOTICE = 5; - private static final int LOG_INFO = 6; - private static final int LOG_DEBUG = 7; - - /** - * Java representation of collectd/src/plugin.h:plugin_register_config - */ - native public static int registerConfig (String name, - CollectdConfigInterface object); - - /** - * Java representation of collectd/src/plugin.h:plugin_register_init - */ - native public static int registerInit (String name, - CollectdInitInterface object); - - /** - * Java representation of collectd/src/plugin.h:plugin_register_read - */ - native public static int registerRead (String name, - CollectdReadInterface object); - - /** - * Java representation of collectd/src/plugin.h:plugin_register_write - */ - native public static int registerWrite (String name, - CollectdWriteInterface object); - - /** - * Java representation of collectd/src/plugin.h:plugin_register_shutdown - */ - native public static int registerShutdown (String name, - CollectdShutdownInterface object); - - /** - * Java representation of collectd/src/plugin.h:plugin_dispatch_values - */ - native public static int dispatchValues (ValueList vl); - - /** - * Java representation of collectd/src/plugin.h:plugin_get_ds - */ - native public static DataSet getDS (String type); - - /** - * Java representation of collectd/src/plugin.h:plugin_log - */ - native private static void log (int severity, String message); - - public static void logError (String message) - { - log (LOG_ERR, message); - } /* void logError */ - - public static void logWarning (String message) - { - log (LOG_WARNING, message); - } /* void logWarning */ - - public static void logNotice (String message) - { - log (LOG_NOTICE, message); - } /* void logNotice */ - - public static void logInfo (String message) - { - log (LOG_INFO, message); - } /* void logInfo */ - - public static void logDebug (String message) - { - log (LOG_DEBUG, message); - } /* void logDebug */ - -} /* class CollectdAPI */ - -/* vim: set sw=2 sts=2 et fdm=marker : */ diff --git a/src/collectd-java.pod b/src/collectd-java.pod index 013bf893..9326cb00 100644 --- a/src/collectd-java.pod +++ b/src/collectd-java.pod @@ -68,14 +68,14 @@ example B. In order to be able to use these abbreviated names, you need to B the classes. The API functions that are available from Java are implemented as I -functions of the B class. +functions of the B class. See L<"CALLING API FUNCTIONS"> below for details. =head1 REGISTERING CALLBACKS When starting up, collectd creates an object of each configured class. The constructor of this class should then register "callbacks" with the daemon, -using the appropriate static functions in B, +using the appropriate static functions in B, see L<"CALLING API FUNCTIONS"> below. To register a callback, the object being passed to one of the register functions must implement an appropriate interface, which are all in the B namespace. @@ -165,7 +165,7 @@ considered an error condition and cause an appropriate message to be logged. This short example demonstrates how to register a read callback with the daemon: - import org.collectd.api.CollectdAPI; + import org.collectd.api.Collectd; import org.collectd.api.ValueList; import org.collectd.api.CollectdReadInterface; @@ -174,7 +174,7 @@ daemon: { public Foobar () { - CollectdAPI.registerRead ("Foobar", this); + Collectd.registerRead ("Foobar", this); } public int read () @@ -183,15 +183,15 @@ daemon: /* Do something... */ - CollectdAPI.dispatchValues (vl); + Collectd.dispatchValues (vl); } } =head1 CALLING API FUNCTIONS All collectd API functions that are available to Java plugins are implemented -as Istatic> functions of the B -class. This makes calling these functions pretty straight forward. +as Istatic> functions of the B class. +This makes calling these functions pretty straight forward. The following are the currently exported functions. For information on the interfaces used, please see L<"REGISTERING CALLBACKS"> above. diff --git a/src/java.c b/src/java.c index d4acdab9..984d29a4 100644 --- a/src/java.c +++ b/src/java.c @@ -2141,10 +2141,10 @@ static int cjni_init_native (JNIEnv *jvm_env) /* {{{ */ jclass api_class_ptr; int status; - api_class_ptr = (*jvm_env)->FindClass (jvm_env, "org.collectd.api.CollectdAPI"); + api_class_ptr = (*jvm_env)->FindClass (jvm_env, "org.collectd.api.Collectd"); if (api_class_ptr == NULL) { - ERROR ("cjni_init_native: Cannot find API class `org.collectd.api.CollectdAPI'."); + ERROR ("cjni_init_native: Cannot find API class `org.collectd.api.Collectd'."); return (-1); }