summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Lucina <mato@kotelna.sk>2010-03-11 20:12:55 +0100
committerMartin Lucina <mato@kotelna.sk>2010-03-11 20:12:55 +0100
commit90944759b66771bbe399922eecedc5095fa2a509 (patch)
tree18ccec0d87f87082a023fa8bd77dae7c0010bb5d
parent9fda070e4d66d538e3c709c6cb8934cbf4442c29 (diff)
Removed Java binding from core distribution
-rw-r--r--Makefile.am4
-rw-r--r--bindings/Makefile.am7
-rwxr-xr-xbindings/java/Context.cpp112
-rw-r--r--bindings/java/Makefile.am72
-rwxr-xr-xbindings/java/Poller.cpp126
-rwxr-xr-xbindings/java/Socket.cpp345
-rwxr-xr-xbindings/java/org/zmq/Context.java58
-rwxr-xr-xbindings/java/org/zmq/Poller.java135
-rw-r--r--bindings/java/org/zmq/Socket.java134
-rw-r--r--configure.in73
-rw-r--r--perf/Makefile.am8
-rw-r--r--perf/java/Makefile.am5
-rw-r--r--perf/java/local_lat.java55
-rw-r--r--perf/java/local_thr.java71
-rw-r--r--perf/java/remote_lat.java60
-rw-r--r--perf/java/remote_thr.java57
16 files changed, 9 insertions, 1313 deletions
diff --git a/Makefile.am b/Makefile.am
index 7576725..090df33 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -4,8 +4,8 @@ if BUILD_PERF
DIR_PERF = perf
endif
-SUBDIRS = src doc $(DIR_PERF) devices bindings
-DIST_SUBDIRS = src doc perf devices bindings
+SUBDIRS = src doc $(DIR_PERF) devices
+DIST_SUBDIRS = src doc perf devices
EXTRA_DIST = \
$(top_srcdir)/foreign/openpgm/@pgm_basename@.tar.gz \
diff --git a/bindings/Makefile.am b/bindings/Makefile.am
deleted file mode 100644
index a923153..0000000
--- a/bindings/Makefile.am
+++ /dev/null
@@ -1,7 +0,0 @@
-if BUILD_JAVA
-DIR_J = java
-endif
-
-SUBDIRS = $(DIR_J)
-DIST_SUBDIRS = java
-
diff --git a/bindings/java/Context.cpp b/bindings/java/Context.cpp
deleted file mode 100755
index 5556ed8..0000000
--- a/bindings/java/Context.cpp
+++ /dev/null
@@ -1,112 +0,0 @@
-/*
- Copyright (c) 2007-2010 iMatix Corporation
-
- This file is part of 0MQ.
-
- 0MQ is free software; you can redistribute it and/or modify it under
- the terms of the Lesser GNU General Public License as published by
- the Free Software Foundation; either version 3 of the License, or
- (at your option) any later version.
-
- 0MQ 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
- Lesser GNU General Public License for more details.
-
- You should have received a copy of the Lesser GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#include <assert.h>
-#include <errno.h>
-
-#include "../c/zmq.h"
-
-#include "org_zmq_Context.h"
-
-/** Handle to Java's Context::contextHandle. */
-static jfieldID ctx_handle_fid = NULL;
-
-/**
- * Make sure we have a valid pointer to Java's Context::contextHandle.
- */
-static void ensure_context (JNIEnv *env, jobject obj)
-{
- if (ctx_handle_fid == NULL) {
- jclass cls = env->GetObjectClass (obj);
- assert (cls);
- ctx_handle_fid = env->GetFieldID (cls, "contextHandle", "J");
- assert (ctx_handle_fid);
- env->DeleteLocalRef (cls);
- }
-}
-
-/**
- * Get the value of Java's Context::contextHandle.
- */
-static void *get_context (JNIEnv *env, jobject obj)
-{
- ensure_context (env, obj);
- void *s = (void*) env->GetLongField (obj, ctx_handle_fid);
- return s;
-}
-
-/**
- * Set the value of Java's Context::contextHandle.
- */
-static void put_context (JNIEnv *env, jobject obj, void *s)
-{
- ensure_context (env, obj);
- env->SetLongField (obj, ctx_handle_fid, (jlong) s);
-}
-
-/**
- * Raise an exception that includes 0MQ's error message.
- */
-static void raise_exception (JNIEnv *env, int err)
-{
- // Get exception class.
- jclass exception_class = env->FindClass ("java/lang/Exception");
- assert (exception_class);
-
- // Get text description of the exception.
- const char *err_msg = zmq_strerror (err);
-
- // Raise the exception.
- int rc = env->ThrowNew (exception_class, err_msg);
- env->DeleteLocalRef (exception_class);
-
- assert (rc == 0);
-}
-
-/**
- * Called to construct a Java Context object.
- */
-JNIEXPORT void JNICALL Java_org_zmq_Context_construct (JNIEnv *env,
- jobject obj, jint app_threads, jint io_threads, jint flags)
-{
- void *c = get_context (env, obj);
- assert (!c);
-
- c = zmq_init (app_threads, io_threads, flags);
- put_context (env, obj, c);
-
- if (!c) {
- raise_exception (env, errno);
- return;
- }
-}
-
-/**
- * Called to destroy a Java Context object.
- */
-JNIEXPORT void JNICALL Java_org_zmq_Context_finalize (JNIEnv *env,
- jobject obj)
-{
- void *c = get_context (env, obj);
- assert (c);
-
- int rc = zmq_term (c);
- put_context (env, obj, NULL);
- assert (rc == 0);
-}
diff --git a/bindings/java/Makefile.am b/bindings/java/Makefile.am
deleted file mode 100644
index f2da01c..0000000
--- a/bindings/java/Makefile.am
+++ /dev/null
@@ -1,72 +0,0 @@
-# We do not want to install Jzmq.class file
-# user has to copy it to the right location.
-#jzmqdir = /tmp
-
-jarfile = Zmq.jar
-jardir = $(datadir)/java
-
-$(jarfile): $(dist_noinst_JAVA)
- $(JAR) cf $(JARFLAGS) $@ org/zmq/*.class
-
-jar_DATA = $(jarfile)
-
-dist_noinst_JAVA = \
- org/zmq/Context.java \
- org/zmq/Socket.java \
- org/zmq/Poller.java
-
-lib_LTLIBRARIES = libjzmq.la
-libjzmq_la_SOURCES = \
- Context.cpp \
- Socket.cpp \
- Poller.cpp
-nodist_libjzmq_la_SOURCES = \
- org_zmq_Context.h \
- org_zmq_Socket.h \
- org_zmq_Poller.h
-
-libjzmq_la_CXXFLAGS = @JAVA_INCLUDE@ -I$(top_srcdir)/bindings/c -Wall
-libjzmq_la_LDFLAGS = -version-info @JLTVER@
-libjzmq_la_LIBADD = $(top_builddir)/src/libzmq.la
-
-BUILT_SOURCES = \
- org/zmq/Context.class \
- org_zmq_Context.h \
- org/zmq/Socket.class \
- org_zmq_Socket.h \
- org/zmq/Poller.class \
- org_zmq_Poller.h
-
-CLEANFILES = \
- org/zmq/Context.class \
- org_zmq_Context.h \
- org/zmq/Socket.class \
- org_zmq_Socket.h \
- org/zmq/Poller.class \
- org_zmq_Poller.h \
- Zmq.jar
-
-$(srcdir)/Context.cpp: org_zmq_Context.h
-
-org_zmq_Context.h: org/zmq/Context.class
- $(CLASSPATH_ENV) $(JAVAH) -jni -classpath . org.zmq.Context
-
-./org/zmq/Context.class: classdist_noinst.stamp
-
-$(srcdir)/Socket.cpp: org_zmq_Socket.h
-
-org_zmq_Socket.h: org/zmq/Socket.class
- $(CLASSPATH_ENV) $(JAVAH) -jni -classpath . org.zmq.Socket
-
-./org/zmq/Socket.class: classdist_noinst.stamp
-
-$(srcdir)/Poller.cpp: org_zmq_Poller.h
-
-org_zmq_Poller.h: org/zmq/Poller.class
- $(CLASSPATH_ENV) $(JAVAH) -jni -classpath . org.zmq.Poller
-
-./org/zmq/Poller.class: classdist_noinst.stamp
-
-dist-hook:
- -rm $(distdir)/*.h
-
diff --git a/bindings/java/Poller.cpp b/bindings/java/Poller.cpp
deleted file mode 100755
index bf7a043..0000000
--- a/bindings/java/Poller.cpp
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
- Copyright (c) 2007-2010 iMatix Corporation
-
- This file is part of 0MQ.
-
- 0MQ is free software; you can redistribute it and/or modify it under
- the terms of the Lesser GNU General Public License as published by
- the Free Software Foundation; either version 3 of the License, or
- (at your option) any later version.
-
- 0MQ 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
- Lesser GNU General Public License for more details.
-
- You should have received a copy of the Lesser GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#include <assert.h>
-#include <errno.h>
-
-#include "../c/zmq.h"
-
-#include "org_zmq_Poller.h"
-
-static void *fetch_socket (JNIEnv *env, jobject socket);
-
-JNIEXPORT jlong JNICALL Java_org_zmq_Poller_run_1poll (JNIEnv *env,
- jobject obj,
- jint count,
- jobjectArray socket_0mq,
- jshortArray event_0mq,
- jshortArray revent_0mq,
- jlong timeout)
-{
- int ls = (int) count;
- if (ls <= 0)
- return 0;
-
- int ls_0mq = 0;
- int le_0mq = 0;
- int lr_0mq = 0;
-
- if (socket_0mq)
- ls_0mq = env->GetArrayLength (socket_0mq);
- if (event_0mq)
- le_0mq = env->GetArrayLength (event_0mq);
- if (revent_0mq)
- lr_0mq = env->GetArrayLength (revent_0mq);
-
- if (ls > ls_0mq || ls > le_0mq || ls > ls_0mq)
- return 0;
-
- zmq_pollitem_t *pitem = new zmq_pollitem_t [ls];
- short pc = 0;
- int rc = 0;
-
- // Add 0MQ sockets.
- if (ls_0mq > 0) {
- jshort *e_0mq = env->GetShortArrayElements (event_0mq, 0);
- if (e_0mq != NULL) {
- for (int i = 0; i < ls_0mq; ++i) {
- jobject s_0mq = env->GetObjectArrayElement (socket_0mq, i);
- if (!s_0mq)
- continue;
- void *s = fetch_socket (env, s_0mq);
- if (!s)
- continue;
- pitem [pc].socket = s;
- pitem [pc].fd = 0;
- pitem [pc].events = e_0mq [i];
- pitem [pc].revents = 0;
- ++pc;
- }
- env->ReleaseShortArrayElements(event_0mq, e_0mq, 0);
- }
- }
-
- if (pc == ls) {
- pc = 0;
- long tout = (long) timeout;
- rc = zmq_poll (pitem, ls, tout);
- }
-
- // Set 0MQ results.
- if (ls_0mq > 0) {
- jshort *r_0mq = env->GetShortArrayElements (revent_0mq, 0);
- if (r_0mq) {
- for (int i = 0; i < ls_0mq; ++i) {
- r_0mq [i] = pitem [pc].revents;
- ++pc;
- }
- env->ReleaseShortArrayElements(revent_0mq, r_0mq, 0);
- }
- }
-
- delete [] pitem;
- return rc;
-}
-
-/**
- * Get the value of socketHandle for the specified Java Socket.
- * TODO: move this to a single util.h file.
- */
-static void *fetch_socket (JNIEnv *env, jobject socket)
-{
- static jmethodID get_socket_handle_mid = NULL;
-
- if (get_socket_handle_mid == NULL) {
- jclass cls = env->GetObjectClass (socket);
- assert (cls);
- get_socket_handle_mid = env->GetMethodID (cls,
- "getSocketHandle", "()J");
- env->DeleteLocalRef (cls);
- assert (get_socket_handle_mid);
- }
-
- void *s = (void*) env->CallLongMethod (socket, get_socket_handle_mid);
- if (env->ExceptionCheck ()) {
- s = NULL;
- }
-
- assert (s);
- return s;
-}
diff --git a/bindings/java/Socket.cpp b/bindings/java/Socket.cpp
deleted file mode 100755
index 51c473d..0000000
--- a/bindings/java/Socket.cpp
+++ /dev/null
@@ -1,345 +0,0 @@
-/*
- Copyright (c) 2007-2010 iMatix Corporation
-
- This file is part of 0MQ.
-
- 0MQ is free software; you can redistribute it and/or modify it under
- the terms of the Lesser GNU General Public License as published by
- the Free Software Foundation; either version 3 of the License, or
- (at your option) any later version.
-
- 0MQ 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
- Lesser GNU General Public License for more details.
-
- You should have received a copy of the Lesser GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#include <string.h>
-#include <assert.h>
-#include <errno.h>
-
-#include "../../src/stdint.hpp"
-#include "../c/zmq.h"
-
-#include "org_zmq_Socket.h"
-
-/** Handle to Java's Socket::socketHandle. */
-static jfieldID socket_handle_fid = NULL;
-
-/**
- * Make sure we have a valid pointer to Java's Socket::socketHandle.
- */
-static void ensure_socket (JNIEnv *env, jobject obj)
-{
- if (socket_handle_fid == NULL) {
- jclass cls = env->GetObjectClass (obj);
- assert (cls);
- socket_handle_fid = env->GetFieldID (cls, "socketHandle", "J");
- assert (socket_handle_fid);
- env->DeleteLocalRef (cls);
- }
-}
-
-/**
- * Get the value of Java's Socket::socketHandle.
- */
-static void *get_socket (JNIEnv *env, jobject obj)
-{
- ensure_socket (env, obj);
- void *s = (void*) env->GetLongField (obj, socket_handle_fid);
- return s;
-}
-
-/**
- * Set the value of Java's Socket::socketHandle.
- */
-static void put_socket (JNIEnv *env, jobject obj, void *s)
-{
- ensure_socket (env, obj);
- env->SetLongField (obj, socket_handle_fid, (jlong) s);
-}
-
-/**
- * Get the value of contextHandle for the specified Java Context.
- */
-static void *fetch_context (JNIEnv *env, jobject context)
-{
- static jmethodID get_context_handle_mid = NULL;
-
- if (!get_context_handle_mid) {
- jclass cls = env->GetObjectClass (context);
- assert (cls);
- get_context_handle_mid = env->GetMethodID (cls,
- "getContextHandle", "()J");
- env->DeleteLocalRef (cls);
- assert (get_context_handle_mid);
- }
-
- void *c = (void*) env->CallLongMethod (context, get_context_handle_mid);
- if (env->ExceptionCheck ()) {
- c = NULL;
- }
-
- assert (c);
- return c;
-}
-
-/**
- * Raise an exception that includes 0MQ's error message.
- */
-static void raise_exception (JNIEnv *env, int err)
-{
- // Get exception class.
- jclass exception_class = env->FindClass ("java/lang/Exception");
- assert (exception_class);
-
- // Get text description of the exception.
- const char *err_msg = zmq_strerror (err);
-
- // Raise the exception.
- int rc = env->ThrowNew (exception_class, err_msg);
- env->DeleteLocalRef (exception_class);
-
- assert (rc == 0);
-}
-
-/**
- * Called to construct a Java Socket object.
- */
-JNIEXPORT void JNICALL Java_org_zmq_Socket_construct (JNIEnv *env,
- jobject obj, jobject context, jint type)
-{
- void *s = get_socket (env, obj);
- assert (! s);
-
- void *c = fetch_context (env, context);
- s = zmq_socket (c, type);
- put_socket(env, obj, s);
-
- if (s == NULL) {
- raise_exception (env, errno);
- return;
- }
-}
-
-/**
- * Called to destroy a Java Socket object.
- */
-JNIEXPORT void JNICALL Java_org_zmq_Socket_finalize (JNIEnv *env,
- jobject obj)
-{
- void *s = get_socket (env, obj);
- assert (s);
-
- int rc = zmq_close (s);
- put_socket (env, obj, NULL);
- assert (rc == 0);
-}
-
-/**
- * Called by Java's Socket::setsockopt(int option, long optval).
- */
-JNIEXPORT void JNICALL Java_org_zmq_Socket_setsockopt__IJ (JNIEnv *env,
- jobject obj, jint option, jlong optval)
-{
- switch (option) {
- case ZMQ_HWM:
- case ZMQ_LWM:
- case ZMQ_SWAP:
- case ZMQ_AFFINITY:
- case ZMQ_RATE:
- case ZMQ_RECOVERY_IVL:
- case ZMQ_MCAST_LOOP:
- {
- void *s = get_socket (env, obj);
- assert (s);
-
- int64_t value = optval;
- int rc = zmq_setsockopt (s, option, &value, sizeof (value));
- if (rc != 0)
- raise_exception (env, errno);
- return;
- }
- default:
- raise_exception (env, EINVAL);
- return;
- }
-}
-
-/**
- * Called by Java's Socket::setsockopt(int option, String optval).
- */
-JNIEXPORT void JNICALL Java_org_zmq_Socket_setsockopt__ILjava_lang_String_2 (
- JNIEnv *env, jobject obj, jint option, jstring optval)
-{
- switch (option) {
- case ZMQ_IDENTITY:
- case ZMQ_SUBSCRIBE:
- case ZMQ_UNSUBSCRIBE:
- {
- if (optval == NULL) {
- raise_exception (env, EINVAL);
- return;
- }
-
- void *s = get_socket (env, obj);
- assert (s);
-
- const char *value = env->GetStringUTFChars (optval, NULL);
- assert (value);
- int rc = zmq_setsockopt (s, option, value, strlen (value));
- env->ReleaseStringUTFChars (optval, value);
- if (rc != 0)
- raise_exception (env, errno);
- return;
- }
- default:
- raise_exception (env, EINVAL);
- return;
- }
-}
-
-/**
- * Called by Java's Socket::bind(String addr).
- */
-JNIEXPORT void JNICALL Java_org_zmq_Socket_bind (JNIEnv *env, jobject obj,
- jstring addr)
-{
- void *s = get_socket (env, obj);
- assert (s);
-
- if (addr == NULL) {
- raise_exception (env, EINVAL);
- return;
- }
-
- const char *c_addr = env->GetStringUTFChars (addr, NULL);
- if (c_addr == NULL) {
- raise_exception (env, EINVAL);
- return;
- }
-
- int rc = zmq_bind (s, c_addr);
- env->ReleaseStringUTFChars (addr, c_addr);
-
- if (rc == -1)
- raise_exception (env, errno);
-}
-
-/**
- * Called by Java's Socket::connect(String addr).
- */
-JNIEXPORT void JNICALL Java_org_zmq_Socket_connect (JNIEnv *env,
- jobject obj, jstring addr)
-{
- void *s = get_socket (env, obj);
- assert (s);
-
- if (addr == NULL) {
- raise_exception (env, EINVAL);
- return;
- }
-
- const char *c_addr = env->GetStringUTFChars (addr, NULL);
- if (c_addr == NULL) {
- raise_exception (env, EINVAL);
- return;
- }
-
- int rc = zmq_connect (s, c_addr);
- env->ReleaseStringUTFChars (addr, c_addr);
-
- if (rc == -1)
- raise_exception (env, errno);
-}
-
-/**
- * Called by Java's Socket::send(byte [] msg, long flags).
- */
-JNIEXPORT jboolean JNICALL Java_org_zmq_Socket_send (JNIEnv *env,
- jobject obj, jbyteArray msg, jlong flags)
-{
- void *s = get_socket (env, obj);
- assert (s);
-
- jsize size = env->GetArrayLength (msg);
- jbyte *data = env->GetByteArrayElements (msg, 0);
-
- zmq_msg_t message;
- int rc = zmq_msg_init_size (&message, size);
- assert (rc == 0);
- memcpy (zmq_msg_data (&message), data, size);
-
- env->ReleaseByteArrayElements (msg, data, 0);
-
- rc = zmq_send (s, &message, (int) flags);
-
- if (rc == -1 && errno == EAGAIN) {
- rc = zmq_msg_close (&message);
- assert (rc == 0);
- return JNI_FALSE;
- }
-
- if (rc == -1) {
- raise_exception (env, errno);
- rc = zmq_msg_close (&message);
- assert (rc == 0);
- return JNI_FALSE;
- }
-
- rc = zmq_msg_close (&message);
- assert (rc == 0);
- return JNI_TRUE;
-}
-
-/**
- * Called by Java's Socket::flush().
- */
-JNIEXPORT void JNICALL Java_org_zmq_Socket_flush (JNIEnv *env, jobject obj)
-{
- void *s = get_socket (env, obj);
- assert (s);
-
- int rc = zmq_flush (s);
-
- if (rc == -1) {
- raise_exception (env, errno);
- return ;
- }
-}
-
-/**
- * Called by Java's Socket::recv(long flags).
- */
-JNIEXPORT jbyteArray JNICALL Java_org_zmq_Socket_recv (JNIEnv *env,
- jobject obj, jlong flags)
-{
- void *s = get_socket (env, obj);
- assert (s);
-
- zmq_msg_t message;
- zmq_msg_init (&message);
- int rc = zmq_recv (s, &message, (int) flags);
-
- if (rc == -1 && errno == EAGAIN) {
- zmq_msg_close (&message);
- return NULL;
- }
-
- if (rc == -1) {
- raise_exception (env, errno);
- zmq_msg_close (&message);
- return NULL;
- }
-
- jbyteArray data = env->NewByteArray (zmq_msg_size (&message));
- assert (data);
- env->SetByteArrayRegion (data, 0, zmq_msg_size (&message),
- (jbyte*) zmq_msg_data (&message));
-
- return data;
-}
-
diff --git a/bindings/java/org/zmq/Context.java b/bindings/java/org/zmq/Context.java
deleted file mode 100755
index a727749..0000000
--- a/bindings/java/org/zmq/Context.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- Copyright (c) 2007-2010 iMatix Corporation
-
- This file is part of 0MQ.
-
- 0MQ is free software; you can redistribute it and/or modify it under
- the terms of the Lesser GNU General Public License as published by
- the Free Software Foundation; either version 3 of the License, or
- (at your option) any later version.
-
- 0MQ 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
- Lesser GNU General Public License for more details.
-
- You should have received a copy of the Lesser GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-package org.zmq;
-
-public class Context {
- static {
- System.loadLibrary("jzmq");
- }
-
- public static final int POLL = 1;
-
- /**
- * Class constructor.
- *
- * @param appThreads maximum number of application threads.
- * @param ioThreads size of the threads pool to handle I/O operations.
- */
- public Context (int appThreads, int ioThreads, int flags) {
- construct (appThreads, ioThreads, flags);
- }
-
- /** Initialize the JNI interface */
- protected native void construct (int appThreads, int ioThreads, int flags);
-
- /** Free all resources used by JNI interface. */
- protected native void finalize ();
-
- /**
- * Get the underlying context handle.
- * This is private because it is only accessed from JNI, where
- * Java access controls are ignored.
- *
- * @return the internal 0MQ context handle.
- */
- private long getContextHandle () {
- return contextHandle;
- }
-
- /** Opaque data used by JNI driver. */
- private long contextHandle;
-}
diff --git a/bindings/java/org/zmq/Poller.java b/bindings/java/org/zmq/Poller.java
deleted file mode 100755
index dd168b2..0000000
--- a/bindings/java/org/zmq/Poller.java
+++ /dev/null
@@ -1,135 +0,0 @@
-/*
- Copyright (c) 2007-2010 iMatix Corporation
-
- This file is part of 0MQ.
-
- 0MQ is free software; you can redistribute it and/or modify it under
- the terms of the Lesser GNU General Public License as published by
- the Free Software Foundation; either version 3 of the License, or
- (at your option) any later version.
-
- 0MQ 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
- Lesser GNU General Public License for more details.
-
- You should have received a copy of the Lesser GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-package org.zmq;
-
-public class Poller {
- static {
- System.loadLibrary("jzmq");
- }
-
- public static final int POLLIN = 1;
- public static final int POLLOUT = 2;
- public static final int POLLERR = 4;
-
- /**
- * Class constructor.
- *
- * @param context a 0MQ context previously created.
- */
- public Poller (Context context, int size) {
- this.context = context;
- this.size = size;
- this.next = 0;
-
- this.socket = new Socket[size];
- this.event = new short[size];
- this.revent = new short[size];
-
- for (int i = 0; i < size; ++i) {
- this.event[i] = (POLLIN | POLLOUT | POLLERR);
- }
- }
-
- public int register (Socket socket) {
- if (next >= size)
- return -1;
- this.socket[next] = socket;
- return next++;
- }
-
- public long getTimeout () {
- return this.timeout;
- }
-
- public void setTimeout (long timeout) {
- this.timeout = timeout;
- }
-
- public int getSize () {
- return this.size;
- }
-
- public int getNext () {
- return this.next;
- }
-
- /**
- * Issue a poll call.
- * @return how many objects where signalled by poll().
- */
- public long poll () {
- if (size <= 0 || next <= 0)
- return 0;
-
- for (int i = 0; i < next; ++i) {
- revent[i] = 0;
- }
-
- return run_poll(next, socket, event, revent, timeout);
- }
-
- public boolean pollin(int index) {
- return poll_mask(index, POLLIN);
- }
-
- public boolean pollout(int index) {
- return poll_mask(index, POLLOUT);
- }
-
- public boolean pollerr(int index) {
- return poll_mask(index, POLLERR);
- }
-
- /**
- * Issue a poll call on the specified 0MQ sockets.
- *
- * @param socket an array of 0MQ Socket objects to poll.
- * @param event an array of short values specifying what to poll for.
- * @param revent an array of short values with the results.
- * @param timeout the maximum timeout in microseconds.
- * @return how many objects where signalled by poll().
- */
- private native long run_poll(int count,
- Socket[] socket,
- short[] event,
- short[] revent,
- long timeout);
-
- /**
- * Check whether a specific mask was signalled by latest poll call.
- *
- * @param index the index indicating the socket.
- * @param mask a combination of POLLIN, POLLOUT and POLLERR.
- * @return true if specific socket was signalled as specified.
- */
- private boolean poll_mask(int index, int mask) {
- if (mask <= 0 || index < 0 || index >= next)
- return false;
- return (revent[index] & mask) > 0;
- }
-
- private Context context = null;
- private long timeout = 0;
- private int size = 0;
- private int next = 0;
- private Socket[] socket = null;
- private short[] event = null;
- private short[] revent = null;
-}
diff --git a/bindings/java/org/zmq/Socket.java b/bindings/java/org/zmq/Socket.java
deleted file mode 100644
index 851b7b8..0000000
--- a/bindings/java/org/zmq/Socket.java
+++ /dev/null
@@ -1,134 +0,0 @@
-/*
- Copyright (c) 2007-2010 iMatix Corporation
-
- This file is part of 0MQ.
-
- 0MQ is free software; you can redistribute it and/or modify it under
- the terms of the Lesser GNU General Public License as published by
- the Free Software Foundation; either version 3 of the License, or
- (at your option) any later version.
-
- 0MQ 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
- Lesser GNU General Public License for more details.
-
- You should have received a copy of the Lesser GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-package org.zmq;
-
-public class Socket {
- static {
- System.loadLibrary("jzmq");
- }
-
- public static final int NOBLOCK = 1;
- public static final int NOFLUSH = 2;
-
- public static final int P2P = 0;
- public static final int PUB = 1;
- public static final int SUB = 2;
- public static final int REQ = 3;
- public static final int REP = 4;
- public static final int XREQ = 5;
- public static final int XREP = 6;
- public static final int UPSTREAM = 7;
- public static final int DOWNSTREAM = 8;
-
- public static final int HWM = 1;
- public static final int LWM = 2;
- public static final int SWAP = 3;
- public static final int AFFINITY = 4;
- public static final int IDENTITY = 5;
- public static final int SUBSCRIBE = 6;
- public static final int UNSUBSCRIBE = 7;
- public static final int RATE = 8;
- public static final int RECOVERY_IVL = 9;
- public static final int MCAST_LOOP = 10;
- public static final int SNDBUF = 11;
- public static final int RCVBUF = 12;
-
- /**
- * Class constructor.
- *
- * @param context a 0MQ context previously created.
- * @param type the socket type.
- */
- public Socket (Context context, int type) {
- construct (context, type);
- }
-
- /**
- * Set the socket option value, given as a long.
- *
- * @param option ID of the option to set.
- * @param optval value (as a long) to set the option to.
- */
- public native void setsockopt (int option, long optval);
-
- /**
- * Set the socket option value, given as a String.
- *
- * @param option ID of the option to set.
- * @param optval value (as a String) to set the option to.
- */
- public native void setsockopt (int option, String optval);
-
- /**
- * Bind to network interface. Start listening for new connections.
- *
- * @param addr the endpoint to bind to.
- */
- public native void bind (String addr);
-
- /**
- * Connect to remote application.
- *
- * @param addr the endpoint to connect to.
- */
- public native void connect (String addr);
-
- /**
- * Send a message.
- *
- * @param msg the message to send, as an array of bytes.
- * @param flags the flags to apply to the send operation.
- * @return true if send was successful, false otherwise.
- */
- public native boolean send (byte [] msg, long flags);
-
- /**
- * Flush the messages down the stream.
- */
- public native void flush ();
-
- /**
- * Receive a message.
- *
- * @param flags the flags to apply to the receive operation.
- * @return the message received, as an array of bytes; null on error.
- */
- public native byte [] recv (long flags);
-
- /** Initialize the JNI interface */
- protected native void construct (Context context, int type);
-
- /** Free all resources used by JNI interface. */
- protected native void finalize ();
-
- /**
- * Get the underlying socket handle.
- * This is private because it is only accessed from JNI, where
- * Java access controls are ignored.
- *
- * @return the internal 0MQ socket handle.
- */
- private long getSocketHandle () {
- return socketHandle;
- }
-
- /** Opaque data used by JNI driver. */
- private long socketHandle;
-}
diff --git a/configure.in b/configure.in
index a101ec3..afee13d 100644
--- a/configure.in
+++ b/configure.in
@@ -37,13 +37,8 @@ AC_SUBST(PACKAGE_VERSION)
LTVER="0:0:0"
AC_SUBST(LTVER)
-# libjzmq -version-info
-JLTVER="0:0:0"
-AC_SUBST(JLTVER)
-
-AM_PROG_CC_C_O
-
# Checks for programs.
+AM_PROG_CC_C_O
AC_PROG_CXX
AC_LIBTOOL_WIN32_DLL
AC_PROG_LIBTOOL
@@ -309,61 +304,6 @@ if test "x$cpp" != "xno"; then
cppzmq="yes"
fi
-# Java language binding
-jzmq="no"
-AC_ARG_WITH([java], [AS_HELP_STRING([--with-java], [build Java language binding [default=no]])], [with_java=yes], [with_java=no])
-if test "x$with_java" != "xno"; then
- AC_PATH_PROG(JAVAC, javac, "no",[$PATH:$JAVA_HOME/bin])
- if test "x$JAVAC" = "xno"; then
- AC_MSG_ERROR([the --with-java option requires that javac be on the path.]);
- fi
-
- AC_PATH_PROG(JAVAH, javah, "no",[$PATH:$JAVA_HOME/bin])
- if test "x$JAVAH" = "xno"; then
- AC_MSG_ERROR([the --with-java option requires that javah be on the path.]);
- fi
-
- AC_PATH_PROG(JAR, jar, "no", [$PATH:$JAVA_HOME/bin])
- if test "x$JAR" = "xno"; then
- AC_MSG_ERROR([the --with-java option requires that jar be on the path.]);
- fi
-
- if test "x$JAVA_HOME" = "x"; then
- AC_MSG_ERROR([the --with-java option requires the JAVA_HOME environment variable be set to your JDK location.]);
- fi
-
- AC_MSG_CHECKING([for jni.h in a $JAVA_HOME/include dir])
- if test -f $JAVA_HOME/include/jni.h; then
- AC_MSG_RESULT([yes])
- else
- AC_MSG_ERROR([cannot find jni.h in the $JAVA_HOME/include directory.]);
- fi
-
- JAVAROOT=./
- AC_SUBST(JAVAROOT)
-
- case "${host_os}" in
- *solaris*)
- JAVA_INCLUDE="-I.. -I${JAVA_HOME}/include -I ${JAVA_HOME}/include/solaris"
- ;;
- *openbsd*)
- JAVA_INCLUDE="-I.. -I${JAVA_HOME}/include -I ${JAVA_HOME}/include/openbsd"
- ;;
- *)
- JAVA_INCLUDE="-I.. -I${JAVA_HOME}/include -I ${JAVA_HOME}/include/linux"
- ;;
- esac
-
- AC_SUBST(JAVA_INCLUDE)
-
- jzmq="yes"
-else
-# Workaround to be able to run make dist without real JAVAH
- JAVAH=true
- JAVAC=true
- JAR=true
-fi
-
# PGM extension
pgm_ext="no"
@@ -491,8 +431,7 @@ AC_ARG_WITH([perf], [AS_HELP_STRING([--with-perf],
if test "x$with_perf" != "xno"; then
perf="yes"
- if test "x$czmq" = "xno" -a "x$cppzmq" = "xno" -a \
- "x$jzmq" = "xno"; then
+ if test "x$czmq" = "xno" -a "x$cppzmq" = "xno"; then
AC_MSG_ERROR([the --with-perf option requires at least one language binding.]);
fi
fi
@@ -501,7 +440,6 @@ if test "x$with_perf" = "xno" -a "x$with_pgm_examples" = "xyes"; then
AC_MSG_ERROR([cannot configure --with-pgm-examples without --with-perf.]);
fi
-AM_CONDITIONAL(BUILD_JAVA, test "x$jzmq" = "xyes")
AM_CONDITIONAL(BUILD_C, test "x$czmq" = "xyes")
AM_CONDITIONAL(BUILD_CPP, test "x$cppzmq" = "xyes")
AM_CONDITIONAL(BUILD_PGM, test "x$pgm_ext" = "xyes")
@@ -528,10 +466,10 @@ AC_TYPE_SIGNAL
AC_CHECK_FUNCS(perror gettimeofday memset socket getifaddrs freeifaddrs)
AC_OUTPUT(Makefile src/Makefile doc/Makefile
- bindings/java/Makefile perf/Makefile perf/c/Makefile perf/cpp/Makefile \
- perf/java/Makefile src/libzmq.pc \
+ perf/Makefile perf/c/Makefile perf/cpp/Makefile \
+ src/libzmq.pc \
devices/Makefile devices/zmq_forwarder/Makefile \
- devices/zmq_streamer/Makefile devices/zmq_queue/Makefile bindings/Makefile)
+ devices/zmq_streamer/Makefile devices/zmq_queue/Makefile)
# On Linux patch libtool to delete hardcoded paths (rpath).
case "${host_os}" in
@@ -557,7 +495,6 @@ AC_MSG_RESULT([ 0MQ install dir: $prefix])
AC_MSG_RESULT([ Language bindings:])
AC_MSG_RESULT([ C: $czmq])
AC_MSG_RESULT([ C++: $cppzmq])
-AC_MSG_RESULT([ Java: $jzmq])
AC_MSG_RESULT([ Transports:])
AC_MSG_RESULT([ tcp: yes])
AC_MSG_RESULT([ pgm (epgm): $pgm_ext])
diff --git a/perf/Makefile.am b/perf/Makefile.am
index 72d24be..87c4833 100644
--- a/perf/Makefile.am
+++ b/perf/Makefile.am
@@ -6,9 +6,5 @@ if BUILD_CPP
PERF_DIR_CPP = cpp
endif
-if BUILD_JAVA
-PERF_DIR_J = java
-endif
-
-SUBDIRS = $(PERF_DIR_C) $(PERF_DIR_CPP) $(PERF_DIR_J)
-DIST_SUBDIRS = c cpp java
+SUBDIRS = $(PERF_DIR_C) $(PERF_DIR_CPP)
+DIST_SUBDIRS = c cpp
diff --git a/perf/java/Makefile.am b/perf/java/Makefile.am
deleted file mode 100644
index 4f370b8..0000000
--- a/perf/java/Makefile.am
+++ /dev/null
@@ -1,5 +0,0 @@
-AM_JAVACFLAGS=-classpath $(top_builddir)/bindings/java
-
-dist_noinst_JAVA = local_lat.java remote_lat.java local_thr.java \
-remote_thr.java
-
diff --git a/perf/java/local_lat.java b/perf/java/local_lat.java
deleted file mode 100644
index d886d4f..0000000
--- a/perf/java/local_lat.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- Copyright (c) 2007-2010 iMatix Corporation
-
- This file is part of 0MQ.
-
- 0MQ is free software; you can redistribute it and/or modify it under
- the terms of the Lesser GNU General Public License as published by
- the Free Software Foundation; either version 3 of the License, or
- (at your option) any later version.
-
- 0MQ 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
- Lesser GNU General Public License for more details.
-
- You should have received a copy of the Lesser GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-import org.zmq.*;
-
-class local_lat
-{
- public static void main (String [] args)
- {
- if (args.length != 3) {
- System.out.println ("usage: local_lat <bind-to> " +
- "<message-size> <roundtrip-count>");
- return;
- }
-
- String bindTo = args [0];
- int messageSize = Integer.parseInt (args [1]);
- int roundtripCount = Integer.parseInt (args [2]);
-
- org.zmq.Context ctx = new org.zmq.Context (1, 1, 0);
-
- org.zmq.Socket s = new org.zmq.Socket (ctx, org.zmq.Socket.REP);
- s.bind (bindTo);
-
- for (int i = 0; i != roundtripCount; i++) {
- byte [] data = s.recv (0);
- assert (data.length == messageSize);
- s.send (data, 0);
- }
-
- try {
- Thread.sleep (1000);
- }
- catch (InterruptedException e) {
- e.printStackTrace ();
- }
-
- }
-}
diff --git a/perf/java/local_thr.java b/perf/java/local_thr.java
deleted file mode 100644
index e1c205d..0000000
--- a/perf/java/local_thr.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- Copyright (c) 2007-2010 iMatix Corporation
-
- This file is part of 0MQ.
-
- 0MQ is free software; you can redistribute it and/or modify it under
- the terms of the Lesser GNU General Public License as published by
- the Free Software Foundation; either version 3 of the License, or
- (at your option) any later version.
-
- 0MQ 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
- Lesser GNU General Public License for more details.
-
- You should have received a copy of the Lesser GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-import org.zmq.*;
-
-class local_thr
-{
- public static void main (String [] args)
- {
- if (args.length != 3) {
- System.out.println ("usage: local_thr <bind-to> " +
- "<message size> <message count>");
- return;
- }
-
- String bindTo = args [0];
- long messageSize = Integer.parseInt (args [1]);
- long messageCount = Integer.parseInt (args [2]);
-
- org.zmq.Context ctx = new org.zmq.Context (1, 1, 0);
-
- org.zmq.Socket s = new org.zmq.Socket (ctx, org.zmq.Socket.SUB);
-
- s.setsockopt (org.zmq.Socket.SUBSCRIBE , "");
-
- // Add your socket options here.
- // For example ZMQ_RATE, ZMQ_RECOVERY_IVL and ZMQ_MCAST_LOOP for PGM.
-
- s.bind (bindTo);
-
- byte [] data = s.recv (0);
- assert (data.length == messageSize);
-
- long start = System.currentTimeMillis ();
-
- for (int i = 1; i != messageCount; i ++) {
- data = s.recv (0);
- assert (data.length == messageSize);
- }
-
- long end = System.currentTimeMillis ();
-
- long elapsed = (end - start) * 1000;
- if (elapsed == 0)
- elapsed = 1;
-
- long throughput = messageCount * 1000000 / elapsed;
- double megabits = (double) (throughput * messageSize * 8) / 1000000;
-
- System.out.println ("message size: " + messageSize + " [B]");
- System.out.println ("message count: " + messageCount);
- System.out.println ("mean throughput: " + throughput + "[msg/s]");
- System.out.println ("mean throughput: " + megabits + "[Mb/s]");
- }
-}
diff --git a/perf/java/remote_lat.java b/perf/java/remote_lat.java
deleted file mode 100644
index 1db0520..0000000
--- a/perf/java/remote_lat.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- Copyright (c) 2007-2010 iMatix Corporation
-
- This file is part of 0MQ.
-
- 0MQ is free software; you can redistribute it and/or modify it under
- the terms of the Lesser GNU General Public License as published by
- the Free Software Foundation; either version 3 of the License, or
- (at your option) any later version.
-
- 0MQ 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
- Lesser GNU General Public License for more details.
-
- You should have received a copy of the Lesser GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-import org.zmq.*;
-
-class remote_lat
-{
- public static void main (String [] args)
- {
- if (args.length != 3) {
- System.out.println ("usage: remote_lat <connect-to> " +
- "<message size> <roundtrip count>");
- return;
- }
-
- String connectTo = args [0];
- int messageSize = Integer.parseInt (args [1]);
- int roundtripCount = Integer.parseInt (args [2]);
-
- org.zmq.Context ctx = new org.zmq.Context (1, 1, 0);
-
- org.zmq.Socket s = new org.zmq.Socket (ctx, org.zmq.Socket.REQ);
- s.connect (connectTo);
-
- long start = System.currentTimeMillis ();
-
- byte data [] = new byte [messageSize];
- for (int i = 0; i != roundtripCount; i ++) {
- s.send (data, 0);
- data = s.recv (0);
- assert (data.length == messageSize);
- }
-
- long end = System.currentTimeMillis ();
-
- long elapsed = (end - start) * 1000;
- double latency = (double) elapsed / roundtripCount / 2;
-
- System.out.println ("message size: " + messageSize + " [B]");
- System.out.println ("roundtrip count: " + roundtripCount);
- System.out.println ("mean latency: " + latency + " [us]");
- }
-}
-
diff --git a/perf/java/remote_thr.java b/perf/java/remote_thr.java
deleted file mode 100644
index f1b5124..0000000
--- a/perf/java/remote_thr.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- Copyright (c) 2007-2010 iMatix Corporation
-
- This file is part of 0MQ.
-
- 0MQ is free software; you can redistribute it and/or modify it under
- the terms of the Lesser GNU General Public License as published by
- the Free Software Foundation; either version 3 of the License, or
- (at your option) any later version.
-
- 0MQ 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
- Lesser GNU General Public License for more details.
-
- You should have received a copy of the Lesser GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-import org.zmq.*;
-
-class remote_thr
-{
- public static void main (String [] args)
- {
- if (args.length != 3) {
- System.out.println ("usage: remote_thr <connect-to> " +
- "<message-size> <message-count>");
- return;
- }
-
- // Parse the command line arguments.
- String connectTo = args [0];
- int messageSize = Integer.parseInt (args [1]);
- int messageCount = Integer.parseInt (args [2]);
-
- org.zmq.Context ctx = new org.zmq.Context (1, 1, 0);
-
- org.zmq.Socket s = new org.zmq.Socket (ctx, org.zmq.Socket.PUB);
-
- // Add your socket options here.
- // For example ZMQ_RATE, ZMQ_RECOVERY_IVL and ZMQ_MCAST_LOOP for PGM.
-
- s.connect (connectTo);
-
- byte msg [] = new byte [messageSize];
- for (int i = 0; i != messageCount; i++)
- s.send (msg, 0);
-
- try {
- Thread.sleep (10000);
- }
- catch (InterruptedException e) {
- e.printStackTrace ();
- }
- }
-}