Split the JNI APIs in separate classes
authorAlexandre Montplaisir <alexmonthy@efficios.com>
Mon, 4 Jan 2016 20:11:11 +0000 (15:11 -0500)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Fri, 12 Feb 2016 22:54:29 +0000 (17:54 -0500)
Isolate the "native" methods in their own class, to better reflect
what is present in the equivalent C files.

Signed-off-by: Alexandre Montplaisir <alexmonthy@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
.gitignore
liblttng-ust-java-agent/java/lttng-ust-agent-jul/Makefile.am
liblttng-ust-java-agent/java/lttng-ust-agent-jul/org/lttng/ust/agent/jul/LttngJulApi.java [new file with mode: 0644]
liblttng-ust-java-agent/java/lttng-ust-agent-jul/org/lttng/ust/agent/jul/LttngLogHandler.java
liblttng-ust-java-agent/java/lttng-ust-agent-log4j/Makefile.am
liblttng-ust-java-agent/java/lttng-ust-agent-log4j/org/lttng/ust/agent/log4j/LttngLog4jApi.java [new file with mode: 0644]
liblttng-ust-java-agent/java/lttng-ust-agent-log4j/org/lttng/ust/agent/log4j/LttngLogAppender.java
liblttng-ust-java-agent/jni/jul/Makefile.am
liblttng-ust-java-agent/jni/jul/lttng_ust_jul.c
liblttng-ust-java-agent/jni/log4j/Makefile.am
liblttng-ust-java-agent/jni/log4j/lttng_ust_log4j.c

index 287d9e7ac2f4f9bc25e67f9796d962b171f2dba0..d480867e5288fdabe86862df7f5cf95a05f197d7 100644 (file)
@@ -61,8 +61,8 @@ classnoinst.stamp
 jni-header.stamp
 jul-jni-header.stamp
 log4j-jni-header.stamp
-org_lttng_ust_agent_jul_LttngLogHandler.h
-org_lttng_ust_agent_log4j_LttngLogAppender.h
+org_lttng_ust_agent_jul_LttngJulApi.h
+org_lttng_ust_agent_log4j_LttngLog4jApi.h
 
 # Python agent
 python-lttngust/lttngust/__init__.py
index d32e1d69ffd9dad593def6ee5497edf82ac5daac..c0316e23a65b9ffeaa6d8196cd4121076f156feb 100644 (file)
@@ -13,6 +13,7 @@ jardir = $(datadir)/java
 juljniout = ../../jni/jul
 
 dist_noinst_JAVA = $(pkgpath)/LttngJulAgent.java \
+                                  $(pkgpath)/LttngJulApi.java \
                                   $(pkgpath)/LttngLogHandler.java
 
 dist_noinst_DATA = $(jarfile_manifest)
@@ -26,7 +27,7 @@ $(jarfile): classnoinst.stamp
        $(JAR) cfm $(JARFLAGS) $@ $(jarfile_manifest) $(classes) && rm -f $(jarfile_symlink) && $(LN_S) $@ $(jarfile_symlink)
 
 jul-jni-header.stamp: $(dist_noinst_JAVA)
-       $(JAVAH) -classpath $(CLASSPATH):$(srcdir) -d $(juljniout) $(JAVAHFLAGS) org.lttng.ust.agent.jul.LttngLogHandler && \
+       $(JAVAH) -classpath $(CLASSPATH):$(srcdir) -d $(juljniout) $(JAVAHFLAGS) org.lttng.ust.agent.jul.LttngJulApi && \
        echo "JUL JNI header generated" > jul-jni-header.stamp
 
 all-local: $(stamp)
@@ -38,4 +39,4 @@ uninstall-hook:
        cd $(DESTDIR)/$(jardir) && rm -f $(jarfile_symlink)
 
 CLEANFILES = $(jarfile) $(pkgpath)/*.class jul-jni-header.stamp \
-       $(juljniout)/org_lttng_ust_agent_jul_LttngLogHandler.h
+       $(juljniout)/org_lttng_ust_agent_jul_LttngJulApi.h
diff --git a/liblttng-ust-java-agent/java/lttng-ust-agent-jul/org/lttng/ust/agent/jul/LttngJulApi.java b/liblttng-ust-java-agent/java/lttng-ust-agent-jul/org/lttng/ust/agent/jul/LttngJulApi.java
new file mode 100644 (file)
index 0000000..f8a29d6
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2016 - EfficiOS Inc., Alexandre Montplaisir <alexmonthy@efficios.com>
+ *
+ * This library is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License, version 2.1 only,
+ * as published by the Free Software Foundation.
+ *
+ * This library 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 Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.lttng.ust.agent.jul;
+
+/**
+ * Virtual class containing the Java side of the LTTng-JUL JNI API methods.
+ *
+ * @author Alexandre Montplaisir
+ */
+final class LttngJulApi {
+
+       private LttngJulApi() {}
+
+       static native void tracepoint(String msg,
+                       String logger_name,
+                       String class_name,
+                       String method_name,
+                       long millis,
+                       int log_level,
+                       int thread_id);
+}
index 39e08a831d51614ec3e5bcd4bc8e9d338ab7456e..3e61fe957471266ad3991f9e25d40f440ac83edd 100644 (file)
@@ -123,7 +123,7 @@ public class LttngLogHandler extends Handler implements ILttngHandler {
                 * caller is used for the event name, the raw message is taken, the
                 * loglevel of the record and the thread ID.
                 */
-               tracepoint(formattedMessage,
+               LttngJulApi.tracepoint(formattedMessage,
                                record.getLoggerName(),
                                record.getSourceClassName(),
                                record.getSourceMethodName(),
@@ -132,12 +132,4 @@ public class LttngLogHandler extends Handler implements ILttngHandler {
                                record.getThreadID());
        }
 
-       /* Send tracepoint information to the JNI library */
-       private native void tracepoint(String msg,
-                       String logger_name,
-                       String class_name,
-                       String method_name,
-                       long millis,
-                       int log_level,
-                       int thread_id);
 }
index 9ae532330b74093a18e8d60691f122352a69328f..c05f2129f9d2e63dc2be48dcfd1503cdc6ff6d6e 100644 (file)
@@ -13,6 +13,7 @@ jardir = $(datadir)/java
 log4jjniout = ../../jni/log4j
 
 dist_noinst_JAVA = $(pkgpath)/LttngLog4jAgent.java \
+                                  $(pkgpath)/LttngLog4jApi.java \
                                   $(pkgpath)/LttngLogAppender.java
 
 dist_noinst_DATA = $(jarfile_manifest)
@@ -26,7 +27,7 @@ $(jarfile): classnoinst.stamp
        $(JAR) cfm $(JARFLAGS) $@ $(jarfile_manifest) $(classes) && rm -f $(jarfile_symlink) && $(LN_S) $@ $(jarfile_symlink)
 
 log4j-jni-header.stamp: $(dist_noinst_JAVA)
-       $(JAVAH) -classpath $(CLASSPATH):$(srcdir) -d $(log4jjniout) $(JAVAHFLAGS) org.lttng.ust.agent.log4j.LttngLogAppender && \
+       $(JAVAH) -classpath $(CLASSPATH):$(srcdir) -d $(log4jjniout) $(JAVAHFLAGS) org.lttng.ust.agent.log4j.LttngLog4jApi && \
        echo "Log4j JNI header generated" > log4j-jni-header.stamp
 
 all-local: $(stamp)
@@ -38,4 +39,4 @@ uninstall-hook:
        cd $(DESTDIR)/$(jardir) && rm -f $(jarfile_symlink)
 
 CLEANFILES = $(jarfile) $(pkgpath)/*.class log4j-jni-header.stamp \
-       $(log4jjniout)/org_lttng_ust_agent_log4j_LttngLogAppender.h
+       $(log4jjniout)/org_lttng_ust_agent_log4j_LttngLog4jApi.h
diff --git a/liblttng-ust-java-agent/java/lttng-ust-agent-log4j/org/lttng/ust/agent/log4j/LttngLog4jApi.java b/liblttng-ust-java-agent/java/lttng-ust-agent-log4j/org/lttng/ust/agent/log4j/LttngLog4jApi.java
new file mode 100644 (file)
index 0000000..2521e9f
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2016 - EfficiOS Inc., Alexandre Montplaisir <alexmonthy@efficios.com>
+ *
+ * This library is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License, version 2.1 only,
+ * as published by the Free Software Foundation.
+ *
+ * This library 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 Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.lttng.ust.agent.log4j;
+
+/**
+ * Virtual class containing the Java side of the LTTng-log4j JNI API methods.
+ *
+ * @author Alexandre Montplaisir
+ */
+final class LttngLog4jApi {
+
+       private LttngLog4jApi() {}
+
+       static native void tracepoint(String msg,
+                       String logger_name,
+                       String class_name,
+                       String method_name,
+                       String file_name,
+                       int line_number,
+                       long timestamp,
+                       int loglevel,
+                       String thread_name);
+}
index 98cc2c8dc583065d1c2b9829e6dd06fc346ac6a7..753a5df34fc9f5642027e16527281ec051aabe4e 100644 (file)
@@ -117,7 +117,8 @@ public class LttngLogAppender extends AppenderSkeleton implements ILttngHandler
                }
 
                eventCount.incrementAndGet();
-               tracepoint(event.getRenderedMessage(),
+
+               LttngLog4jApi.tracepoint(event.getRenderedMessage(),
                                event.getLoggerName(),
                                event.getLocationInformation().getClassName(),
                                event.getLocationInformation().getMethodName(),
@@ -128,15 +129,4 @@ public class LttngLogAppender extends AppenderSkeleton implements ILttngHandler
                                event.getThreadName());
        }
 
-
-       /* Use for a user session daemon. */
-       private native void tracepoint(String msg,
-                       String logger_name,
-                       String class_name,
-                       String method_name,
-                       String file_name,
-                       int line_number,
-                       long timestamp,
-                       int loglevel,
-                       String thread_name);
 }
index 40906e10ca0b191712a7bcf8da9c612acccfa31d..cd0b7dc3ea01c85a19c26491fb3d6f069d4e19bf 100644 (file)
@@ -4,6 +4,6 @@ lib_LTLIBRARIES = liblttng-ust-jul-jni.la
 liblttng_ust_jul_jni_la_SOURCES = lttng_ust_jul.c \
                                  lttng_ust_jul.h
 
-nodist_liblttng_ust_jul_jni_la_SOURCES = org_lttng_ust_agent_jul_LttngLogHandler.h
+nodist_liblttng_ust_jul_jni_la_SOURCES = org_lttng_ust_agent_jul_LttngJulApi.h
 
 liblttng_ust_jul_jni_la_LIBADD = -lc -L$(top_builddir)/liblttng-ust/.libs -llttng-ust
index 0e86fbc7c1d0637597df3f84e927f61027da5379..a0e893e5f2eca5d641b4b7251b8e29c4a4a2cd6a 100644 (file)
@@ -16,7 +16,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-#include "org_lttng_ust_agent_jul_LttngLogHandler.h"
+#include "org_lttng_ust_agent_jul_LttngJulApi.h"
 
 #define TRACEPOINT_DEFINE
 #define TRACEPOINT_CREATE_PROBES
@@ -25,7 +25,7 @@
 /*
  * Tracepoint used by Java applications using the JUL handler.
  */
-JNIEXPORT void JNICALL Java_org_lttng_ust_agent_jul_LttngLogHandler_tracepoint(JNIEnv *env,
+JNIEXPORT void JNICALL Java_org_lttng_ust_agent_jul_LttngJulApi_tracepoint(JNIEnv *env,
                                                jobject jobj,
                                                jstring msg,
                                                jstring logger_name,
index 07384f8d6a6759b197985bf0e21b35a2dff588b8..5030a03f7d1c459ecf3192d2f70369159b5d0d62 100644 (file)
@@ -3,6 +3,6 @@ lib_LTLIBRARIES = liblttng-ust-log4j-jni.la
 liblttng_ust_log4j_jni_la_SOURCES = lttng_ust_log4j.c \
                                  lttng_ust_log4j.h
 
-nodist_liblttng_ust_log4j_jni_la_SOURCES = org_lttng_ust_agent_log4j_LttngLogAppender.h
+nodist_liblttng_ust_log4j_jni_la_SOURCES = org_lttng_ust_agent_log4j_LttngLog4jApi.h
 
 liblttng_ust_log4j_jni_la_LIBADD = -lc -L$(top_builddir)/liblttng-ust/.libs -llttng-ust
index 73d4eee7a9383453fd9d966d7d7907aeb6d89b80..3b78c8e5911f6845b4836ed1cb1e5b38354c8812 100644 (file)
@@ -16,7 +16,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-#include "org_lttng_ust_agent_log4j_LttngLogAppender.h"
+#include "org_lttng_ust_agent_log4j_LttngLog4jApi.h"
 
 #define TRACEPOINT_DEFINE
 #define TRACEPOINT_CREATE_PROBES
@@ -25,7 +25,7 @@
 /*
  * System tracepoint meaning only root agent will fire this.
  */
-JNIEXPORT void JNICALL Java_org_lttng_ust_agent_log4j_LttngLogAppender_tracepoint(JNIEnv *env,
+JNIEXPORT void JNICALL Java_org_lttng_ust_agent_log4j_LttngLog4jApi_tracepoint(JNIEnv *env,
                                                jobject jobj,
                                                jstring msg,
                                                jstring logger_name,
This page took 0.030386 seconds and 4 git commands to generate.