{GPL, other}: Relicense to MIT license.
[collectd.git] / bindings / java / org / collectd / api / Collectd.java
1 /**
2  * collectd - bindings/java/org/collectd/api/Collectd.java
3  * Copyright (C) 2009       Florian octo Forster
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining a
6  * copy of this software and associated documentation files (the "Software"),
7  * to deal in the Software without restriction, including without limitation
8  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9  * and/or sell copies of the Software, and to permit persons to whom the
10  * Software is furnished to do so, subject to the following conditions:
11  *
12  * The above copyright notice and this permission notice shall be included in
13  * all copies or substantial portions of the Software.
14  *
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21  * DEALINGS IN THE SOFTWARE.
22  *
23  * Authors:
24  *   Florian octo Forster <octo at collectd.org>
25  */
26
27 package org.collectd.api;
28
29 /**
30  * Java API to internal functions of collectd.
31  *
32  * All functions in this class are {@code static}. You don't need to create an
33  * object of this class (in fact, you can't). Just call these functions
34  * directly.
35  *
36  * @author Florian Forster &lt;octo at collectd.org&gt;
37  */
38 public class Collectd
39 {
40
41   /**
42    * Constant for severity (log level) "error".
43    *
44    * @see CollectdLogInterface
45    */
46   public static final int LOG_ERR     = 3;
47
48   /**
49    * Constant for severity (log level) "warning".
50    *
51    * @see CollectdLogInterface
52    */
53   public static final int LOG_WARNING = 4;
54
55   /**
56    * Constant for severity (log level) "notice".
57    *
58    * @see CollectdLogInterface
59    */
60   public static final int LOG_NOTICE  = 5;
61
62   /**
63    * Constant for severity (log level) "info".
64    *
65    * @see CollectdLogInterface
66    */
67   public static final int LOG_INFO    = 6;
68
69   /**
70    * Constant for severity (log level) "debug".
71    *
72    * @see CollectdLogInterface
73    */
74   public static final int LOG_DEBUG   = 7;
75
76   /**
77    * Return value of match methods: No match.
78    *
79    * This is one of two valid return values from match callbacks, indicating
80    * that the passed {@link DataSet} and {@link ValueList} did not match.
81    *
82    * Do not use the numeric value directly, it is subject to change without
83    * notice!
84    *
85    * @see CollectdMatchInterface
86    */
87   public static final int FC_MATCH_NO_MATCH  = 0;
88
89   /**
90    * Return value of match methods: Match.
91    *
92    * This is one of two valid return values from match callbacks, indicating
93    * that the passed {@link DataSet} and {@link ValueList} did match.
94    *
95    * Do not use the numeric value directly, it is subject to change without
96    * notice!
97    *
98    * @see CollectdMatchInterface
99    */
100   public static final int FC_MATCH_MATCHES   = 1;
101
102   /**
103    * Return value of target methods: Continue.
104    *
105    * This is one of three valid return values from target callbacks, indicating
106    * that processing of the {@link ValueList} should continue.
107    *
108    * Do not use the numeric value directly, it is subject to change without
109    * notice!
110    *
111    * @see CollectdTargetInterface
112    */
113   public static final int FC_TARGET_CONTINUE = 0;
114
115   /**
116    * Return value of target methods: Stop.
117    *
118    * This is one of three valid return values from target callbacks, indicating
119    * that processing of the {@link ValueList} should stop immediately.
120    *
121    * Do not use the numeric value directly, it is subject to change without
122    * notice!
123    *
124    * @see CollectdTargetInterface
125    */
126   public static final int FC_TARGET_STOP     = 1;
127
128   /**
129    * Return value of target methods: Return.
130    *
131    * This is one of three valid return values from target callbacks, indicating
132    * that processing of the current chain should be stopped and processing of
133    * the {@link ValueList} should continue in the calling chain.
134    *
135    * Do not use the numeric value directly, it is subject to change without
136    * notice!
137    *
138    * @see CollectdTargetInterface
139    */
140   public static final int FC_TARGET_RETURN   = 2;
141
142   /**
143    * Java representation of collectd/src/plugin.h:plugin_register_config
144    *
145    * @return Zero when successful, non-zero otherwise.
146    * @see CollectdConfigInterface
147    */
148   native public static int registerConfig (String name,
149       CollectdConfigInterface object);
150
151   /**
152    * Java representation of collectd/src/plugin.h:plugin_register_init
153    *
154    * @return Zero when successful, non-zero otherwise.
155    * @see CollectdInitInterface
156    */
157   native public static int registerInit (String name,
158       CollectdInitInterface object);
159
160   /**
161    * Java representation of collectd/src/plugin.h:plugin_register_read
162    *
163    * @return Zero when successful, non-zero otherwise.
164    * @see CollectdReadInterface
165    */
166   native public static int registerRead (String name,
167       CollectdReadInterface object);
168
169   /**
170    * Java representation of collectd/src/plugin.h:plugin_register_write
171    *
172    * @return Zero when successful, non-zero otherwise.
173    * @see CollectdWriteInterface
174    */
175   native public static int registerWrite (String name,
176       CollectdWriteInterface object);
177
178   /**
179    * Java representation of collectd/src/plugin.h:plugin_register_flush
180    *
181    * @return Zero when successful, non-zero otherwise.
182    * @see CollectdFlushInterface
183    */
184   native public static int registerFlush (String name,
185       CollectdFlushInterface object);
186
187   /**
188    * Java representation of collectd/src/plugin.h:plugin_register_shutdown
189    *
190    * @return Zero when successful, non-zero otherwise.
191    * @see CollectdShutdownInterface
192    */
193   native public static int registerShutdown (String name,
194       CollectdShutdownInterface object);
195
196   /**
197    * Java representation of collectd/src/plugin.h:plugin_register_log
198    *
199    * @return Zero when successful, non-zero otherwise.
200    * @see CollectdLogInterface
201    */
202   native public static int registerLog (String name,
203       CollectdLogInterface object);
204
205   /**
206    * Java representation of collectd/src/plugin.h:plugin_register_notification
207    *
208    * @return Zero when successful, non-zero otherwise.
209    * @see CollectdNotificationInterface
210    */
211   native public static int registerNotification (String name,
212       CollectdNotificationInterface object);
213
214   /**
215    * Java representation of collectd/src/filter_chain.h:fc_register_match
216    *
217    * @return Zero when successful, non-zero otherwise.
218    * @see CollectdMatchFactoryInterface
219    */
220   native public static int registerMatch (String name,
221       CollectdMatchFactoryInterface object);
222
223   /**
224    * Java representation of collectd/src/filter_chain.h:fc_register_target
225    *
226    * @return Zero when successful, non-zero otherwise.
227    * @see CollectdTargetFactoryInterface
228    */
229   native public static int registerTarget (String name,
230       CollectdTargetFactoryInterface object);
231
232   /**
233    * Java representation of collectd/src/plugin.h:plugin_dispatch_values
234    *
235    * @return Zero when successful, non-zero otherwise.
236    */
237   native public static int dispatchValues (ValueList vl);
238
239   /**
240    * Java representation of collectd/src/plugin.h:plugin_dispatch_notification
241    *
242    * @return Zero when successful, non-zero otherwise.
243    */
244   native public static int dispatchNotification (Notification n);
245
246   /**
247    * Java representation of collectd/src/plugin.h:plugin_get_ds
248    *
249    * @return The appropriate {@link DataSet} object or {@code null} if no such
250    * type is registered.
251    */
252   native public static DataSet getDS (String type);
253
254   /**
255    * Java representation of collectd/src/plugin.h:plugin_log
256    */
257   native private static void log (int severity, String message);
258
259   /**
260    * Prints an error message.
261    */
262   public static void logError (String message)
263   {
264     log (LOG_ERR, message);
265   } /* void logError */
266
267   /**
268    * Prints a warning message.
269    */
270   public static void logWarning (String message)
271   {
272     log (LOG_WARNING, message);
273   } /* void logWarning */
274
275   /**
276    * Prints a notice.
277    */
278   public static void logNotice (String message)
279   {
280     log (LOG_NOTICE, message);
281   } /* void logNotice */
282
283   /**
284    * Prints an info message.
285    */
286   public static void logInfo (String message)
287   {
288     log (LOG_INFO, message);
289   } /* void logInfo */
290
291   /**
292    * Prints a debug message.
293    */
294   public static void logDebug (String message)
295   {
296     log (LOG_DEBUG, message);
297   } /* void logDebug */
298 } /* class Collectd */
299
300 /* vim: set sw=2 sts=2 et fdm=marker : */