summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 4382a1e)
raw | patch | inline | side by side (parent: 4382a1e)
author | Florian Forster <octo@leeloo.lan.home.verplant.org> | |
Sun, 22 Feb 2009 18:10:56 +0000 (19:10 +0100) | ||
committer | Florian Forster <octo@leeloo.lan.home.verplant.org> | |
Sun, 22 Feb 2009 18:10:56 +0000 (19:10 +0100) |
bindings/java/org/collectd/api/Collectd.java | [new file with mode: 0644] | patch | blob |
bindings/java/org/collectd/api/CollectdAPI.java | [deleted file] | patch | blob | history |
src/collectd-java.pod | patch | blob | history | |
src/java.c | patch | blob | history |
diff --git a/bindings/java/org/collectd/api/Collectd.java b/bindings/java/org/collectd/api/Collectd.java
--- /dev/null
@@ -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 <octo at verplant.org>
+ */
+
+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
+++ /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 <octo at verplant.org>
- */
-
-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 013bf893391ec4631132c3dbb845ddbe90ae81c2..9326cb00c83acc02e5a3eba45b76c644f86db17a 100644 (file)
--- a/src/collectd-java.pod
+++ b/src/collectd-java.pod
need to B<import> the classes.
The API functions that are available from Java are implemented as I<static>
-functions of the B<org.collectd.api.CollectdAPI> class.
+functions of the B<org.collectd.api.Collectd> 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<CollectdAPI>,
+using the appropriate static functions in B<Collectd>,
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<org.collectd.api> namespace.
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;
{
public Foobar ()
{
- CollectdAPI.registerRead ("Foobar", this);
+ Collectd.registerRead ("Foobar", this);
}
public int read ()
/* 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 I<publicE<nbsp>static> functions of the B<org.collectd.api.CollectdAPI>
-class. This makes calling these functions pretty straight forward.
+as I<publicE<nbsp>static> functions of the B<org.collectd.api.Collectd> 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 d4acdab9c429a3d9330949c94e2e05df41033437..984d29a4c20d6da55315bf6bcf7bd28bef413d51 100644 (file)
--- a/src/java.c
+++ b/src/java.c
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);
}