├── .gitignore
├── .java-version
├── .travis.yml
├── AUTHORS
├── CONTRIBUTING.md
├── COPYING
├── COPYING.LESSER
├── Changelog.md
├── README.md
├── jzmq-core
├── pom.xml
└── src
│ ├── main
│ └── java
│ │ └── org
│ │ └── zeromq
│ │ ├── Utils.java
│ │ ├── ZAuth.java
│ │ ├── ZCert.java
│ │ ├── ZCertStore.java
│ │ ├── ZConfig.java
│ │ ├── ZContext.java
│ │ ├── ZDispatcher.java
│ │ ├── ZFrame.java
│ │ ├── ZLoop.java
│ │ ├── ZMsg.java
│ │ └── ZThread.java
│ └── test
│ └── java
│ └── org
│ └── zeromq
│ ├── TestUtils.java
│ ├── ZAuthTest.java
│ ├── ZCertStoreTest.java
│ ├── ZConfigTest.java
│ ├── ZContextTest.java
│ ├── ZDispatcherTest.java
│ ├── ZFrameTest.java
│ ├── ZLoopTest.java
│ ├── ZMsgTest.java
│ └── ZThreadTest.java
├── jzmq-devices
├── pom.xml
└── src
│ ├── main
│ └── java
│ │ └── org
│ │ └── zeromq
│ │ ├── ZMQForwarder.java
│ │ ├── ZMQQueue.java
│ │ └── ZMQStreamer.java
│ └── test
│ └── java
│ └── org
│ └── zeromq
│ ├── ZMQForwarderTest.java
│ └── ZMQQueueTest.java
├── jzmq-jni
├── AUTHORS
├── CMakeLists.txt
├── COPYING
├── COPYING.LESSER
├── ChangeLog
├── Dockerfile
├── Makefile.am
├── NEWS
├── README
├── README-PERF
├── autogen.sh
├── builds
│ └── msvc
│ │ ├── config.hpp
│ │ ├── jzmq
│ │ ├── jzmq.vcproj
│ │ └── jzmq.vcxproj
│ │ ├── local_lat
│ │ ├── local_lat.vcproj
│ │ └── local_lat.vcxproj
│ │ ├── local_thr
│ │ ├── local_thr.vcproj
│ │ └── local_thr.vcxproj
│ │ ├── msvc.sln
│ │ ├── remote_lat
│ │ ├── remote_lat.vcproj
│ │ └── remote_lat.vcxproj
│ │ └── remote_thr
│ │ ├── remote_thr.vcproj
│ │ └── remote_thr.vcxproj
├── config
│ └── ax_jni_include_dir.m4
├── configure.in
├── debian
│ ├── changelog
│ ├── compat
│ ├── control
│ ├── copyright
│ ├── docs
│ ├── jzmq.install
│ └── rules
├── jzmq.spec
├── nativejar.xml
├── pom.xml
└── src
│ ├── main
│ ├── c++
│ │ ├── Context.cpp
│ │ ├── Curve.cpp
│ │ ├── Event.cpp
│ │ ├── Makefile.am
│ │ ├── Poller.cpp
│ │ ├── Socket.cpp
│ │ ├── ZMQ.cpp
│ │ ├── jzmq.hpp
│ │ ├── util.cpp
│ │ └── util.hpp
│ ├── java
│ │ └── org
│ │ │ └── zeromq
│ │ │ ├── App.java
│ │ │ ├── EmbeddedLibraryTools.java
│ │ │ ├── ZMQ.java
│ │ │ └── ZMQException.java
│ └── perf
│ │ ├── Makefile.am
│ │ ├── local_lat.java
│ │ ├── local_lat.sh
│ │ ├── local_thr.java
│ │ ├── local_thr.sh
│ │ ├── remote_lat.java
│ │ ├── remote_lat.sh
│ │ ├── remote_thr.java
│ │ └── remote_thr.sh
│ └── test
│ ├── java
│ └── org
│ │ └── zeromq
│ │ ├── EmbeddedLibraryToolsTest.java
│ │ └── ZMQTest.java
│ └── resources
│ └── NATIVE
│ └── testarch
│ └── Linux
│ ├── foo.dll
│ ├── libjzmq.so
│ └── libzmq.so
├── jzmq
└── pom.xml
├── maven.readme
└── pom.xml
/.gitignore:
--------------------------------------------------------------------------------
1 | Makefile.in
2 | perf/Makefile.in
3 | src/Makefile.in
4 | Makefile
5 | aclocal.m4
6 | autom4te.cache
7 | autoscan.log
8 | configure
9 | config.log
10 | config.status
11 | configure.scan
12 | libtool
13 | *.stamp
14 | stamp-*
15 | *.class
16 | .deps
17 | .libs
18 | *.la
19 | *.o
20 | *.lo
21 | *~
22 | src/main/c++/config.hpp.in
23 | src/main/c++/config.hpp
24 | src/main/c++/org_zeromq_*.h
25 | lib/
26 | target/
27 | .classpath
28 | .idea
29 | .project
30 | .settings/
31 | build-stamp
32 | configure-stamp
33 | builds/msvc/msvc.ncb
34 | builds/msvc/msvc.suo
35 | builds/msvc/jzmq/jzmq.vcproj.*
36 | builds/msvc/local_lat/local_lat.vcproj.*
37 | builds/msvc/local_thr/local_thr.vcproj.*
38 | builds/msvc/remote_lat/remote_lat.vcproj.*
39 | builds/msvc/remote_thr/remote_thr.vcproj.*
40 | builds/msvc/jzmq/Debug/
41 | builds/msvc/local_lat/Debug/
42 | builds/msvc/local_thr/Debug/
43 | builds/msvc/remote_lat/Debug/
44 | builds/msvc/remote_thr/Debug/
45 | builds/msvc/jzmq/Release/
46 | builds/msvc/local_lat/Release/
47 | builds/msvc/local_thr/Release/
48 | builds/msvc/remote_lat/Release/
49 | builds/msvc/remote_thr/Release/
50 | debian/files
51 | debian/jzmq.debhelper.log
52 | debian/jzmq.postinst.debhelper
53 | debian/jzmq.postrm.debhelper
54 | debian/jzmq.substvars
55 | debian/jzmq/
56 | debian/tmp/
57 | .DS_Store
58 | *.iml
59 | config/
60 | build/
61 | builds/msvc/Debug/
62 | builds/msvc/Release/
63 | builds/msvc/UpgradeLog.XML
64 | builds/msvc/_UpgradeReport_Files/
65 | builds/msvc/jzmq/*.dll
66 | builds/msvc/jzmq/jzmq.vcxproj*
67 | builds/msvc/msvc.sdf
68 | builds/msvc/*.lib
69 | builds/msvc/*.dll
70 | builds/msvc/local_lat/local_lat.vcxproj*
71 | builds/msvc/local_thr/local_thr.vcxproj*
72 | builds/msvc/remote_lat/remote_lat.vcxproj*
73 | builds/msvc/remote_thr/remote_thr.vcxproj*
74 | perf/*.dll
75 | \#*
76 | .\#*
77 | *.jar
78 | INSTALL
79 | .checkstyle
80 | javac_stamp
81 | javah_stamp
82 | .tags*
83 | *.sublime-project
84 | *.sublime-workspace
85 |
--------------------------------------------------------------------------------
/.java-version:
--------------------------------------------------------------------------------
1 | 1.7
2 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | addons:
2 | # hostname monkeying needed for openjdk, see travis-ci/travis-ci#5227 for details
3 | hosts:
4 | - myshorthost
5 | hostname: myshorthost
6 | before_install:
7 | - sudo add-apt-repository ppa:trevorbernard/zeromq -y
8 | - sudo apt-get update -y
9 | - sudo apt-get install libpgm-dev make build-essential pkg-config libtool automake -y
10 | - git clone git://github.com/jedisct1/libsodium.git
11 | - cd libsodium
12 | - ./autogen.sh
13 | - ./configure && make
14 | - sudo make install
15 | - sudo ldconfig
16 | - cd ..
17 | - git clone https://github.com/zeromq/libzmq.git
18 | - cd libzmq
19 | - ./autogen.sh
20 | - ./configure --with-libsodium && make
21 | - sudo make install
22 | - sudo ldconfig
23 | - cd ..
24 | - cd jzmq-jni
25 | - ./autogen.sh
26 | - ./configure
27 | - make
28 | - sudo make install
29 | - cd ..
30 | install: mvn install --quiet -DskipTests=true -Dgpg.skip=true
31 | language: java
32 |
33 | script: mvn test
34 |
35 | jdk:
36 | - openjdk6
37 | - openjdk7
38 | - oraclejdk8
39 |
--------------------------------------------------------------------------------
/AUTHORS:
--------------------------------------------------------------------------------
1 | Contributors
2 | ============
3 |
4 | Alexej Lotz
5 | Asko Kauppi
6 | Barak Amar
7 | Bernd Prager
8 | Chris Busbey
9 | Chris Wong
10 | Conrad D. Steenberg
11 | Dhruva Krishnamurthy
12 | Dirk O. Kaar
13 | Erich Heine
14 | Erik Rigtorp
15 | Frank Denis
16 | George Neill
17 | Gonzalo Diethelm
18 | Joe Thornber
19 | Jon Dyte
20 | Kamil Shakirov
21 | Luke Palmer
22 | Martin Hurton
23 | Martin Lucina
24 | Martin Sustrik
25 | Mario Steinhoff
26 | Matus Hamorsky
27 | McClain Looney
28 | Pavel Gushcha
29 | Pavol Malosek
30 | Steven McCoy
31 | Tamara Kustarova
32 | Tero Marttila
33 | Terry Wilson
34 | Thomas Trocha
35 | Trevor Bernard
36 | Vitaly Mayatskikh
37 |
38 | Credits
39 | =======
40 |
41 | Aamir Mohammad
42 | Aleksey Yeschenko
43 | Alexander Majorov
44 | Bernd Schumacher
45 | Brett Cameron
46 | Brian Granger
47 | Carsten Dinkelmann
48 | David Bahi
49 | Dirk Eddelbuettel
50 | Evgueny Khartchenko
51 | Frank Vanden Berghen
52 | John Apps
53 | Markus Fischer
54 | Matt Muggeridge
55 | Paulo Henrique Silva
56 | Peter Busser
57 | Peter Lemenkov
58 | Robert Zhang
59 |
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | # Contributing to JZMQ
2 |
3 | The contributors are listed in AUTHORS (add yourself). This project uses the LGPL v3 license, see COPYING.
4 |
5 | JZMQ uses the [C4.1 (Collective Code Construction Contract)](http://rfc.zeromq.org/spec:22) process for contributions. Please read this if you are unfamiliar with it.
6 |
7 | JZMQ grows by the slow and careful accretion of simple, minimal solutions to real problems faced by many people. Some people seem to not understand this. So in case of doubt:
8 |
9 | * Each patch defines one clear and agreed problem, and one clear, minimal, plausible solution. If you come with a large, complex problem and a large, complex solution, you will provoke a negative reaction from JZMQ maintainers and users.
10 |
11 | * We will usually merge patches aggressively, without a blocking review. If you send us bad patches, without taking the care to read and understand our rules, that reflects on you. Do NOT expect us to do your homework for you.
12 |
13 | * As rapidly we will merge poor quality patches, we will remove them again. If you insist on arguing about this and trying to justify your changes, we will simply ignore you and your patches. If you still insist, we will ban you.
14 |
15 | * JZMQ is not a sandbox where "anything goes until the next stable release". If you want to experiment, please work in your own projects.
16 |
--------------------------------------------------------------------------------
/Changelog.md:
--------------------------------------------------------------------------------
1 | # Changelog
2 |
3 | ## v3.1.0
4 | * Update scm tags in pom.xml
5 | * Fix issue where release was failing because a circular reference
6 | * Added method ZMQ.Socket.setProbeRouter(), issue #333
7 | * exposed plaintext gss sock opt
8 | * Change version to 3.1.0-SNAPSHOT
9 | * Change artifactId back to jzmq
10 | * bug fix: non blocking recvByteBuffer throws exception when there are no data to receive
11 | * Fix issue #328 - Expose public set_sockopt for ZMQ_REQ_RELAXED and ZMQ_REQ_CORRELATE
12 | * Ignore .checkstyle
13 | * Fix issue #325 - Able to build latest JZMQ with libzmq 2.2.0
14 | * Use inline instead of static inline since it's behaviour is undefined
15 | * Update Context.cpp formatting
16 | * Fix issue #323 - Add get and set max socket options on Context
17 | * Fixed java.nio.Buffer.position method being called as void.
18 | * ZMQ_GSSAPI_PRINCIPAL and ZMQ_GSSAPI_SERVICE_PRINCIPAL are available since 4.1.0
19 | * Raise exception if zmq_poll returns error.
20 | * principle->principal
21 | * exposing ZAPRequest members
22 | * gss auth callback moved to zauth for implementation override
23 | * added new gss config options
24 | * zap interprets gss zap, by default allow all clients
25 | * prefer boolean to int
26 | * support for gss mech
27 | * improve send performance
28 | * fix error on address part in zmq version >= 4.0.0
29 | * Add support for ZMQ monitors
30 | * Fix multiple equal case statements can be enabled at the same time when setting value.
31 | * fix other duplicate case statement
32 | * Fix multiple equal case statements can be enabled at the same time.
33 | * zauth missing from makefile
34 | * Add support for ZMQ_IMMEDIATE and ZMQ_DELAY_ATTACH_ON_CONNECT socket options.
35 | * Add PLAIN security auth
36 | * Fix javadoc errors
37 | * Put ZAuth back in the package
38 | * adding more build depends tools
39 | * pkg-config is needed because of autogen.sh
40 | * executing autogen.sh so configure script is created and the package can be built
41 | * Fix missing definition of the ZMQ_CONFLATE option in native methods.
42 | * Fix type of the ZMQ_CONFLATE option in native method.
43 | * Fix regression with issue #283
44 | * Restore the JZMQ_CLASS_FILES vairable.
45 | * Fixed perf failing to build multithreaded
46 | * Makefiles can now be executed multithreaded
47 | * Fixed 'No rule to make target' error in makefile
48 | * Added missing .class files with a '$' in them to JAR. Removed makefile duplicate
49 | * Include all class files in the resulting jar.
50 | * Add missing java classes to make files.
51 | * Add missing getConflate method to get value of the ZMQ_CONFLATE option.
52 | * fix jni getLongSockopt
53 | * Add the ZMQ_CONFLATE option.
54 | * Fix issue #283 - Add libsodium to travis-ci build
55 | * Imported Visual Studio solution into Visual Studio 2012. Copied config.hpp into src/main/c++/.
56 | * don't catch exceptions on junits
57 | * pushd/popd not working
58 | * add version to gpg and surefire plugins to avoid mvn warning
59 | * make jar with right folder structure
60 | * Fix CMake Error at CMakeLists.txt:204 (add_library): Cannot find source file: ....
61 | * Remove and ignore INSTALL
62 | * Fix regression when I rebased
63 | * Remove config.hpp.in
64 | * Add Trevor Bernard to contributors
65 | * More cleaning
66 | * Make Context instance variable private
67 | * More cleanup
68 | * Spring cleaning JNI
69 | * Clean up jmethodID names
70 | * Clean up jmethodID and jfieldID names
71 | * Update license in c++ files and headers
72 | * Ignore generated files
73 | * Move perf and cpp into the structure
74 | * Move perf into src
75 | * Use standard maven project structure
76 | * Revert "updated INSTALL and src/config.hpp.in from latest autogen(?)"
77 | * Use PUSH/PULL for throughput perf teset
78 | * added darwin subfolder to catch jni_md.h automatically
79 | * added support for MacOSX and Oracle's Java
80 | * updated INSTALL and src/config.hpp.in from latest autogen(?)
81 | * Revert "config/* is on .gitignore, so config/ax_jni_include_dir.m4 shan't be commited"
82 | * config/* is on .gitignore, so config/ax_jni_include_dir.m4 shan't be commited
83 | * Fixed broken builds for zmq < 4.0.0
84 | * add self to authors...
85 | * cleanup, stubs for other mechs
86 | * null allows all but blacklisted through
87 | * ZAuth with null mechanism support
88 | * Add acknowledgements section
89 | * Fix issue #259 - Set socket identity now works with 4.0.x
90 | * Depend on libzmq-dev or libzmq3-dev
91 | * Fix issue #257 - recvByteBuffer fails if message length is bigger than ByteBuffer limit
92 | * Update to 4.0
93 | * Update pom.xml to reflect 4.0
94 | * [maven-release-plugin] prepare release v3.0.1
95 | * Fix issue # 253 - Load jzmq in Socket class
96 | * Fix issue # 253 - Load jzmq in Socket class
97 | * [maven-release-plugin] prepare for next development iteration
98 | * [maven-release-plugin] prepare release v3.0.0
99 | * Prepare code for release
100 | * Backport Fixes for #250 and #252
101 | * Fix recvByteBuffer unit test
102 | * Improvements
103 | * Fix issue #249 - Take position into account as an offset for send and recv
104 | * Ignore emacs files
105 |
106 | ## v3.0.1
107 |
108 | ## v2.1.1 - February 16, 2013
109 |
110 | * Add zero copy API to send and recv
111 | * Remove asserts from get_context JNI
112 | * Add ZLoop support
113 | * Poller rewrite
114 | * No longer c assert when trying to write to a closed Socket
115 | * Add a continuous integration support through travis-ci
116 |
117 | ## v2.1.0 - February 12, 2013
118 |
119 | * First release to Maven Central
120 |
--------------------------------------------------------------------------------
/jzmq-core/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 4.0.0
4 |
5 |
6 | org.zeromq
7 | jzmq-parent
8 | 3.1.1-SNAPSHOT
9 |
10 |
11 | org.zeromq
12 | jzmq-core
13 | jar
14 |
15 |
16 |
17 | org.zeromq
18 | jzmq-jni
19 | 3.1.1-SNAPSHOT
20 |
21 |
22 |
23 |
24 |
25 |
26 | org.commonjava.maven.plugins
27 | directory-maven-plugin
28 |
29 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/jzmq-core/src/main/java/org/zeromq/Utils.java:
--------------------------------------------------------------------------------
1 | package org.zeromq;
2 |
3 | public class Utils
4 | {
5 | private Utils()
6 | {
7 | }
8 |
9 | public static void checkNotNull(Object obj)
10 | {
11 | if (obj == null) {
12 | throw new IllegalArgumentException("Argument must not be null");
13 | }
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/jzmq-core/src/main/java/org/zeromq/ZCert.java:
--------------------------------------------------------------------------------
1 | package org.zeromq;
2 |
3 | import java.util.HashMap;
4 | import java.util.Map;
5 |
6 | /**
7 | * Minimal ZCert-class to handle public and secret keys
8 | *
9 | * @author thomas (dot) trocha (at) gmail (dot) com
10 | *
11 | */
12 | public class ZCert {
13 | private byte[] public_key;// Public key in binary
14 | private byte[] secret_key;// Secret key in binary
15 | private String public_txt;// Public key in Z85 text
16 | private String secret_txt;// Secret key in Z85 text
17 | private Map metadata=new HashMap(); // Certificate metadata
18 |
19 | public ZCert(String publicKey) {
20 | if (publicKey.length()==32) { // in binary-format
21 | public_key = publicKey.getBytes();
22 | public_txt = ZMQ.Curve.z85Encode(public_key);
23 | } else { // Z85-Coded
24 | public_key = ZMQ.Curve.z85Decode(publicKey);
25 | public_txt = publicKey;
26 | }
27 | }
28 |
29 | public ZCert() {
30 | ZMQ.Curve.KeyPair keypair = ZMQ.Curve.generateKeyPair();
31 | public_key = ZMQ.Curve.z85Decode(keypair.publicKey);
32 | public_txt = keypair.publicKey;
33 | secret_key = ZMQ.Curve.z85Decode(keypair.secretKey);
34 | secret_txt = keypair.secretKey;
35 | }
36 |
37 |
38 |
39 | public byte[] getPublicKey() {
40 | return public_key;
41 | }
42 |
43 | public byte[] getSecretKey() {
44 | return secret_key;
45 | }
46 |
47 | public String getPublicKeyAsZ85() {
48 | return public_txt;
49 | }
50 |
51 |
52 | public String getSecretKeyAsZ85() {
53 | return secret_txt;
54 | }
55 |
56 | public void setMeta(String key,String value) {
57 | metadata.put(key, value);
58 | }
59 |
60 | private void metaToZConfig(Map meta,ZConfig zconf) {
61 | for (String key : meta.keySet()) {
62 | zconf.putValue("metadata/"+key, meta.get(key));
63 | }
64 | }
65 |
66 | /**
67 | * Save the public-key to disk
68 | * @param filename
69 | */
70 | public void savePublic(String filename) {
71 | ZConfig zconf = new ZConfig("root",null);
72 | metaToZConfig(metadata, zconf);
73 | zconf.addComment(" ZeroMQ CURVE Public Certificate");
74 | zconf.addComment(" Exchange securely, or use a secure mechanism to verify the contents");
75 | zconf.addComment(" of this file after exchange. Store public certificates in your home");
76 | zconf.addComment(" directory, in the .curve subdirectory.");
77 | zconf.putValue("/curve/public-key", public_txt);
78 | zconf.save(filename);
79 | }
80 |
81 | /**
82 | * save the public- and secret-key to disk
83 | * @param filename
84 | */
85 | public void saveSecret(String filename) {
86 | ZConfig zconf = new ZConfig("root",null);
87 | metaToZConfig(metadata, zconf);
88 | zconf.addComment(" ZeroMQ CURVE **Secret** Certificate");
89 | zconf.addComment(" DO NOT PROVIDE THIS FILE TO OTHER USERS nor change its permissions.");
90 | zconf.putValue("/curve/public-key", public_txt);
91 | zconf.putValue("/curve/secret-key", secret_txt);
92 | zconf.save(filename);
93 | }
94 | }
95 |
--------------------------------------------------------------------------------
/jzmq-core/src/main/java/org/zeromq/ZCertStore.java:
--------------------------------------------------------------------------------
1 | package org.zeromq;
2 |
3 | import java.io.File;
4 | import java.util.HashSet;
5 | import java.util.Set;
6 | /**
7 | * Simple certstore that manages certificate file in a directory. Those files need to be in ZMP-Format which is created by ZConf.java
8 | *
9 | * @author thomas (dot) trocha (at) gmail (dot) com
10 | *
11 | */
12 | public class ZCertStore {
13 |
14 | private static interface IFileVisitor {
15 | void handleFile(File f);
16 | void handleDir(File f);
17 | }
18 |
19 |
20 | private String location; // Directory location
21 | // This isn't sufficient; we should check the hash of all files
22 | // or else use a trigger like inotify on Linux.
23 | private long modified; // Modified time of directory
24 | private int certCount; // Number of certificates
25 | private int fileSize; // Total size of certificates
26 | private int tempCounter;
27 |
28 | private boolean fileCheckRunning = false;
29 | private boolean requestStopThread = false;
30 |
31 | // save publickey as key and the modified-date in milliseconds as value
32 | private Set publicKeys = new HashSet();
33 |
34 | /**
35 | * Create a CertificationStore at that filesystem location
36 | *
37 | * @param location
38 | */
39 | public ZCertStore(String location) {
40 | loadFiles(location);
41 | // startDummyCheckThread(1000);
42 | }
43 |
44 | private void traverseDirectory(String path,IFileVisitor visitor) {
45 | File root = new File(path);
46 | traverseDirectory(root, visitor);
47 | }
48 | private void traverseDirectory(File root,IFileVisitor visitor) {
49 | if (!root.exists()) {
50 | throw new RuntimeException("There is no path:"+root.getPath());
51 | }
52 | if (!root.isDirectory()) {
53 | throw new RuntimeException("Path:"+root.getPath()+" is not a directory!");
54 | }
55 |
56 | for (File f : root.listFiles()) {
57 | if (f.isFile()) {
58 | visitor.handleFile(f);
59 | }
60 | else if (f.isDirectory()) {
61 | visitor.handleDir(f);
62 | traverseDirectory(f, visitor);
63 | }
64 | else {
65 | System.out.println("WARNING:"+f+" is neither file nor directory? This shouldn't happen....SKIPPING");
66 | }
67 | }
68 | }
69 |
70 | /**
71 | * Check if a publickey is in the certstore
72 | * @param publicKey byte[] : needs to be a 32byte-string representing the publickey
73 | * @return
74 | */
75 | public boolean containsPublicKey(byte[] publicKey) {
76 | if (publicKey.length!=32) {
77 | throw new RuntimeException("publickey needs to have a size of 32bytes. got only "+publicKey.length);
78 | }
79 | String z85Key=ZMQ.Curve.z85Encode(publicKey);
80 | return containsPublicKey(z85Key);
81 | }
82 |
83 | /**
84 | * check if a z85-based publickey is in the certstore.
85 | *
86 | * if you have no checkthread running this method will scan the cert-folder for changes on every call
87 | *
88 | * @param publicKey
89 | * @return
90 | */
91 | public boolean containsPublicKey(String publicKey) {
92 | if (publicKey.length()!=40) {
93 | throw new RuntimeException("z85 publickeys should have a length of 40bytes but got "+publicKey.length());
94 | }
95 |
96 | // if the checkthread is not running we scan the folders on each publickey-check
97 | if (!isCheckThreadRunning()){
98 | checkAndReload();
99 | }
100 |
101 | return publicKeys.contains(publicKey);
102 | }
103 |
104 | private void loadFiles(String directory) {
105 | publicKeys.clear();
106 | certCount=0;
107 | location = directory;
108 | File f = new File(directory);
109 | if (!f.exists()) {
110 | // create folder if not existant
111 | f.mkdirs();
112 | }
113 | if ( f.isDirectory()) {
114 | modified = f.lastModified();
115 | }
116 |
117 | fileSize=f.list().length;
118 |
119 | traverseDirectory(directory, new IFileVisitor() {
120 | @Override
121 | public void handleFile(File f) {
122 | try {
123 | ZConfig zconf = ZConfig.load(f.getAbsolutePath());
124 | String publicKey = zconf.getValue("curve/public-key");
125 | if (publicKey==null) {
126 | System.out.println("Warning!! File has no curve/public-key-element: "+f.getAbsolutePath()+" SKIPPING!");
127 | return;
128 | }
129 | if (publicKey.length()==32) { // we want to store the public-key as Z85-String
130 | publicKey=ZMQ.Curve.z85Encode(publicKey.getBytes());
131 | }
132 | publicKeys.add(publicKey);
133 | certCount++;
134 | }
135 | catch (Exception e) {
136 | e.printStackTrace();
137 | }
138 | }
139 |
140 | @Override
141 | public void handleDir(File f) {
142 | fileSize += f.list().length;
143 | }
144 | });
145 | }
146 |
147 | /**
148 | * How many certificates are registered at the moment
149 | * @return int
150 | */
151 | public int getAmountCertificates() {
152 | if (!isCheckThreadRunning()) {
153 | checkAndReload();
154 | }
155 | return publicKeys.size();
156 | }
157 |
158 | private boolean directoryModified(String path) {
159 | File f = new File(path);
160 | if (f.exists() && f.isDirectory()) {
161 | if (f.lastModified() != modified) {
162 | return true;
163 | };
164 | }
165 | return false;
166 | }
167 |
168 | /**
169 | * Check if files in the cert-folder have been added or removed. Changes are also recognized in subfolder
170 | * This might differ from OS to OS. At least on Linux this works. Timestamps are second-based!!
171 | *
172 | *
173 | * @return boolean
174 | */
175 | public boolean checkCertFolderForChanges() {
176 | if (directoryModified(location)) {
177 | return true;
178 | }
179 |
180 | File f = new File(this.location);
181 | if (!f.exists()) {
182 | return true; // run load-files if the main-folder is not present,yet
183 | }
184 | // initalize with fileCount of current-directory and add subdirs via traversal
185 | tempCounter = f.list().length;
186 | traverseDirectory(f, new IFileVisitor() {
187 |
188 | @Override
189 | public void handleFile(File f) {
190 |
191 | }
192 |
193 | @Override
194 | public void handleDir(File f) {
195 | tempCounter += f.list().length;
196 | }
197 | });
198 |
199 | if (tempCounter != fileSize) {
200 | return true;
201 | }
202 |
203 | return false;
204 | }
205 |
206 | /**
207 | * Check if certificates in the cert-folder changed and reload them
208 | */
209 | public void checkAndReload() {
210 | checkAndReload(false);
211 | }
212 |
213 | /**
214 | * Check if certificates in the cert-folder changed and reload them
215 | */
216 | public void checkAndReload(boolean force) {
217 | if (force || checkCertFolderForChanges()) {
218 | loadFiles(location);
219 | }
220 | }
221 |
222 | /**
223 | * Start simple thread that checks if the the directory timestamp changed or the overall count of files did change. If yes it will reload all certificates again
224 | *
225 | * @param checkTime - the time in milliseconds the check should run
226 | */
227 | public void startCheckThread(final int checkTime) {
228 | if (fileCheckRunning){
229 | return;
230 | }
231 | fileCheckRunning = true;
232 | new Thread(new Runnable() {
233 |
234 | @Override
235 | public void run() {
236 | while(fileCheckRunning && !requestStopThread) {
237 | checkAndReload();
238 | try {
239 | Thread.sleep(checkTime);
240 | } catch (InterruptedException e) {
241 | e.printStackTrace();
242 | }
243 | }
244 | fileCheckRunning = false;
245 | requestStopThread = false;
246 | }
247 | }).start();
248 | }
249 |
250 | /**
251 | * stop the dummy check after the next sleep-period is over
252 | */
253 | public void stopCheckThread() {
254 | requestStopThread = true;
255 | }
256 |
257 | /**
258 | * Check if the Thread is running that periodically scans the cert-folder for new data
259 | * @return
260 | */
261 | public boolean isCheckThreadRunning() {
262 | return fileCheckRunning;
263 | }
264 |
265 | }
266 |
--------------------------------------------------------------------------------
/jzmq-core/src/main/java/org/zeromq/ZContext.java:
--------------------------------------------------------------------------------
1 | package org.zeromq;
2 |
3 | import java.io.Closeable;
4 | import java.util.List;
5 | import java.util.ListIterator;
6 | import java.util.concurrent.CopyOnWriteArrayList;
7 |
8 | import org.zeromq.ZMQ.Context;
9 | import org.zeromq.ZMQ.Socket;
10 |
11 | /**
12 | * ZContext provides a high-level ZeroMQ context management class
13 | *
14 | * The ZContext class wraps java org.zeromq.Context objects, which in turn wrap native 0MQ contexts. It manages open
15 | * sockets in the context and automatically closes these before terminating the context. It provides a simple way to set
16 | * the linger timeout on sockets, and configure contexts for number of I/O threads. Sets-up signal (interrupt) handling
17 | * for the process.
18 | *
19 | * @see czmq version
20 | *
21 | * @author rsmith (at) rsbatechnology (dot) co (dot) uk
22 | */
23 | public class ZContext implements Closeable {
24 |
25 | /**
26 | * Reference to underlying Context object
27 | */
28 | private ZMQ.Context context;
29 |
30 | /**
31 | * List of sockets managed by this ZContext
32 | */
33 | private List sockets;
34 |
35 | /**
36 | * Number of io threads allocated to this context, default 1
37 | */
38 | private int ioThreads;
39 |
40 | /**
41 | * Linger timeout, default 0
42 | */
43 | private int linger;
44 |
45 | /**
46 | * Indicates if context object is owned by main thread (useful for multi-threaded applications)
47 | */
48 | private boolean main;
49 |
50 | /**
51 | * Class Constructor
52 | */
53 | public ZContext() {
54 | context = null; // Don't create Context until create 1st 0MQ socket
55 | sockets = new CopyOnWriteArrayList();
56 | ioThreads = 1;
57 | linger = 0;
58 | main = true;
59 | }
60 |
61 | /**
62 | * Destructor. Call this to gracefully terminate context and close any managed 0MQ sockets
63 | */
64 | public void destroy() {
65 | ListIterator itr = sockets.listIterator();
66 | while (itr.hasNext()) {
67 | destroySocket(itr.next());
68 | }
69 | sockets.clear();
70 |
71 | // Only terminate context if we are on the main thread
72 | if (isMain() && context != null)
73 | context.term();
74 |
75 | }
76 |
77 | /**
78 | * Creates a new managed socket within this ZContext instance. Use this to get automatic management of the socket at
79 | * shutdown
80 | *
81 | * @param type socket type (see ZMQ static class members)
82 | * @return Newly created Socket object
83 | */
84 | public Socket createSocket(int type) {
85 | if (context == null)
86 | context = ZMQ.context(ioThreads);
87 |
88 | // Create and register socket
89 | Socket socket = context.socket(type);
90 | sockets.add(socket);
91 | return socket;
92 | }
93 |
94 | /**
95 | * Destroys managed socket within this context and remove from sockets list
96 | *
97 | * @param s org.zeromq.Socket object to destroy
98 | */
99 | public void destroySocket(Socket s) {
100 | if (s == null)
101 | return;
102 |
103 | if (sockets.contains(s)) {
104 | try {
105 | s.setLinger(linger);
106 | } catch (ZMQException e) {
107 | if (e.getErrorCode() != ZMQ.ETERM()) {
108 | throw e;
109 | }
110 | }
111 | s.close();
112 | sockets.remove(s);
113 | }
114 | }
115 |
116 | /**
117 | * Creates new shadow context. Shares same underlying org.zeromq.Context instance but has own list of managed
118 | * sockets, io thread count etc.
119 | *
120 | * @param ctx Original ZContext to create shadow of
121 | * @return New ZContext
122 | */
123 | public static ZContext shadow(ZContext ctx) {
124 | ZContext shadow = new ZContext();
125 | shadow.setContext(ctx.getContext());
126 | shadow.setMain(false);
127 | return shadow;
128 | }
129 |
130 | /**
131 | * @return the ioThreads
132 | */
133 | public int getIoThreads() {
134 | return ioThreads;
135 | }
136 |
137 | /**
138 | * @param ioThreads the ioThreads to set
139 | */
140 | public void setIoThreads(int ioThreads) {
141 | this.ioThreads = ioThreads;
142 | }
143 |
144 | /**
145 | * @return the linger
146 | */
147 | public int getLinger() {
148 | return linger;
149 | }
150 |
151 | /**
152 | * @param linger the linger to set
153 | */
154 | public void setLinger(int linger) {
155 | this.linger = linger;
156 | }
157 |
158 | /**
159 | * @return the main
160 | */
161 | public boolean isMain() {
162 | return main;
163 | }
164 |
165 | /**
166 | * @param main the main to set
167 | */
168 | public void setMain(boolean main) {
169 | this.main = main;
170 | }
171 |
172 | /**
173 | * @return the context
174 | */
175 | public Context getContext() {
176 | return context;
177 | }
178 |
179 | /**
180 | * @param ctx sets the underlying org.zeromq.Context associated with this ZContext wrapper object
181 | */
182 | public void setContext(Context ctx) {
183 | this.context = ctx;
184 | }
185 |
186 | /**
187 | * @return the sockets
188 | */
189 | public List getSockets() {
190 | return sockets;
191 | }
192 |
193 | @Override
194 | public void close() {
195 | destroy();
196 | }
197 | }
198 |
--------------------------------------------------------------------------------
/jzmq-core/src/main/java/org/zeromq/ZDispatcher.java:
--------------------------------------------------------------------------------
1 | package org.zeromq;
2 |
3 | import java.util.concurrent.BlockingQueue;
4 | import java.util.concurrent.ConcurrentHashMap;
5 | import java.util.concurrent.ConcurrentMap;
6 | import java.util.concurrent.CountDownLatch;
7 | import java.util.concurrent.ExecutorService;
8 | import java.util.concurrent.Executors;
9 | import java.util.concurrent.LinkedBlockingQueue;
10 | import java.util.concurrent.atomic.AtomicBoolean;
11 |
12 | /**
13 | * Dispatcher for ZeroMQ Sockets.
14 | *
15 | * Warning:
16 | * The Dispatcher uses a busy spin loop when waiting on events.
17 | * This is ideal for low latency applications but not in all situations.
18 | * It has the side effect of consuming 100% of a CPU when waiting for events.
19 | *
20 | * With this dispatcher, you can register ONE handler per socket
21 | * and get a Sender for sending ZMsg.
22 | */
23 | public class ZDispatcher {
24 | private ConcurrentMap dispatchers = new ConcurrentHashMap();
25 | private final ExecutorService dispatcherExecutor;
26 |
27 | public ZDispatcher() {
28 | this.dispatcherExecutor = Executors.newCachedThreadPool();
29 | }
30 |
31 | public ZDispatcher(ExecutorService dispatcherExecutor) {
32 | this.dispatcherExecutor = dispatcherExecutor;
33 | }
34 |
35 | public void registerHandler(ZMQ.Socket socket, ZMessageHandler messageHandler, ZSender sender) {
36 | registerHandler(socket, messageHandler, sender, Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors()));
37 | }
38 |
39 | public void registerHandler(ZMQ.Socket socket, ZMessageHandler messageHandler, ZSender sender, ExecutorService threadpool) {
40 | SocketDispatcher socketDispatcher = new SocketDispatcher(socket, messageHandler, sender, threadpool);
41 | if (dispatchers.putIfAbsent(socket, socketDispatcher) != null) {
42 | throw new IllegalArgumentException("This socket already have a message handler");
43 | }
44 | socketDispatcher.start();
45 | dispatcherExecutor.execute(socketDispatcher);
46 | }
47 |
48 | public void unregisterHandler(ZMQ.Socket socket) {
49 | SocketDispatcher removedDispatcher = dispatchers.remove(socket);
50 | if (removedDispatcher == null) {
51 | throw new IllegalArgumentException("This socket doesn't have a message handler");
52 | }
53 | removedDispatcher.shutdown();
54 | }
55 |
56 | public void shutdown() {
57 | dispatcherExecutor.shutdown();
58 | for (SocketDispatcher socketDispatcher : dispatchers.values()) {
59 | socketDispatcher.shutdown();
60 | }
61 | dispatchers.clear();
62 | }
63 |
64 | public interface ZMessageHandler {
65 |
66 | public void handleMessage(ZDispatcher.ZSender sender, ZMsg msg);
67 |
68 | }
69 |
70 | public final static class ZSender {
71 | private final BlockingQueue out = new LinkedBlockingQueue();
72 |
73 | public final boolean send(ZMsg msg) {
74 | return out.add(msg);
75 | }
76 | }
77 |
78 | private static final class SocketDispatcher implements Runnable {
79 | private volatile boolean active = false;
80 | private final CountDownLatch shutdownLatch = new CountDownLatch(1);
81 | private final ZMQ.Socket socket;
82 | private final ZMessageHandler handler;
83 | private final ZSender sender;
84 | private final ExecutorService threadpool;
85 | private final BlockingQueue in = new LinkedBlockingQueue();
86 | private static final int BUFFER_SIZE = 1024;
87 | private static final ThreadLocal messages = new ThreadLocal() {
88 | @Override
89 | protected ZMessageBuffer initialValue() {
90 | return new ZMessageBuffer();
91 | }
92 | };
93 | private final AtomicBoolean busy = new AtomicBoolean(false);
94 |
95 | public SocketDispatcher(ZMQ.Socket socket, ZMessageHandler handler, ZSender sender, ExecutorService handleThreadpool) {
96 | this.socket = socket;
97 | this.handler = handler;
98 | this.sender = sender;
99 | this.threadpool = handleThreadpool;
100 | }
101 |
102 | public void run() {
103 | while (active) {
104 | doReceive();
105 | doHandle();
106 | doSend();
107 | }
108 | threadpool.shutdown();
109 | shutdownLatch.countDown();
110 | }
111 |
112 | public void start() {
113 | this.active = true;
114 | }
115 |
116 | public void shutdown() {
117 | try {
118 | this.active = false;
119 | this.shutdownLatch.await();
120 |
121 | } catch (InterruptedException e) {
122 | }
123 | }
124 |
125 | private void doReceive() {
126 | ZMsg msg;
127 | int remainingBuffer = BUFFER_SIZE;
128 | while (active && remainingBuffer-- > 0 && (msg = ZMsg.recvMsg(socket, ZMQ.DONTWAIT)) != null && msg.size() > 0 && msg.getFirst().hasData()) {
129 | in.add(msg);
130 | }
131 | }
132 |
133 | private void doHandle() {
134 | if (!in.isEmpty() && busy.compareAndSet(false, true)) {
135 | threadpool.submit(new Runnable() {
136 | @Override
137 | public void run() {
138 | ZMessageBuffer messages = SocketDispatcher.this.messages.get();
139 | messages.drainFrom(in);
140 | busy.set(false);
141 | for (int i = 0; i <= messages.lastValidIndex; i++) {
142 | if (active) {
143 | handler.handleMessage(sender, messages.buffer[i]);
144 | }
145 | }
146 | }
147 | });
148 | }
149 | }
150 |
151 | private void doSend() {
152 | ZMsg msg;
153 | int remainingBuffer = BUFFER_SIZE;
154 | while (active && remainingBuffer-- > 0 && (msg = sender.out.poll()) != null) {
155 | msg.send(socket);
156 | }
157 | }
158 |
159 | private static class ZMessageBuffer {
160 | private final ZMsg[] buffer = new ZMsg[BUFFER_SIZE];
161 | private int lastValidIndex;
162 |
163 | private void drainFrom(BlockingQueue in) {
164 | int lastIndex = lastValidIndex = -1;
165 | ZMsg msg;
166 | while (++lastIndex < buffer.length && (msg = in.poll()) != null) {
167 | buffer[lastIndex] = msg;
168 | lastValidIndex = lastIndex;
169 | }
170 | }
171 | }
172 | }
173 | }
174 |
--------------------------------------------------------------------------------
/jzmq-core/src/main/java/org/zeromq/ZThread.java:
--------------------------------------------------------------------------------
1 | package org.zeromq;
2 |
3 | import org.zeromq.ZMQ.Socket;
4 |
5 | public class ZThread {
6 | public static interface IAttachedRunnable {
7 | public void run(Object[] args, ZContext ctx, Socket pipe);
8 | }
9 |
10 | public static interface IDetachedRunnable {
11 | public void run(Object[] args);
12 | }
13 |
14 | private static class ShimThread extends Thread {
15 | private ZContext ctx;
16 | private IAttachedRunnable attachedRunnable;
17 | private IDetachedRunnable detachedRunnable;
18 | private Object[] args;
19 | private Socket pipe;
20 |
21 | protected ShimThread(ZContext ctx, IAttachedRunnable runnable, Object[] args, Socket pipe) {
22 | assert (ctx != null);
23 | assert (pipe != null);
24 | assert (runnable != null);
25 |
26 | this.ctx = ctx;
27 | this.attachedRunnable = runnable;
28 | this.args = args;
29 | this.pipe = pipe;
30 | }
31 |
32 | public ShimThread(IDetachedRunnable runnable, Object[] args) {
33 | assert (runnable != null);
34 | this.detachedRunnable = runnable;
35 | this.args = args;
36 | }
37 |
38 | @Override
39 | public void run() {
40 | if (attachedRunnable != null) {
41 | try {
42 | attachedRunnable.run(args, ctx, pipe);
43 | } catch (ZMQException e) {
44 | if (e.getErrorCode() != ZMQ.ETERM()) {
45 | throw e;
46 | }
47 | }
48 | ctx.destroy();
49 | } else
50 | detachedRunnable.run(args);
51 | }
52 | }
53 |
54 | // --------------------------------------------------------------------------
55 | // Create a detached thread. A detached thread operates autonomously
56 | // and is used to simulate a separate process. It gets no ctx, and no
57 | // pipe.
58 |
59 | public static void start(IDetachedRunnable runnable, Object... args) {
60 | // Prepare child thread
61 | Thread shim = new ShimThread(runnable, args);
62 | shim.start();
63 | }
64 |
65 | // --------------------------------------------------------------------------
66 | // Create an attached thread. An attached thread gets a ctx and a PAIR
67 | // pipe back to its parent. It must monitor its pipe, and exit if the
68 | // pipe becomes unreadable. Returns pipe, or null if there was an error.
69 |
70 | public static Socket fork(ZContext ctx, IAttachedRunnable runnable, Object... args) {
71 | Socket pipe = ctx.createSocket(ZMQ.PAIR);
72 |
73 | if (pipe != null) {
74 | pipe.bind(String.format("inproc://zctx-pipe-%d", pipe.hashCode()));
75 | } else {
76 | return null;
77 | }
78 |
79 | // Connect child pipe to our pipe
80 | ZContext ccontext = ZContext.shadow(ctx);
81 | Socket cpipe = ccontext.createSocket(ZMQ.PAIR);
82 | if (cpipe == null)
83 | return null;
84 | cpipe.connect(String.format("inproc://zctx-pipe-%d", pipe.hashCode()));
85 |
86 | // Prepare child thread
87 | Thread shim = new ShimThread(ccontext, runnable, args, cpipe);
88 | shim.start();
89 |
90 | return pipe;
91 | }
92 | }
93 |
--------------------------------------------------------------------------------
/jzmq-core/src/test/java/org/zeromq/TestUtils.java:
--------------------------------------------------------------------------------
1 | package org.zeromq;
2 |
3 | import java.io.File;
4 |
5 | public class TestUtils {
6 | /**
7 | * Remove a directory and delete all files and subdir recursively
8 | * CAUTION: watchout with symbolic links. not tested how the behaviour is but suspect this function will follow those as well.
9 | * @param path as String
10 | */
11 | public static void cleanupDir(String path) {
12 | cleanupSimpleDir(new File(path));
13 | }
14 |
15 | /**
16 | * Remove a directory and delete all files and subdir recursively
17 | * CAUTION: watchout with symbolic links. not tested how the behaviour is but suspect this function will follow those as well.
18 | * @param path File-path
19 | */
20 | public static void cleanupSimpleDir(File path) {
21 | if (!path.exists()){
22 | return;
23 | }
24 |
25 | for (File fileToDelete : path.listFiles()) {
26 | if (fileToDelete.isDirectory()) {
27 | cleanupSimpleDir(fileToDelete);
28 | }
29 | fileToDelete.delete();
30 | // System.out.println("Deleted "+fileToDelete.getAbsolutePath());
31 | }
32 | path.delete();
33 | }
34 |
35 | public static void sleep(long ms) {
36 | try {
37 | Thread.sleep(ms);
38 | } catch (InterruptedException e) {
39 | e.printStackTrace();
40 | }
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/jzmq-core/src/test/java/org/zeromq/ZCertStoreTest.java:
--------------------------------------------------------------------------------
1 | package org.zeromq;
2 |
3 | import static org.junit.Assert.assertFalse;
4 |
5 | import java.io.File;
6 |
7 | import org.junit.After;
8 | import org.junit.Before;
9 | import org.junit.Test;
10 |
11 | public class ZCertStoreTest {
12 |
13 | private ZCertStore certStore;
14 |
15 | private static final String CERTSTORE_LOCATION = "testCurveCerts";
16 | private ZAuth auth;
17 |
18 | @Before
19 | public void init() {
20 | // first cleanup test-directory if still present
21 | TestUtils.cleanupDir(CERTSTORE_LOCATION);
22 |
23 | auth = new ZAuth(new ZContext());
24 | certStore = new ZCertStore(CERTSTORE_LOCATION);
25 | File f = new File(CERTSTORE_LOCATION);
26 | // check if the certstore location was created by the certstore
27 | assert(f.exists() && f.isDirectory());
28 | // new certstore-directory should have no certs,yet
29 | assert(certStore.getAmountCertificates() == 0);
30 | }
31 |
32 | @Test
33 | public void addCertTest() {
34 | // first cleanup test-directory if still present
35 | TestUtils.cleanupDir(CERTSTORE_LOCATION);
36 |
37 | int beforeAmount = certStore.getAmountCertificates();
38 | assert(beforeAmount == 0);
39 |
40 | ZCert c1 = new ZCert();
41 | c1.savePublic(CERTSTORE_LOCATION+"/c1.cert");
42 | // check the store if something changed, and if yes reload all
43 | certStore.checkAndReload();
44 | // is now one certificate more in the store?
45 | assert((beforeAmount+1)==certStore.getAmountCertificates());
46 |
47 | // check if we find our publickey using the Z85-Version to lookup
48 | assert(certStore.containsPublicKey(c1.getPublicKeyAsZ85()));
49 | // check if we find our publickey using the binary-Version to lookup (this will internally be encoded to z85 for the lookup)
50 | assert(certStore.containsPublicKey(c1.getPublicKey()));
51 | // check if we do not find some random lookup-key. Z85-Keys need to have a length of 40bytes.
52 | assert(certStore.containsPublicKey("1234567890123456789012345678901234567890")==false);
53 |
54 | // check certs in sub-directories
55 | ZCert c2 = new ZCert();
56 | c2.savePublic(CERTSTORE_LOCATION+"/sub/c2.cert");
57 | assert(certStore.getAmountCertificates() == 2);
58 | }
59 |
60 |
61 | @Test
62 | public void checkForCertChanges() {
63 | // first cleanup test-directory if still present
64 | TestUtils.cleanupDir(CERTSTORE_LOCATION);
65 |
66 | assert(certStore.getAmountCertificates() == 0);
67 |
68 | ZCert cert1 = new ZCert();
69 | cert1.savePublic(CERTSTORE_LOCATION+"/c1.cert");
70 | ZCert cert2 = new ZCert();
71 | cert2.saveSecret(CERTSTORE_LOCATION+"/sub/c2.cert");
72 |
73 | assert(certStore.getAmountCertificates() == 2);
74 |
75 | // rewrite certificates and see if this change gets recognized
76 | assertFalse(certStore.checkCertFolderForChanges());
77 |
78 | // sleep one second to see an effect on lastModified-method for files, since seconds seems to be the smallest
79 | // time-unit that is saved
80 | TestUtils.sleep(1000);
81 |
82 | cert1 = new ZCert();
83 | cert1.savePublic(CERTSTORE_LOCATION+"/c1.cert");
84 | // change is recognized if a file is changed only in the main-folder
85 |
86 | assert(certStore.checkCertFolderForChanges());
87 |
88 | // again wait a second
89 | TestUtils.sleep(1000);
90 |
91 | // check if changes in subfolders get recognized
92 | cert2.savePublic(CERTSTORE_LOCATION+"/sub/c2.cert");
93 | assert(certStore.checkCertFolderForChanges());
94 | }
95 |
96 | // This test has a very minimal chance to fail so I take it out for now
97 | // @Test
98 | public void testCheckThread() {
99 | // first cleanup test-directory if still present
100 | TestUtils.cleanupDir(CERTSTORE_LOCATION);
101 |
102 | assert(certStore.getAmountCertificates() == 0);
103 |
104 | // start checkservice that runs every 2second to see if something changed in the cert-folder
105 | certStore.startCheckThread(1000);
106 |
107 | // create some Certificates
108 | ZCert cert1 = new ZCert();
109 | cert1.savePublic(CERTSTORE_LOCATION+"/c1.cert");
110 | ZCert cert2 = new ZCert();
111 | cert2.savePublic(CERTSTORE_LOCATION+"/sub/c2.cert");
112 | // right after creation the amount is still on 0 since when the checkThread is running
113 | // only this is responsible for checking for new/delete or changed files
114 | assert(certStore.getAmountCertificates() == 0);
115 | TestUtils.sleep(1500);
116 | // now the thread should have done its work
117 | assert(certStore.getAmountCertificates() == 2);
118 |
119 | // delete a file, wait and see the effect
120 | File deleteFile = new File(CERTSTORE_LOCATION+"/sub/c2.cert");
121 | deleteFile.delete();
122 | // right after the action there are still the old values
123 | assert(certStore.getAmountCertificates() == 2);
124 |
125 | // wait for the thread to do its job
126 | TestUtils.sleep(1500);
127 | assert(certStore.getAmountCertificates() == 1);
128 |
129 |
130 | // stop the thread
131 | certStore.stopCheckThread();
132 | // sleep till the thread is really exited
133 | TestUtils.sleep(1500);
134 |
135 | // Now the old system should apply again
136 | ZCert cert3 = new ZCert();
137 | cert3.savePublic(CERTSTORE_LOCATION+"/c3.cert");
138 | assert(certStore.getAmountCertificates() == 2);
139 |
140 | }
141 |
142 | @After
143 | public void cleanup() {
144 | TestUtils.cleanupDir(CERTSTORE_LOCATION);
145 | }
146 |
147 |
148 |
149 |
150 | }
151 |
--------------------------------------------------------------------------------
/jzmq-core/src/test/java/org/zeromq/ZConfigTest.java:
--------------------------------------------------------------------------------
1 | package org.zeromq;
2 |
3 | import java.io.File;
4 | import java.io.FileWriter;
5 | import java.io.IOException;
6 |
7 | import org.junit.After;
8 | import org.junit.Before;
9 | import org.junit.Test;
10 | /**
11 | * Test ZConfig
12 | *
13 | * @author dertom
14 | *
15 | */
16 | public class ZConfigTest {
17 |
18 | private static final String TEST_FOLDER = "testCertFolder";
19 | private static ZConfig conf = new ZConfig("root",null);
20 |
21 |
22 | @Before
23 | public void init() {
24 | conf.putValue("/curve/public-key", "abcdefg");
25 | conf.putValue("/curve/secret-key", "(w3lSF/5yv&j*c&0h{4JHe(CETJSksTr.QSjcZE}");
26 | conf.putValue("metadata/name", "key-value tests");
27 |
28 | // create test-file with values that should be compatible but are actually not create with this implementation
29 | try {
30 | File dir = new File(TEST_FOLDER);
31 | if (!dir.exists()) {
32 | dir.mkdir();
33 | }
34 | FileWriter write = new FileWriter(TEST_FOLDER+"/test.zpl");
35 | write.write("1. ZPL configuration file example\n"); // should be discarded
36 | write.write(" # some initial comment \n"); // should be discarded
37 | write.write("meta\n");
38 | write.write(" leadingquote = \"abcde\n");
39 | write.write(" endingquote = abcde\"\n");
40 | write.write(" quoted = \"abcde\"\n");
41 | write.write(" singlequoted = 'abcde'\n");
42 | write.write(" bind = tcp://eth0:5555\n");
43 | write.write(" verbose = 1 # Ask for a trace\n");
44 | write.write(" sub # some comment after container-name\n");
45 | write.write(" fortuna = f95\n");
46 | write.close();
47 | } catch (IOException e) {
48 | e.printStackTrace();
49 | }
50 | }
51 |
52 | @Test
53 | public void testPutGet(){
54 | assert(conf.getValue("/curve/public-key").equals("abcdefg"));
55 | // intentionally checking without leading /
56 | assert(conf.getValue("curve/secret-key").equals("(w3lSF/5yv&j*c&0h{4JHe(CETJSksTr.QSjcZE}"));
57 | assert(conf.getValue("/metadata/name").equals("key-value tests"));
58 |
59 | // checking default value
60 | assert(conf.getValue("/metadata/nothinghere","default").equals("default"));
61 | }
62 |
63 |
64 | @Test
65 | public void testLoadSave() {
66 | conf.save(TEST_FOLDER+"/test.cert");
67 | assert(isFileInPath(TEST_FOLDER,"test.cert"));
68 | ZConfig loadedConfig = ZConfig.load(TEST_FOLDER+"/test.cert");
69 | Object obj = loadedConfig.getValue("/curve/public-key");
70 | assert(loadedConfig.getValue("/curve/public-key").equals("abcdefg"));
71 | // intentionally checking without leading /
72 | assert(loadedConfig.getValue("curve/secret-key").equals("(w3lSF/5yv&j*c&0h{4JHe(CETJSksTr.QSjcZE}"));
73 | assert(loadedConfig.getValue("/metadata/name").equals("key-value tests"));
74 | }
75 |
76 | private boolean isFileInPath(String path,String filename) {
77 | File dir = new File(path);
78 | if (!dir.isDirectory()) {
79 | return false;
80 | }
81 | for (File file : dir.listFiles()){
82 | if (file.getName().equals(filename)) {
83 | return true;
84 | }
85 | }
86 | return false;
87 | }
88 |
89 | @Test
90 | public void testZPLSpecialCases() {
91 | // this file was generated in the init-method and tests some cases that should be processed by the loader but are not
92 | // created with our writer.
93 | ZConfig zplSpecials = ZConfig.load(TEST_FOLDER+"/test.zpl");
94 | // test leading quotes
95 | assert(zplSpecials.getValue("meta/leadingquote").equals("\"abcde"));
96 | // test ending quotes
97 | assert(zplSpecials.getValue("meta/endingquote").equals("abcde\""));
98 | // test full doublequoted. here the quotes should be removed
99 | assert(zplSpecials.getValue("meta/quoted").equals("abcde"));
100 | // test full singlequoted. here the quotes should be removed
101 | assert(zplSpecials.getValue("meta/singlequoted").equals("abcde"));
102 | // test no quotes tcp-pattern
103 | assert(zplSpecials.getValue("meta/bind").equals("tcp://eth0:5555"));
104 | // test comment after value
105 | assert(zplSpecials.getValue("meta/verbose").equals("1"));
106 | // test comment after container-name
107 | assert(zplSpecials.pathExists("meta/sub"));
108 | }
109 |
110 |
111 | @After
112 | public void cleanup() {
113 | TestUtils.cleanupDir(TEST_FOLDER);
114 | }
115 |
116 | }
117 |
--------------------------------------------------------------------------------
/jzmq-core/src/test/java/org/zeromq/ZContextTest.java:
--------------------------------------------------------------------------------
1 | package org.zeromq;
2 |
3 | import org.junit.Test;
4 | import org.zeromq.ZMQ.Socket;
5 |
6 | import static org.junit.Assert.assertEquals;
7 | import static org.junit.Assert.assertTrue;
8 |
9 | /**
10 | * Tests high-level ZContext class
11 | *
12 | * @author richardsmith
13 | *
14 | */
15 | public class ZContextTest {
16 |
17 | @Test
18 | public void testConstruction() {
19 | ZContext ctx = new ZContext();
20 | assertTrue(ctx != null);
21 | assertEquals(1, ctx.getIoThreads());
22 | assertEquals(0, ctx.getLinger());
23 | assertTrue(ctx.isMain());
24 | }
25 |
26 | @Test
27 | public void testDestruction() {
28 | ZContext ctx = new ZContext();
29 | ctx.destroy();
30 | assertTrue(ctx.getSockets().isEmpty());
31 |
32 | // Ensure context is not destroyed if not in main thread
33 | ZContext ctx1 = new ZContext();
34 | ctx1.setMain(false);
35 | @SuppressWarnings("unused")
36 | Socket s = ctx1.createSocket(ZMQ.PAIR);
37 | ctx1.destroy();
38 | assertTrue(ctx1.getSockets().isEmpty());
39 | assertTrue(ctx1.getContext() != null);
40 | }
41 |
42 | @Test
43 | public void testAddingSockets() throws ZMQException {
44 | // Tests "internal" newSocket method, should not be used outside jzmq itself.
45 | ZContext ctx = new ZContext();
46 | try {
47 | Socket s = ctx.createSocket(ZMQ.PUB);
48 | assertTrue(s != null);
49 | assertTrue(s.getType() == ZMQ.PUB);
50 | Socket s1 = ctx.createSocket(ZMQ.REQ);
51 | assertTrue(s1 != null);
52 | assertEquals(2, ctx.getSockets().size());
53 | } finally {
54 | ctx.destroy();
55 | }
56 | }
57 |
58 | @Test
59 | public void testRemovingSockets() throws ZMQException {
60 | ZContext ctx = new ZContext();
61 | try {
62 | Socket s = ctx.createSocket(ZMQ.PUB);
63 | assertTrue(s != null);
64 | assertEquals(1, ctx.getSockets().size());
65 |
66 | ctx.destroySocket(s);
67 | assertEquals(0, ctx.getSockets().size());
68 | } finally {
69 | ctx.destroy();
70 | }
71 | }
72 |
73 | @Test
74 | public void testShadow() {
75 | ZContext ctx = new ZContext();
76 | Socket s = ctx.createSocket(ZMQ.PUB);
77 | assertTrue(s != null);
78 | assertEquals(1, ctx.getSockets().size());
79 |
80 | ZContext shadowCtx = ZContext.shadow(ctx);
81 | shadowCtx.setMain(false);
82 | assertEquals(0, shadowCtx.getSockets().size());
83 | @SuppressWarnings("unused")
84 | Socket s1 = shadowCtx.createSocket(ZMQ.SUB);
85 | assertEquals(1, shadowCtx.getSockets().size());
86 | assertEquals(1, ctx.getSockets().size());
87 |
88 | shadowCtx.destroy();
89 | ctx.destroy();
90 | }
91 |
92 | }
93 |
--------------------------------------------------------------------------------
/jzmq-core/src/test/java/org/zeromq/ZFrameTest.java:
--------------------------------------------------------------------------------
1 | package org.zeromq;
2 |
3 | import org.junit.Test;
4 | import org.zeromq.ZMQ.Socket;
5 |
6 | import static org.junit.Assert.assertEquals;
7 | import static org.junit.Assert.assertFalse;
8 | import static org.junit.Assert.assertNull;
9 | import static org.junit.Assert.assertTrue;
10 |
11 | /**
12 | * Tests ZFrame class
13 | *
14 | * @author Richard Smith
15 | *
16 | */
17 | public class ZFrameTest {
18 |
19 | @Test
20 | public void testZFrameCreation() {
21 | ZFrame f = new ZFrame("Hello".getBytes());
22 | assertTrue(f != null);
23 | assertTrue(f.hasData());
24 | assertEquals(5, f.size());
25 |
26 | f = new ZFrame();
27 | assertFalse(f.hasData());
28 | assertEquals(0, f.size());
29 | }
30 |
31 | @Test
32 | public void testZFrameEquals() {
33 | ZFrame f = new ZFrame("Hello".getBytes());
34 | ZFrame clone = f.duplicate();
35 | assertEquals(f, clone);
36 | }
37 |
38 | @Test
39 | public void testSending() {
40 | ZContext ctx = new ZContext();
41 | Socket output = ctx.createSocket(ZMQ.PAIR);
42 | output.bind("inproc://zframe.test");
43 | Socket input = ctx.createSocket(ZMQ.PAIR);
44 | input.connect("inproc://zframe.test");
45 |
46 | // Send five different frames, test ZFRAME_MORE
47 | for (int i = 0; i < 5; i++) {
48 | ZFrame f = new ZFrame("Hello".getBytes());
49 | boolean rt = f.send(output, ZMQ.SNDMORE);
50 | assertTrue(rt);
51 | }
52 |
53 | // Send same frame five times
54 | ZFrame f = new ZFrame("Hello".getBytes());
55 | for (int i = 0; i < 5; i++) {
56 | f.send(output, ZMQ.SNDMORE);
57 | }
58 | assertEquals(5, f.size());
59 | ctx.close();
60 | }
61 |
62 | @Test
63 | public void testCopyingAndDuplicating() {
64 | ZContext ctx = new ZContext();
65 | Socket output = ctx.createSocket(ZMQ.PAIR);
66 | output.bind("inproc://zframe.test");
67 | Socket input = ctx.createSocket(ZMQ.PAIR);
68 | input.connect("inproc://zframe.test");
69 |
70 | ZFrame f = new ZFrame("Hello");
71 | ZFrame copy = f.duplicate();
72 | assertTrue(copy.equals(f));
73 | f.destroy();
74 | assertFalse(copy.equals(f));
75 | assertEquals(5, copy.size());
76 | ctx.close();
77 | }
78 |
79 | @Test
80 | public void testReceiving() {
81 | ZContext ctx = new ZContext();
82 | Socket output = ctx.createSocket(ZMQ.PAIR);
83 | output.bind("inproc://zframe.test");
84 | Socket input = ctx.createSocket(ZMQ.PAIR);
85 | input.connect("inproc://zframe.test");
86 |
87 | // Send same frame five times
88 | ZFrame f = new ZFrame("Hello".getBytes());
89 | for (int i = 0; i < 5; i++) {
90 | f.send(output, ZMQ.SNDMORE);
91 | }
92 |
93 | // Send END frame
94 | f = new ZFrame("NOT".getBytes());
95 | f.reset("END".getBytes());
96 | assertEquals("454E44", f.strhex());
97 | f.send(output, 0);
98 |
99 | // Read and count until we receive END
100 | int frame_nbr = 0;
101 | while (true) {
102 | f = ZFrame.recvFrame(input);
103 | frame_nbr++;
104 | if (f.streq("END")) {
105 | f.destroy();
106 | break;
107 | }
108 | }
109 | assertEquals(6, frame_nbr);
110 | f = ZFrame.recvFrame(input, ZMQ.DONTWAIT);
111 | assertNull(f);
112 |
113 | ctx.close();
114 | }
115 |
116 | @Test
117 | public void testStringFrames() {
118 | ZContext ctx = new ZContext();
119 | Socket output = ctx.createSocket(ZMQ.PAIR);
120 | output.bind("inproc://zframe.test");
121 | Socket input = ctx.createSocket(ZMQ.PAIR);
122 | input.connect("inproc://zframe.test");
123 |
124 | ZFrame f1 = new ZFrame("Hello");
125 | assertEquals(5, f1.getData().length);
126 | f1.send(output, 0);
127 |
128 | ZFrame f2 = ZFrame.recvFrame(input);
129 | assertTrue(f2.hasData());
130 | assertEquals(5, f2.getData().length);
131 | assertTrue(f2.streq("Hello"));
132 | assertEquals(f2.toString(), "Hello");
133 | assertTrue(f2.equals(f1));
134 |
135 | ctx.close();
136 | }
137 | }
138 |
--------------------------------------------------------------------------------
/jzmq-core/src/test/java/org/zeromq/ZMsgTest.java:
--------------------------------------------------------------------------------
1 | package org.zeromq;
2 |
3 | import org.junit.Test;
4 | import org.zeromq.ZMQ.Socket;
5 |
6 | import java.io.DataInputStream;
7 | import java.io.DataOutputStream;
8 | import java.io.File;
9 | import java.io.FileInputStream;
10 | import java.io.FileNotFoundException;
11 | import java.io.FileOutputStream;
12 | import java.io.IOException;
13 | import java.util.Iterator;
14 |
15 | import static org.junit.Assert.assertEquals;
16 | import static org.junit.Assert.assertFalse;
17 | import static org.junit.Assert.assertNull;
18 | import static org.junit.Assert.assertTrue;
19 | import static org.junit.Assert.fail;
20 |
21 | public class ZMsgTest {
22 |
23 | @Test
24 | public void testMessageEquals() {
25 | ZMsg msg = new ZMsg();
26 | ZFrame hello = new ZFrame("Hello");
27 | ZFrame world = new ZFrame("World");
28 | msg.add(hello);
29 | msg.add(world);
30 | assertEquals(msg, msg.duplicate());
31 |
32 | ZMsg reverseMsg = new ZMsg();
33 | msg.add(hello);
34 | msg.addFirst(world);
35 | assertFalse(msg.equals(reverseMsg));
36 | }
37 |
38 | @Test
39 | public void testSingleFrameMessage() {
40 | ZContext ctx = new ZContext();
41 |
42 | Socket output = ctx.createSocket(ZMQ.PAIR);
43 | output.bind("inproc://zmsg.test");
44 | Socket input = ctx.createSocket(ZMQ.PAIR);
45 | input.connect("inproc://zmsg.test");
46 |
47 | // Test send and receive of a single ZMsg
48 | ZMsg msg = new ZMsg();
49 | ZFrame frame = new ZFrame("Hello");
50 | msg.addFirst(frame);
51 | assertEquals(1, msg.size());
52 | assertEquals(5, msg.contentSize());
53 | msg.send(output);
54 |
55 | ZMsg msg2 = ZMsg.recvMsg(input);
56 | assertTrue(msg2 != null);
57 | assertEquals(1, msg2.size());
58 | assertEquals(5, msg2.contentSize());
59 |
60 | msg.destroy();
61 | msg2.destroy();
62 | ctx.close();
63 | }
64 |
65 | @Test
66 | public void testMultiPart() {
67 | ZContext ctx = new ZContext();
68 |
69 | Socket output = ctx.createSocket(ZMQ.PAIR);
70 | output.bind("inproc://zmsg.test2");
71 | Socket input = ctx.createSocket(ZMQ.PAIR);
72 | input.connect("inproc://zmsg.test2");
73 |
74 | ZMsg msg = new ZMsg();
75 | for (int i = 0; i < 10; i++)
76 | msg.addString("Frame" + i);
77 | ZMsg copy = msg.duplicate();
78 | copy.send(output);
79 | msg.send(output);
80 |
81 | copy = ZMsg.recvMsg(input);
82 | assertTrue(copy != null);
83 | assertEquals(10, copy.size());
84 | assertEquals(60, copy.contentSize());
85 | copy.destroy();
86 |
87 | msg = ZMsg.recvMsg(input);
88 | assertTrue(msg != null);
89 | assertEquals(10, msg.size());
90 | int count = 0;
91 | for (ZFrame f : msg)
92 | assertTrue(f.streq("Frame" + count++));
93 | assertEquals(60, msg.contentSize());
94 | msg.destroy();
95 |
96 | ctx.close();
97 | }
98 |
99 | @Test
100 | public void testMessageFrameManipulation() {
101 | ZMsg msg = new ZMsg();
102 | for (int i = 0; i < 10; i++)
103 | msg.addString("Frame" + i);
104 |
105 | // Remove all frames apart from the first and last one
106 | for (int i = 0; i < 8; i++) {
107 | Iterator iter = msg.iterator();
108 | iter.next(); // Skip first frame
109 | ZFrame f = iter.next();
110 | msg.remove(f);
111 | f.destroy();
112 | }
113 |
114 | assertEquals(2, msg.size());
115 | assertEquals(12, msg.contentSize());
116 | assertTrue(msg.getFirst().streq("Frame0"));
117 | assertTrue(msg.getLast().streq("Frame9"));
118 |
119 | ZFrame f = new ZFrame("Address");
120 | msg.push(f);
121 | assertEquals(3, msg.size());
122 | assertTrue(msg.getFirst().streq("Address"));
123 |
124 | msg.addString("Body");
125 | assertEquals(4, msg.size());
126 | ZFrame f0 = msg.pop();
127 | assertTrue(f0.streq("Address"));
128 |
129 | msg.destroy();
130 |
131 | msg = new ZMsg();
132 | f = new ZFrame("Address");
133 | msg.wrap(f);
134 | assertEquals(2, msg.size());
135 | msg.addString("Body");
136 | assertEquals(3, msg.size());
137 | f = msg.unwrap();
138 | f.destroy();
139 | assertEquals(1, msg.size());
140 | msg.destroy();
141 |
142 | }
143 |
144 | @Test
145 | public void testEmptyMessage() {
146 | ZMsg msg = new ZMsg();
147 | assertEquals(0, msg.size());
148 | assertEquals(null, msg.getFirst());
149 | assertEquals(null, msg.getLast());
150 | assertTrue(msg.isEmpty());
151 | assertEquals(null, msg.pop());
152 | assertEquals(null, msg.removeFirst());
153 | assertEquals(false, msg.removeFirstOccurrence(null));
154 | assertEquals(null, msg.removeLast());
155 |
156 | msg.destroy();
157 |
158 | }
159 |
160 | @Test
161 | public void testLoadSave() {
162 | ZMsg msg = new ZMsg();
163 | for (int i = 0; i < 10; i++)
164 | msg.addString("Frame" + i);
165 |
166 | try {
167 | // Save msg to a file
168 | File f = new File("zmsg.test");
169 | DataOutputStream dos = new DataOutputStream(new FileOutputStream(f));
170 | assertTrue(ZMsg.save(msg, dos));
171 | dos.close();
172 |
173 | // Read msg out of the file
174 | DataInputStream dis = new DataInputStream(new FileInputStream(f));
175 | ZMsg msg2 = ZMsg.load(dis);
176 | dis.close();
177 | f.delete();
178 |
179 | assertEquals(10, msg2.size());
180 | assertEquals(60, msg2.contentSize());
181 |
182 | } catch (FileNotFoundException e) {
183 | e.printStackTrace();
184 | assertTrue(false);
185 | } catch (IOException e) {
186 | e.printStackTrace();
187 | assertTrue(false);
188 | }
189 | }
190 |
191 | @Test
192 | public void testNewStringMessage() {
193 | // A single string => frame
194 | ZMsg msg = ZMsg.newStringMsg("Foo");
195 | assertEquals(1, msg.size());
196 | assertTrue(msg.getFirst().streq("Foo"));
197 |
198 | // Multiple strings => frames
199 | ZMsg msg2 = ZMsg.newStringMsg("Foo", "Bar", "Baz");
200 | assertEquals(3, msg2.size());
201 | assertTrue(msg2.getFirst().streq("Foo"));
202 | assertTrue(msg2.getLast().streq("Baz"));
203 |
204 | // Empty message (Not very useful)
205 | ZMsg msg3 = ZMsg.newStringMsg();
206 | assertTrue(msg3.isEmpty());
207 | }
208 |
209 | @Test
210 | public void testClosedContext() {
211 | ZContext ctx = new ZContext();
212 |
213 | Socket output = ctx.createSocket(ZMQ.PAIR);
214 | output.bind("inproc://zmsg.test");
215 | Socket input = ctx.createSocket(ZMQ.PAIR);
216 | input.connect("inproc://zmsg.test");
217 |
218 | ZMsg msg = ZMsg.newStringMsg("Foo", "Bar");
219 | msg.send(output);
220 |
221 | ZMsg msg2 = ZMsg.recvMsg(input);
222 | assertEquals("Foo", msg2.popString());
223 | assertEquals("Bar", msg2.popString());
224 | msg2.destroy();
225 |
226 | msg.send(output);
227 | msg.destroy();
228 | ctx.close();
229 |
230 | try {
231 | assertNull("Expected null message", ZMsg.recvMsg(input));
232 | } catch (ZMQException e) {
233 | fail();
234 | }
235 |
236 | }
237 | }
238 |
--------------------------------------------------------------------------------
/jzmq-core/src/test/java/org/zeromq/ZThreadTest.java:
--------------------------------------------------------------------------------
1 | package org.zeromq;
2 |
3 | import org.zeromq.ZMQ.Socket;
4 | import org.junit.Assert;
5 | import org.junit.Test;
6 |
7 | public class ZThreadTest {
8 |
9 | @Test
10 | public void testDetached() {
11 | ZThread.IDetachedRunnable detached = new ZThread.IDetachedRunnable() {
12 |
13 | @Override
14 | public void run(Object[] args) {
15 | ZContext ctx = new ZContext();
16 | assert (ctx != null);
17 |
18 | Socket push = ctx.createSocket(ZMQ.PUSH);
19 | assert (push != null);
20 | ctx.destroy();
21 | }
22 | };
23 |
24 | ZThread.start(detached);
25 | }
26 |
27 | @Test
28 | public void testFork() {
29 | ZContext ctx = new ZContext();
30 |
31 | ZThread.IAttachedRunnable attached = new ZThread.IAttachedRunnable() {
32 |
33 | @Override
34 | public void run(Object[] args, ZContext ctx, Socket pipe) {
35 | // Create a socket to check it'll be automatically deleted
36 | ctx.createSocket(ZMQ.PUSH);
37 | pipe.recvStr();
38 | pipe.send("pong");
39 | }
40 | };
41 |
42 | Socket pipe = ZThread.fork(ctx, attached);
43 | assert (pipe != null);
44 |
45 | pipe.send("ping");
46 | String pong = pipe.recvStr();
47 |
48 | Assert.assertEquals(pong, "pong");
49 |
50 | // Everything should be cleanly closed now
51 | ctx.destroy();
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/jzmq-devices/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 4.0.0
4 |
5 |
6 | org.zeromq
7 | jzmq-parent
8 | 3.1.1-SNAPSHOT
9 |
10 |
11 | org.zeromq
12 | jzmq-devices
13 | jar
14 |
15 |
16 |
17 | org.zeromq
18 | jzmq-jni
19 | 3.1.1-SNAPSHOT
20 |
21 |
22 |
23 |
24 |
25 |
26 | org.commonjava.maven.plugins
27 | directory-maven-plugin
28 |
29 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/jzmq-devices/src/main/java/org/zeromq/ZMQForwarder.java:
--------------------------------------------------------------------------------
1 | package org.zeromq;
2 |
3 | import org.zeromq.ZMQ.Context;
4 | import org.zeromq.ZMQ.Socket;
5 |
6 | /**
7 | * ZeroMQ Forwarder Device implementation.
8 | *
9 | * @author Alois Belaska <alois.belaska@gmail.com>
10 | */
11 | public class ZMQForwarder implements Runnable {
12 |
13 | private final ZMQ.Poller poller;
14 | private final ZMQ.Socket inSocket;
15 | private final ZMQ.Socket outSocket;
16 |
17 | /**
18 | * Class constructor.
19 | *
20 | * @param context a 0MQ context previously created.
21 | * @param inSocket input socket
22 | * @param outSocket output socket
23 | */
24 | public ZMQForwarder(Context context, Socket inSocket, Socket outSocket) {
25 | this.inSocket = inSocket;
26 | this.outSocket = outSocket;
27 |
28 | this.poller = context.poller(1);
29 | this.poller.register(inSocket, ZMQ.Poller.POLLIN);
30 | }
31 |
32 | /**
33 | * Forwarding messages.
34 | */
35 | @Override
36 | public void run() {
37 | byte[] msg = null;
38 | boolean more = true;
39 |
40 | while (!Thread.currentThread().isInterrupted()) {
41 | try {
42 | // wait while there are requests to process
43 | if (poller.poll(250000) < 1) {
44 | continue;
45 | }
46 |
47 | msg = inSocket.recv(0);
48 |
49 | more = inSocket.hasReceiveMore();
50 |
51 | if (msg != null) {
52 | outSocket.send(msg, more ? ZMQ.SNDMORE : 0);
53 | }
54 | } catch (ZMQException e) {
55 | // context destroyed, exit
56 | if (ZMQ.Error.ETERM.getCode() == e.getErrorCode()) {
57 | break;
58 | }
59 | throw e;
60 | }
61 | }
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/jzmq-devices/src/main/java/org/zeromq/ZMQQueue.java:
--------------------------------------------------------------------------------
1 | package org.zeromq;
2 |
3 | import java.io.Closeable;
4 | import java.io.IOException;
5 |
6 | import org.zeromq.ZMQ.Context;
7 | import org.zeromq.ZMQ.Socket;
8 |
9 | /**
10 | * ZeroMQ Queue Device implementation.
11 | *
12 | * @author Alois Belaska <alois.belaska@gmail.com>
13 | */
14 | public class ZMQQueue implements Runnable, Closeable {
15 |
16 | private final ZMQ.Poller poller;
17 | private final ZMQ.Socket inSocket;
18 | private final ZMQ.Socket outSocket;
19 |
20 | /**
21 | * Class constructor.
22 | *
23 | * @param context a 0MQ context previously created.
24 | * @param inSocket input socket
25 | * @param outSocket output socket
26 | */
27 | public ZMQQueue(Context context, Socket inSocket, Socket outSocket) {
28 | this.inSocket = inSocket;
29 | this.outSocket = outSocket;
30 |
31 | this.poller = context.poller(2);
32 | this.poller.register(inSocket, ZMQ.Poller.POLLIN);
33 | this.poller.register(outSocket, ZMQ.Poller.POLLIN);
34 | }
35 |
36 | /**
37 | * Queuing of requests and replies.
38 | */
39 | @Override
40 | public void run() {
41 | byte[] msg = null;
42 | boolean more = true;
43 |
44 | while (!Thread.currentThread().isInterrupted()) {
45 | try {
46 | // wait while there are either requests or replies to process
47 | if (poller.poll(-1) < 0) {
48 | break;
49 | }
50 |
51 | // process a request
52 | if (poller.pollin(0)) {
53 | more = true;
54 | while (more) {
55 | msg = inSocket.recv(0);
56 |
57 | more = inSocket.hasReceiveMore();
58 |
59 | if (msg != null) {
60 | outSocket.send(msg, more ? ZMQ.SNDMORE : 0);
61 | }
62 | }
63 | }
64 |
65 | // process a reply
66 | if (poller.pollin(1)) {
67 | more = true;
68 | while (more) {
69 | msg = outSocket.recv(0);
70 |
71 | more = outSocket.hasReceiveMore();
72 |
73 | if (msg != null) {
74 | inSocket.send(msg, more ? ZMQ.SNDMORE : 0);
75 | }
76 | }
77 | }
78 | } catch (ZMQException e) {
79 | // context destroyed, exit
80 | if (ZMQ.Error.ETERM.getCode() == e.getErrorCode()) {
81 | break;
82 | }
83 | throw e;
84 | }
85 | }
86 | }
87 |
88 | /**
89 | * Unregisters input and output sockets.
90 | */
91 | @Override
92 | public void close() throws IOException {
93 | poller.unregister(this.inSocket);
94 | poller.unregister(this.outSocket);
95 | }
96 | }
97 |
--------------------------------------------------------------------------------
/jzmq-devices/src/main/java/org/zeromq/ZMQStreamer.java:
--------------------------------------------------------------------------------
1 | package org.zeromq;
2 |
3 | import org.zeromq.ZMQ.Context;
4 | import org.zeromq.ZMQ.Socket;
5 |
6 | /**
7 | * ZeroMQ Streamer Device implementation.
8 | *
9 | * @author Alois Belaska <alois.belaska@gmail.com>
10 | */
11 | public class ZMQStreamer extends ZMQForwarder {
12 |
13 | /**
14 | * Class constructor.
15 | *
16 | * @param context a 0MQ context previously created.
17 | * @param inSocket input socket
18 | * @param outSocket output socket
19 | */
20 | public ZMQStreamer(Context context, Socket inSocket, Socket outSocket) {
21 | super(context, inSocket, outSocket);
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/jzmq-devices/src/test/java/org/zeromq/ZMQForwarderTest.java:
--------------------------------------------------------------------------------
1 | package org.zeromq;
2 |
3 | import static org.junit.Assert.assertArrayEquals;
4 |
5 | import org.junit.Test;
6 |
7 | public class ZMQForwarderTest {
8 |
9 | @Test
10 | public void testQueue() throws InterruptedException {
11 | ZMQ.Context context = ZMQ.context(1);
12 |
13 | ZMQ.Socket clients = context.socket(ZMQ.PAIR);
14 | clients.bind("inproc://fw_clients");
15 |
16 | ZMQ.Socket client = context.socket(ZMQ.PAIR);
17 | client.connect("inproc://fw_clients");
18 |
19 | ZMQ.Socket workers = context.socket(ZMQ.PAIR);
20 | workers.bind("inproc://fw_workers");
21 |
22 | ZMQ.Socket worker = context.socket(ZMQ.PAIR);
23 | worker.connect("inproc://fw_workers");
24 |
25 | Thread t = new Thread(new ZMQForwarder(context, clients, workers));
26 | t.start();
27 |
28 | for (int i = 0; i < 10; i++) {
29 | byte[] req = ("request" + i).getBytes();
30 |
31 | client.send(req, 0);
32 |
33 | // worker receives request
34 | byte[] reqTmp = worker.recv(0);
35 |
36 | assertArrayEquals(req, reqTmp);
37 | }
38 |
39 | t.interrupt();
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/jzmq-devices/src/test/java/org/zeromq/ZMQQueueTest.java:
--------------------------------------------------------------------------------
1 | package org.zeromq;
2 |
3 | import static org.junit.Assert.assertArrayEquals;
4 |
5 | import org.junit.Test;
6 |
7 | public class ZMQQueueTest {
8 |
9 | @Test
10 | public void testQueue() throws InterruptedException {
11 | ZMQ.Context context = ZMQ.context(1);
12 |
13 | ZMQ.Socket clients = context.socket(ZMQ.XREP);
14 | clients.bind("inproc://gate_clients");
15 |
16 | ZMQ.Socket workers = context.socket(ZMQ.XREQ);
17 | workers.bind("inproc://gate_workers");
18 |
19 | ZMQ.Socket client = context.socket(ZMQ.REQ);
20 | client.connect("inproc://gate_clients");
21 |
22 | ZMQ.Socket worker = context.socket(ZMQ.REP);
23 | worker.connect("inproc://gate_workers");
24 |
25 | Thread t = new Thread(new ZMQQueue(context, clients, workers));
26 | t.start();
27 |
28 | for (int i = 0; i < 10; i++) {
29 | byte[] req = ("request" + i).getBytes();
30 | byte[] rsp = ("response" + i).getBytes();
31 |
32 | client.send(req, 0);
33 |
34 | // worker receives request
35 | byte[] reqTmp = worker.recv(0);
36 |
37 | assertArrayEquals(req, reqTmp);
38 |
39 | // worker sends response
40 | worker.send(rsp, 0);
41 |
42 | // client receives response
43 | byte[] rspTmp = client.recv(0);
44 |
45 | assertArrayEquals(rsp, rspTmp);
46 | }
47 |
48 | t.interrupt();
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/jzmq-jni/AUTHORS:
--------------------------------------------------------------------------------
1 | ../AUTHORS
--------------------------------------------------------------------------------
/jzmq-jni/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # CMake build script for ØMQ Java bindings on Windows
2 |
3 | cmake_minimum_required (VERSION 2.8)
4 |
5 | project (JZMQ)
6 | find_package (Java REQUIRED)
7 | find_package (JNI REQUIRED)
8 |
9 |
10 | set(ZMQ_C_INCLUDE_PATH "" CACHE PATH "Path to ZMQ Header files")
11 | set(ZMQ_C_LIB_PATH "" CACHE PATH "Path to ZMQ library")
12 |
13 | find_program (JNI_JAVAH
14 | NAMES javah
15 | HINTS ${_JAVA_HINTS}
16 | PATHS ${_JAVA_PATHS}
17 | )
18 |
19 | #-----------------------------------------------------------------------------
20 | # force off-tree build
21 |
22 |
23 | if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
24 | message(FATAL_ERROR "CMake generation is not allowed within the source directory!
25 | Remove the CMakeCache.txt file and try again from another folder, e.g.:
26 | del CMakeCache.txt
27 | mkdir build
28 | cd build
29 | cmake ..
30 | ")
31 | endif(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
32 |
33 | #-----------------------------------------------------------------------------
34 | # default to Release build
35 |
36 | if(NOT CMAKE_BUILD_TYPE)
37 | set(CMAKE_BUILD_TYPE Release CACHE STRING
38 | "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel."
39 | FORCE)
40 | endif(NOT CMAKE_BUILD_TYPE)
41 |
42 | set(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/bin)
43 | set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/lib)
44 |
45 | #-----------------------------------------------------------------------------
46 | # platform specifics
47 |
48 | add_definitions(
49 | -DWIN32
50 | -DDLL_EXPORT
51 | -DFD_SETSIZE=1024
52 | )
53 |
54 | #-----------------------------------------------------------------------------
55 | # source files
56 |
57 | set(java-sources
58 | org/zeromq/ZMQ.java
59 | org/zeromq/ZMQException.java
60 | ../../../../jzmq-devices/src/main/java/org/zeromq/ZMQForwarder.java
61 | ../../../../jzmq-devices/src/main/java/org/zeromq/ZMQQueue.java
62 | ../../../../jzmq-devices/src/main/java/org/zeromq/ZMQStreamer.java
63 | org/zeromq/EmbeddedLibraryTools.java
64 | org/zeromq/App.java
65 | ../../../../jzmq-core/src/main/java/org/zeromq/ZContext.java
66 | ../../../../jzmq-core/src/main/java/org/zeromq/Utils.java
67 | ../../../../jzmq-core/src/main/java/org/zeromq/ZDispatcher.java
68 | ../../../../jzmq-core/src/main/java/org/zeromq/ZFrame.java
69 | ../../../../jzmq-core/src/main/java/org/zeromq/ZMsg.java
70 | ../../../../jzmq-core/src/main/java/org/zeromq/ZLoop.java
71 | ../../../../jzmq-core/src/main/java/org/zeromq/ZThread.java
72 | )
73 | set(java-classes
74 | org/zeromq/ZMQ.class
75 | org/zeromq/Utils.class
76 | org/zeromq/ZMQ$$Context.class
77 | org/zeromq/ZMQ$$Socket.class
78 | org/zeromq/ZMQ$$PollItem.class
79 | org/zeromq/ZMQ$$Poller.class
80 | org/zeromq/ZMQ$$Error.class
81 | org/zeromq/ZMQException.class
82 | org/zeromq/ZMQQueue.class
83 | org/zeromq/ZMQForwarder.class
84 | org/zeromq/ZMQStreamer.class
85 | org/zeromq/EmbeddedLibraryTools.class
86 | org/zeromq/App.class
87 | org/zeromq/ZContext.class
88 | org/zeromq/ZDispatcher.class
89 | org/zeromq/ZDispatcher$$1.class
90 | org/zeromq/ZDispatcher$$SocketDispatcher$$1.class
91 | org/zeromq/ZDispatcher$$SocketDispatcher$$2.class
92 | org/zeromq/ZDispatcher$$SocketDispatcher$$ZMessageBuffer.class
93 | org/zeromq/ZDispatcher$$SocketDispatcher.class
94 | org/zeromq/ZDispatcher$$ZMessageHandler.class
95 | org/zeromq/ZDispatcher$$ZSender.class
96 | org/zeromq/ZFrame.class
97 | org/zeromq/ZMsg.class
98 | org/zeromq/ZLoop.class
99 | org/zeromq/ZLoop$$IZLoopHandler.class
100 | org/zeromq/ZLoop$$SPoller.class
101 | org/zeromq/ZLoop$$STimer.class
102 | org/zeromq/ZThread.class
103 | org/zeromq/ZThread$$IAttachedRunnable.class
104 | org/zeromq/ZThread$$IDetachedRunnable.class
105 | org/zeromq/ZThread$$ShimThread.class
106 | )
107 | set(javah-headers
108 | org_zeromq_ZMQ.h
109 | org_zeromq_ZMQ_Error.h
110 | org_zeromq_ZMQ_Context.h
111 | org_zeromq_ZMQ_Socket.h
112 | org_zeromq_ZMQ_PollItem.h
113 | org_zeromq_ZMQ_Poller.h
114 | )
115 | set(cxx-sources
116 | Context.cpp
117 | Poller.cpp
118 | Socket.cpp
119 | util.cpp
120 | ZMQ.cpp
121 | )
122 |
123 | include_directories(
124 | src
125 | src/main/java
126 | ${CMAKE_CURRENT_BINARY_DIR}
127 | )
128 |
129 | #-----------------------------------------------------------------------------
130 | # optional modules
131 |
132 | add_definitions(
133 | -DZMQ_HAVE_OPENPGM
134 | )
135 | include_directories(
136 | ${ZMQ_C_INCLUDE_PATH}
137 | ${JNI_INCLUDE_DIRS}
138 | )
139 | link_directories(
140 | ${ZMQ_C_LIB_PATH}
141 | )
142 |
143 | #-----------------------------------------------------------------------------
144 | # source generators
145 |
146 | foreach (source ${cxx-sources})
147 | list(APPEND sources ${CMAKE_CURRENT_SOURCE_DIR}/src/main/c++/${source})
148 | endforeach()
149 |
150 | add_custom_command(
151 | OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/config.hpp
152 | COMMAND ${CMAKE_COMMAND}
153 | ARGS -E
154 | copy
155 | ${CMAKE_CURRENT_SOURCE_DIR}/builds/msvc/config.hpp
156 | ${CMAKE_CURRENT_BINARY_DIR}/config.hpp
157 | DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/builds/msvc/config.hpp
158 | )
159 | list(APPEND sources ${CMAKE_CURRENT_BINARY_DIR}/config.hpp)
160 |
161 | add_custom_command(
162 | OUTPUT ${javah-headers}
163 | COMMAND ${JNI_JAVAH}
164 | ARGS -jni
165 | -classpath ${CMAKE_CURRENT_BINARY_DIR}
166 | org.zeromq.ZMQ
167 | WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
168 | DEPENDS ${java-classes}
169 | )
170 | list(APPEND sources ${javah-headers})
171 |
172 | set (source-tmp "")
173 | foreach (source ${java-sources})
174 | list (APPEND source-tmp ${CMAKE_CURRENT_SOURCE_DIR}/src/main/java/${source})
175 | endforeach()
176 | set (java-sources ${source-tmp})
177 |
178 | add_custom_command(
179 | OUTPUT ${java-classes}
180 | COMMAND ${JAVA_COMPILE}
181 | ARGS -classpath ${CMAKE_CURRENT_BINARY_DIR}
182 | -sourcepath ${CMAKE_CURRENT_SOURCE_DIR}/src/main/java
183 | -d ${CMAKE_CURRENT_BINARY_DIR}
184 | ${java-sources}
185 | DEPENDS ${java-sources}
186 | )
187 |
188 | add_custom_command(
189 | OUTPUT lib/zmq.jar
190 | COMMAND ${JAVA_ARCHIVE}
191 | ARGS cf
192 | lib/zmq.jar
193 | ${java-classes}
194 | WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
195 | DEPENDS ${java-classes}
196 | )
197 | list(APPEND sources lib/zmq.jar)
198 |
199 | #-----------------------------------------------------------------------------
200 | # output
201 |
202 | add_library(jzmq SHARED ${sources})
203 | target_link_libraries(jzmq libzmq.lib)
204 |
205 | set(docs
206 | AUTHORS
207 | COPYING
208 | COPYING.LESSER
209 | ChangeLog
210 | INSTALL
211 | NEWS
212 | README
213 | README-PERF
214 | )
215 |
216 | install (TARGETS jzmq DESTINATION lib)
217 | install (FILES ${CMAKE_CURRENT_BINARY_DIR}/lib/zmq.jar DESTINATION lib)
218 | install (FILES ${docs} DESTINATION doc)
219 |
220 | # By default, do not warn when built on machines using only VS Express:
221 | IF(NOT DEFINED CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_NO_WARNINGS)
222 | SET(CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_NO_WARNINGS ON)
223 | ENDIF()
224 |
225 | include (InstallRequiredSystemLibraries)
226 | set (CPACK_PACKAGE_VENDOR "Miru Limited")
227 | set (CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/COPYING")
228 | set (CPACK_PACKAGE_VERSION_MAJOR "3")
229 | set (CPACK_PACKAGE_VERSION_MINOR "2")
230 | set (CPACK_PACKAGE_VERSION_PATCH "2")
231 | include (CPack)
232 |
233 | # end of file
234 |
--------------------------------------------------------------------------------
/jzmq-jni/COPYING:
--------------------------------------------------------------------------------
1 | ../COPYING
--------------------------------------------------------------------------------
/jzmq-jni/COPYING.LESSER:
--------------------------------------------------------------------------------
1 | ../COPYING.LESSER
--------------------------------------------------------------------------------
/jzmq-jni/ChangeLog:
--------------------------------------------------------------------------------
1 | ../Changelog.md
--------------------------------------------------------------------------------
/jzmq-jni/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM ubuntu:14.04
2 | ENV DEBIAN_FRONTEND noninteractive
3 |
4 | #
5 | # - update our repo
6 | #
7 | RUN apt-get -y update
8 | RUN apt-get -y upgrade
9 |
10 | #
11 | # - install git
12 | #
13 | RUN apt-get -y install python python-pip git
14 |
15 | #
16 | # - install jdk8 from oracle
17 | #
18 | RUN apt-get install -y python-software-properties software-properties-common
19 | RUN add-apt-repository ppa:webupd8team/java
20 | RUN apt-get update
21 | RUN echo oracle-java8-installer shared/accepted-oracle-license-v1-1 select true | /usr/bin/debconf-set-selections
22 | RUN apt-get install -y oracle-java8-installer
23 |
24 | #
25 | # - install building tools
26 | #
27 | RUN apt-get install make
28 | RUN apt-get install -y unzip
29 | RUN apt-get install -y build-essential
30 | RUN apt-get install -y pkg-config
31 | RUN apt-get install -y libtool
32 | RUN apt-get install -y autoconf
33 | RUN apt-get install -y automake
34 |
35 | #
36 | # - install libzmq-master
37 | #
38 | RUN git clone --depth 1 https://github.com/zeromq/libzmq.git
39 | RUN cd libzmq && ./autogen.sh && ./configure && make && sudo make install && sudo ldconfig
40 |
41 | #
42 | # - install zeromq-3.2.3
43 | #
44 | RUN wget http://download.zeromq.org/zeromq-3.2.3.zip
45 | RUN unzip zeromq-3.2.3.zip
46 | RUN cd zeromq-3.2.3 && ./configure && make && sudo make install && sudo ldconfig
47 |
48 | #
49 | # - install jzmq
50 | #
51 | RUN git clone --depth 1 https://github.com/zeromq/jzmq.git
52 | RUN cd jzmq && ./autogen.sh && ./configure && make && sudo make install && sudo ldconfig
53 |
54 | #
55 | # - set java.library.path
56 | #
57 | ENV LD_LIBRARY_PATH /usr/local/lib:/usr/local/share/java
58 |
59 | #
60 | # - remove defunct packages
61 | #
62 | RUN apt-get -y autoremove
63 |
64 | #
65 | # - copy lib files to docker default lib directory
66 | #
67 | RUN cp /usr/local/lib/libzmq.so.3.0.0 /lib/libzmq.so
68 | RUN cp /usr/local/lib/libjzmq.so.0.0.0 /lib/libjzmq.so
69 |
--------------------------------------------------------------------------------
/jzmq-jni/Makefile.am:
--------------------------------------------------------------------------------
1 | SHELL = /bin/sh
2 |
3 | ACLOCAL_AMFLAGS = -I config
4 |
5 | SUBDIRS = src/main/c++ src/main/perf
6 | DIST_SUBDIRS = src/main/c++ src/main/perf
7 |
--------------------------------------------------------------------------------
/jzmq-jni/NEWS:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zeromq/jzmq/00e699eff7bcd5a837048c016ec46990b338afb8/jzmq-jni/NEWS
--------------------------------------------------------------------------------
/jzmq-jni/README:
--------------------------------------------------------------------------------
1 | ../README.md
--------------------------------------------------------------------------------
/jzmq-jni/README-PERF:
--------------------------------------------------------------------------------
1 | First you have to compile library, follow README.
2 |
3 | Performance utilities must be executed from perf directory (cd perf).
4 |
5 | More informations can be found here http://www.zeromq.org/results:perf-howto.
--------------------------------------------------------------------------------
/jzmq-jni/autogen.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | # Copyright (c) 2007-2010 iMatix Corporation
3 | #
4 | # This file is part of 0MQ.
5 | #
6 | # 0MQ is free software; you can redistribute it and/or modify
7 | # it under the terms of the GNU General Public License as published by
8 | # the Free Software Foundation; either version 3 of the License, or
9 | # (at your option) any later version.
10 |
11 | # 0MQ is distributed in the hope that it will be useful,
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | # GNU General Public License for more details.
15 |
16 | # You should have received a copy of the GNU General Public License
17 | # along with this program. If not, see .
18 |
19 | # Script to generate all required files from fresh git checkout.
20 |
21 | command -v pkg-config >/dev/null 2>&1
22 | if [ $? -ne 0 ]; then
23 | echo "autogen.sh: error: could not find pkg-config. pkg-config is required to run autogen.sh." 1>&2
24 | exit 1
25 | fi
26 |
27 | # Debian and Ubuntu do not ship libtool anymore, but OSX does not ship libtoolize.
28 | command -v libtoolize >/dev/null 2>&1
29 | if [ $? -ne 0 ]; then
30 | command -v libtool >/dev/null 2>&1
31 |
32 | if [ $? -ne 0 ]; then
33 | echo "autogen.sh: error: could not find libtool. libtool is required to run autogen.sh." 1>&2
34 | exit 1
35 | fi
36 | fi
37 |
38 | command -v autoreconf >/dev/null 2>&1
39 | if [ $? -ne 0 ]; then
40 | echo "autogen.sh: error: could not find autoreconf. autoconf and automake are required to run autogen.sh." 1>&2
41 | exit 1
42 | fi
43 |
44 | mkdir -p ./config
45 | if [ $? -ne 0 ]; then
46 | echo "autogen.sh: error: could not create directory: ./config." 1>&2
47 | exit 1
48 | fi
49 |
50 | autoreconf --install --force --verbose -I config
51 | if [ $? -ne 0 ]; then
52 | echo "autogen.sh: error: autoreconf exited with status $?" 1>&2
53 | exit 1
54 | fi
55 |
--------------------------------------------------------------------------------
/jzmq-jni/builds/msvc/config.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (c) 2007-2010 iMatix Corporation
3 |
4 | This file is part of 0MQ.
5 |
6 | 0MQ is free software; you can redistribute it and/or modify it under
7 | the terms of the Lesser GNU General Public License as published by
8 | the Free Software Foundation; either version 3 of the License, or
9 | (at your option) any later version.
10 |
11 | 0MQ is distributed in the hope that it will be useful,
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | Lesser GNU General Public License for more details.
15 |
16 | You should have received a copy of the Lesser GNU General Public License
17 | along with this program. If not, see .
18 | */
19 |
--------------------------------------------------------------------------------
/jzmq-jni/builds/msvc/local_lat/local_lat.vcproj:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
14 |
15 |
16 |
17 |
18 |
25 |
30 |
33 |
36 |
39 |
40 |
48 |
53 |
56 |
59 |
62 |
63 |
64 |
65 |
66 |
67 |
72 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
--------------------------------------------------------------------------------
/jzmq-jni/builds/msvc/local_lat/local_lat.vcxproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | Win32
7 |
8 |
9 | Debug
10 | x64
11 |
12 |
13 | Release
14 | Win32
15 |
16 |
17 | Release
18 | x64
19 |
20 |
21 |
22 | {6E023743-6824-46E4-A7E2-F9CEAD0D8A1D}
23 | local_lat
24 |
25 |
26 |
27 | Utility
28 | v110
29 | MultiByte
30 | true
31 |
32 |
33 | Utility
34 | v110
35 | MultiByte
36 | true
37 |
38 |
39 | Utility
40 | v110
41 | MultiByte
42 |
43 |
44 | Utility
45 | v110
46 | MultiByte
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 | <_ProjectFileVersion>11.0.61030.0
66 |
67 |
68 | $(SolutionDir)$(Configuration)\
69 | $(Configuration)\
70 |
71 |
72 |
73 | $(SolutionDir)$(Configuration)\
74 | $(Configuration)\
75 |
76 |
77 |
78 |
79 | Compiling Java classes
80 | javac -classpath ..\..\..\lib\zmq.jar;..\..\..\src\main\perf ..\..\..\src\main\perf\local_lat.java
81 |
82 |
83 |
84 |
85 | Compiling Java classes
86 | javac -classpath ..\..\..\lib\zmq.jar;..\..\..\src\main\perf ..\..\..\src\main\perf\local_lat.java
87 |
88 |
89 |
90 |
91 | Compiling Java classes
92 | javac -classpath ..\..\..\lib\zmq.jar;..\..\..\src\main\perf ..\..\..\src\main\perf\local_lat.java
93 |
94 |
95 |
96 |
97 | Compiling Java classes
98 | javac -classpath ..\..\..\lib\zmq.jar;..\..\..\src\main\perf ..\..\..\src\main\perf\local_lat.java
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 | {d4fc8ad4-eb3c-46aa-a67b-90d290a024f1}
107 | false
108 |
109 |
110 |
111 |
112 |
113 |
--------------------------------------------------------------------------------
/jzmq-jni/builds/msvc/local_thr/local_thr.vcproj:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
14 |
15 |
16 |
17 |
18 |
25 |
30 |
33 |
36 |
39 |
40 |
48 |
53 |
56 |
59 |
62 |
63 |
64 |
65 |
66 |
67 |
72 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
--------------------------------------------------------------------------------
/jzmq-jni/builds/msvc/local_thr/local_thr.vcxproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | Win32
7 |
8 |
9 | Debug
10 | x64
11 |
12 |
13 | Release
14 | Win32
15 |
16 |
17 | Release
18 | x64
19 |
20 |
21 |
22 | {BA759269-B4F7-44EA-82D3-BE69FACAE8E8}
23 | local_thr
24 |
25 |
26 |
27 | Utility
28 | v110
29 | MultiByte
30 | true
31 |
32 |
33 | Utility
34 | v110
35 | MultiByte
36 | true
37 |
38 |
39 | Utility
40 | v110
41 | MultiByte
42 |
43 |
44 | Utility
45 | v110
46 | MultiByte
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 | <_ProjectFileVersion>11.0.61030.0
66 |
67 |
68 | $(SolutionDir)$(Configuration)\
69 | $(Configuration)\
70 |
71 |
72 |
73 | $(SolutionDir)$(Configuration)\
74 | $(Configuration)\
75 |
76 |
77 |
78 |
79 | Compiling Java classes
80 | javac -classpath ..\..\..\lib\zmq.jar;..\..\..\src\main\perf ..\..\..\src\main\perf\local_thr.java
81 |
82 |
83 |
84 |
85 | Compiling Java classes
86 | javac -classpath ..\..\..\lib\zmq.jar;..\..\..\src\main\perf ..\..\..\src\main\perf\local_thr.java
87 |
88 |
89 |
90 |
91 | Compiling Java classes
92 | javac -classpath ..\..\..\lib\zmq.jar;..\..\..\src\main\perf ..\..\..\src\main\perf\local_thr.java
93 |
94 |
95 |
96 |
97 | Compiling Java classes
98 | javac -classpath ..\..\..\lib\zmq.jar;..\..\..\src\main\perf ..\..\..\src\main\perf\local_thr.java
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 | {d4fc8ad4-eb3c-46aa-a67b-90d290a024f1}
107 | false
108 |
109 |
110 |
111 |
112 |
113 |
--------------------------------------------------------------------------------
/jzmq-jni/builds/msvc/msvc.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 2012
4 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "jzmq", "jzmq\jzmq.vcxproj", "{D4FC8AD4-EB3C-46AA-A67B-90D290A024F1}"
5 | EndProject
6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "local_lat", "local_lat\local_lat.vcxproj", "{6E023743-6824-46E4-A7E2-F9CEAD0D8A1D}"
7 | EndProject
8 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "remote_lat", "remote_lat\remote_lat.vcxproj", "{A5D76DBB-258B-4A1D-8843-4E133E456245}"
9 | EndProject
10 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "local_thr", "local_thr\local_thr.vcxproj", "{BA759269-B4F7-44EA-82D3-BE69FACAE8E8}"
11 | EndProject
12 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "remote_thr", "remote_thr\remote_thr.vcxproj", "{D1423DF1-C423-4C85-916D-B5E9F1445931}"
13 | EndProject
14 | Global
15 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
16 | Debug|Win32 = Debug|Win32
17 | Debug|x64 = Debug|x64
18 | Release|Win32 = Release|Win32
19 | Release|x64 = Release|x64
20 | EndGlobalSection
21 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
22 | {D4FC8AD4-EB3C-46AA-A67B-90D290A024F1}.Debug|Win32.ActiveCfg = Release|x64
23 | {D4FC8AD4-EB3C-46AA-A67B-90D290A024F1}.Debug|Win32.Build.0 = Release|x64
24 | {D4FC8AD4-EB3C-46AA-A67B-90D290A024F1}.Debug|x64.ActiveCfg = Debug|x64
25 | {D4FC8AD4-EB3C-46AA-A67B-90D290A024F1}.Debug|x64.Build.0 = Debug|x64
26 | {D4FC8AD4-EB3C-46AA-A67B-90D290A024F1}.Release|Win32.ActiveCfg = Release|Win32
27 | {D4FC8AD4-EB3C-46AA-A67B-90D290A024F1}.Release|Win32.Build.0 = Release|Win32
28 | {D4FC8AD4-EB3C-46AA-A67B-90D290A024F1}.Release|x64.ActiveCfg = Release|x64
29 | {D4FC8AD4-EB3C-46AA-A67B-90D290A024F1}.Release|x64.Build.0 = Release|x64
30 | {6E023743-6824-46E4-A7E2-F9CEAD0D8A1D}.Debug|Win32.ActiveCfg = Release|Win32
31 | {6E023743-6824-46E4-A7E2-F9CEAD0D8A1D}.Debug|Win32.Build.0 = Release|Win32
32 | {6E023743-6824-46E4-A7E2-F9CEAD0D8A1D}.Debug|x64.ActiveCfg = Debug|x64
33 | {6E023743-6824-46E4-A7E2-F9CEAD0D8A1D}.Debug|x64.Build.0 = Debug|x64
34 | {6E023743-6824-46E4-A7E2-F9CEAD0D8A1D}.Release|Win32.ActiveCfg = Release|Win32
35 | {6E023743-6824-46E4-A7E2-F9CEAD0D8A1D}.Release|Win32.Build.0 = Release|Win32
36 | {6E023743-6824-46E4-A7E2-F9CEAD0D8A1D}.Release|x64.ActiveCfg = Release|x64
37 | {6E023743-6824-46E4-A7E2-F9CEAD0D8A1D}.Release|x64.Build.0 = Release|x64
38 | {A5D76DBB-258B-4A1D-8843-4E133E456245}.Debug|Win32.ActiveCfg = Release|Win32
39 | {A5D76DBB-258B-4A1D-8843-4E133E456245}.Debug|Win32.Build.0 = Release|Win32
40 | {A5D76DBB-258B-4A1D-8843-4E133E456245}.Debug|x64.ActiveCfg = Debug|x64
41 | {A5D76DBB-258B-4A1D-8843-4E133E456245}.Debug|x64.Build.0 = Debug|x64
42 | {A5D76DBB-258B-4A1D-8843-4E133E456245}.Release|Win32.ActiveCfg = Release|Win32
43 | {A5D76DBB-258B-4A1D-8843-4E133E456245}.Release|Win32.Build.0 = Release|Win32
44 | {A5D76DBB-258B-4A1D-8843-4E133E456245}.Release|x64.ActiveCfg = Release|x64
45 | {A5D76DBB-258B-4A1D-8843-4E133E456245}.Release|x64.Build.0 = Release|x64
46 | {BA759269-B4F7-44EA-82D3-BE69FACAE8E8}.Debug|Win32.ActiveCfg = Release|Win32
47 | {BA759269-B4F7-44EA-82D3-BE69FACAE8E8}.Debug|Win32.Build.0 = Release|Win32
48 | {BA759269-B4F7-44EA-82D3-BE69FACAE8E8}.Debug|x64.ActiveCfg = Debug|x64
49 | {BA759269-B4F7-44EA-82D3-BE69FACAE8E8}.Debug|x64.Build.0 = Debug|x64
50 | {BA759269-B4F7-44EA-82D3-BE69FACAE8E8}.Release|Win32.ActiveCfg = Release|Win32
51 | {BA759269-B4F7-44EA-82D3-BE69FACAE8E8}.Release|Win32.Build.0 = Release|Win32
52 | {BA759269-B4F7-44EA-82D3-BE69FACAE8E8}.Release|x64.ActiveCfg = Release|x64
53 | {BA759269-B4F7-44EA-82D3-BE69FACAE8E8}.Release|x64.Build.0 = Release|x64
54 | {D1423DF1-C423-4C85-916D-B5E9F1445931}.Debug|Win32.ActiveCfg = Release|Win32
55 | {D1423DF1-C423-4C85-916D-B5E9F1445931}.Debug|Win32.Build.0 = Release|Win32
56 | {D1423DF1-C423-4C85-916D-B5E9F1445931}.Debug|x64.ActiveCfg = Debug|x64
57 | {D1423DF1-C423-4C85-916D-B5E9F1445931}.Debug|x64.Build.0 = Debug|x64
58 | {D1423DF1-C423-4C85-916D-B5E9F1445931}.Release|Win32.ActiveCfg = Release|Win32
59 | {D1423DF1-C423-4C85-916D-B5E9F1445931}.Release|Win32.Build.0 = Release|Win32
60 | {D1423DF1-C423-4C85-916D-B5E9F1445931}.Release|x64.ActiveCfg = Release|x64
61 | {D1423DF1-C423-4C85-916D-B5E9F1445931}.Release|x64.Build.0 = Release|x64
62 | EndGlobalSection
63 | GlobalSection(SolutionProperties) = preSolution
64 | HideSolutionNode = FALSE
65 | EndGlobalSection
66 | EndGlobal
67 |
--------------------------------------------------------------------------------
/jzmq-jni/builds/msvc/remote_lat/remote_lat.vcproj:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
14 |
15 |
16 |
17 |
18 |
25 |
30 |
33 |
36 |
39 |
40 |
48 |
53 |
56 |
59 |
62 |
63 |
64 |
65 |
66 |
67 |
72 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
--------------------------------------------------------------------------------
/jzmq-jni/builds/msvc/remote_lat/remote_lat.vcxproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | Win32
7 |
8 |
9 | Debug
10 | x64
11 |
12 |
13 | Release
14 | Win32
15 |
16 |
17 | Release
18 | x64
19 |
20 |
21 |
22 | {A5D76DBB-258B-4A1D-8843-4E133E456245}
23 | remote_lat
24 |
25 |
26 |
27 | Utility
28 | v110
29 | MultiByte
30 | true
31 |
32 |
33 | Utility
34 | v110
35 | MultiByte
36 | true
37 |
38 |
39 | Utility
40 | v110
41 | MultiByte
42 |
43 |
44 | Utility
45 | v110
46 | MultiByte
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 | <_ProjectFileVersion>11.0.61030.0
66 |
67 |
68 | $(SolutionDir)$(Configuration)\
69 | $(Configuration)\
70 |
71 |
72 |
73 | $(SolutionDir)$(Configuration)\
74 | $(Configuration)\
75 |
76 |
77 |
78 |
79 | Compiling Java classes
80 | javac -classpath ..\..\..\lib\zmq.jar;..\..\..\src\main\perf ..\..\..\src\main\perf\remote_lat.java
81 |
82 |
83 |
84 |
85 | Compiling Java classes
86 | javac -classpath ..\..\..\lib\zmq.jar;..\..\..\src\main\perf ..\..\..\src\main\perf\remote_lat.java
87 |
88 |
89 |
90 |
91 | Compiling Java classes
92 | javac -classpath ..\..\..\lib\zmq.jar;..\..\..\src\main\perf ..\..\..\src\main\perf\remote_lat.java
93 |
94 |
95 |
96 |
97 | Compiling Java classes
98 | javac -classpath ..\..\..\lib\zmq.jar;..\..\..\src\main\perf ..\..\..\src\main\perf\remote_lat.java
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 | {d4fc8ad4-eb3c-46aa-a67b-90d290a024f1}
107 | false
108 |
109 |
110 |
111 |
112 |
113 |
--------------------------------------------------------------------------------
/jzmq-jni/builds/msvc/remote_thr/remote_thr.vcproj:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
14 |
15 |
16 |
17 |
18 |
25 |
30 |
33 |
36 |
39 |
40 |
48 |
53 |
56 |
59 |
62 |
63 |
64 |
65 |
66 |
67 |
72 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
--------------------------------------------------------------------------------
/jzmq-jni/builds/msvc/remote_thr/remote_thr.vcxproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | Win32
7 |
8 |
9 | Debug
10 | x64
11 |
12 |
13 | Release
14 | Win32
15 |
16 |
17 | Release
18 | x64
19 |
20 |
21 |
22 | {D1423DF1-C423-4C85-916D-B5E9F1445931}
23 | remote_thr
24 |
25 |
26 |
27 | Utility
28 | v110
29 | MultiByte
30 | true
31 |
32 |
33 | Utility
34 | v110
35 | MultiByte
36 | true
37 |
38 |
39 | Utility
40 | v110
41 | MultiByte
42 |
43 |
44 | Utility
45 | v110
46 | MultiByte
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 | <_ProjectFileVersion>11.0.61030.0
66 |
67 |
68 | $(SolutionDir)$(Configuration)\
69 | $(Configuration)\
70 |
71 |
72 |
73 | $(SolutionDir)$(Configuration)\
74 | $(Configuration)\
75 |
76 |
77 |
78 |
79 | Compiling Java classes
80 | javac -classpath ..\..\..\lib\zmq.jar;..\..\..\src ..\..\..\src\main\perf\remote_thr.java
81 |
82 |
83 |
84 |
85 | Compiling Java classes
86 | javac -classpath ..\..\..\lib\zmq.jar;..\..\..\src ..\..\..\src\main\perf\remote_thr.java
87 |
88 |
89 |
90 |
91 | Compiling Java classes
92 | javac -classpath ..\..\..\lib\zmq.jar;..\..\..\src ..\..\..\src\main\perf\remote_thr.java
93 |
94 |
95 |
96 |
97 | Compiling Java classes
98 | javac -classpath ..\..\..\lib\zmq.jar;..\..\..\src ..\..\..\src\main\perf\remote_thr.java
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 | {d4fc8ad4-eb3c-46aa-a67b-90d290a024f1}
107 | false
108 |
109 |
110 |
111 |
112 |
113 |
--------------------------------------------------------------------------------
/jzmq-jni/config/ax_jni_include_dir.m4:
--------------------------------------------------------------------------------
1 | # ===========================================================================
2 | # http://www.gnu.org/software/autoconf-archive/ax_jni_include_dir.html
3 | # ===========================================================================
4 | #
5 | # SYNOPSIS
6 | #
7 | # AX_JNI_INCLUDE_DIR
8 | #
9 | # DESCRIPTION
10 | #
11 | # AX_JNI_INCLUDE_DIR finds include directories needed for compiling
12 | # programs using the JNI interface.
13 | #
14 | # JNI include directories are usually in the java distribution This is
15 | # deduced from the value of JAVAC. When this macro completes, a list of
16 | # directories is left in the variable JNI_INCLUDE_DIRS.
17 | #
18 | # Example usage follows:
19 | #
20 | # AX_JNI_INCLUDE_DIR
21 | #
22 | # for JNI_INCLUDE_DIR in $JNI_INCLUDE_DIRS
23 | # do
24 | # CPPFLAGS="$CPPFLAGS -I$JNI_INCLUDE_DIR"
25 | # done
26 | #
27 | # If you want to force a specific compiler:
28 | #
29 | # - at the configure.in level, set JAVAC=yourcompiler before calling
30 | # AX_JNI_INCLUDE_DIR
31 | #
32 | # - at the configure level, setenv JAVAC
33 | #
34 | # Note: This macro can work with the autoconf M4 macros for Java programs.
35 | # This particular macro is not part of the original set of macros.
36 | #
37 | # LICENSE
38 | #
39 | # Copyright (c) 2008 Don Anderson
40 | #
41 | # Copying and distribution of this file, with or without modification, are
42 | # permitted in any medium without royalty provided the copyright notice
43 | # and this notice are preserved. This file is offered as-is, without any
44 | # warranty.
45 |
46 | #serial 7
47 |
48 | AU_ALIAS([AC_JNI_INCLUDE_DIR], [AX_JNI_INCLUDE_DIR])
49 | AC_DEFUN([AX_JNI_INCLUDE_DIR],[
50 |
51 | JNI_INCLUDE_DIRS=""
52 |
53 | test "x$JAVAC" = x && AC_MSG_ERROR(['\$JAVAC' undefined])
54 | AC_PATH_PROG([_ACJNI_JAVAC], [$JAVAC], [no], [$PATH$PATH_SEPARATOR/])
55 | test "x$_ACJNI_JAVAC" = xno && AC_MSG_ERROR([$JAVAC could not be found in path])
56 |
57 | _ACJNI_FOLLOW_SYMLINKS("$_ACJNI_JAVAC")
58 | _JTOPDIR=`echo "$_ACJNI_FOLLOWED" | sed -e 's://*:/:g' -e 's:/[[^/]]*$::'`
59 | case "$host_os" in
60 | darwin*) _JTOPDIR=`echo "$_JTOPDIR" | sed -e 's:/[[^/]]*$::'`
61 | _JINC="$_JTOPDIR/Headers"
62 | if ! test -d "$_JINC"; then
63 | _JTOPDIR="$(/usr/libexec/java_home)"
64 | _JINC="$_JTOPDIR/include"
65 | fi;;
66 | *) _JINC="$_JTOPDIR/include";;
67 | esac
68 | #_AS_ECHO_LOG([_JTOPDIR=$_JTOPDIR])
69 | #_AS_ECHO_LOG([_JINC=$_JINC])
70 |
71 | # On Mac OS X 10.6.4, jni.h is a symlink:
72 | # /System/Library/Frameworks/JavaVM.framework/Versions/Current/Headers/jni.h
73 | # -> ../../CurrentJDK/Headers/jni.h.
74 | if test -f "$_JINC/jni.h" || test -L "$_JINC/jni.h"; then
75 | JNI_INCLUDE_DIRS="$JNI_INCLUDE_DIRS $_JINC"
76 | else
77 | _JTOPDIR=`echo "$_JTOPDIR" | sed -e 's:/[[^/]]*$::'`
78 | if test -f "$_JTOPDIR/include/jni.h"; then
79 | JNI_INCLUDE_DIRS="$JNI_INCLUDE_DIRS $_JTOPDIR/include"
80 | else
81 | AC_MSG_ERROR([cannot find java include files])
82 | fi
83 | fi
84 |
85 | # get the likely subdirectories for system specific java includes
86 | case "$host_os" in
87 | bsdi*) _JNI_INC_SUBDIRS="bsdos";;
88 | linux*) _JNI_INC_SUBDIRS="linux genunix";;
89 | darwin*) _JNI_INC_SUBDIRS="darwin";;
90 | osf*) _JNI_INC_SUBDIRS="alpha";;
91 | solaris*) _JNI_INC_SUBDIRS="solaris";;
92 | mingw*) _JNI_INC_SUBDIRS="win32";;
93 | cygwin*) _JNI_INC_SUBDIRS="win32";;
94 | *) _JNI_INC_SUBDIRS="genunix";;
95 | esac
96 |
97 | # add any subdirectories that are present
98 | for JINCSUBDIR in $_JNI_INC_SUBDIRS
99 | do
100 | if test -d "$_JTOPDIR/include/$JINCSUBDIR"; then
101 | JNI_INCLUDE_DIRS="$JNI_INCLUDE_DIRS $_JTOPDIR/include/$JINCSUBDIR"
102 | fi
103 | done
104 | ])
105 |
106 | # _ACJNI_FOLLOW_SYMLINKS
107 | # Follows symbolic links on ,
108 | # finally setting variable _ACJNI_FOLLOWED
109 | # ----------------------------------------
110 | AC_DEFUN([_ACJNI_FOLLOW_SYMLINKS],[
111 | # find the include directory relative to the javac executable
112 | _cur="$1"
113 | while ls -ld "$_cur" 2>/dev/null | grep " -> " >/dev/null; do
114 | AC_MSG_CHECKING([symlink for $_cur])
115 | _slink=`ls -ld "$_cur" | sed 's/.* -> //'`
116 | case "$_slink" in
117 | /*) _cur="$_slink";;
118 | # 'X' avoids triggering unwanted echo options.
119 | *) _cur=`echo "X$_cur" | sed -e 's/^X//' -e 's:[[^/]]*$::'`"$_slink";;
120 | esac
121 | AC_MSG_RESULT([$_cur])
122 | done
123 | _ACJNI_FOLLOWED="$_cur"
124 | ])# _ACJNI
125 |
--------------------------------------------------------------------------------
/jzmq-jni/configure.in:
--------------------------------------------------------------------------------
1 | # -*- Autoconf -*-
2 | # Process this file with autoconf to produce a configure script.
3 | # AC_PREREQ(2.59)
4 | #
5 | # Change the version number below after doing a public release.
6 | # The version in git should reflect the *next* version planned.
7 | # Version must be MAJOR.MINOR.PATCH otherwise things will break.
8 | #
9 | AC_INIT([jzmq],[4.0.0],[zeromq-dev@lists.zeromq.org])
10 |
11 | AC_CONFIG_AUX_DIR(config)
12 | AC_CONFIG_MACRO_DIR(config)
13 | AC_CONFIG_HEADERS(src/main/c++/config.hpp)
14 | AM_INIT_AUTOMAKE(tar-ustar)
15 |
16 | #
17 | # Libtool -version-info (ABI version)
18 | #
19 | # Currently 0.0.0 ("unstable"). Don't change this unless you
20 | # know exactly what you're doing and have read and understand
21 | # http://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html
22 | #
23 | # libjzmq -version-info
24 | JLTVER="0:0:0"
25 | AC_SUBST(JLTVER)
26 |
27 | # Checks for programs.
28 | AC_PROG_LIBTOOL
29 | #AC_PROG_RANLIB
30 | # AC_PROG_SED
31 | AC_PROG_AWK
32 | AM_PROG_CC_C_O
33 | AC_PROG_CXX
34 | AC_LANG(C++)
35 |
36 | # Set default CPPFLAGS for reentrant code
37 | CPPFLAGS="-D_REENTRANT -D_THREAD_SAFE $CPPFLAGS"
38 |
39 | # Check for zeromq library
40 | zeromq_prefix=detect
41 | AC_ARG_WITH([zeromq],
42 | [AS_HELP_STRING([--with-zeromq=PREFIX],
43 | [build with ZeroMQ library installed in PREFIX [default=autodetect]])],
44 | [case "x$withval" in
45 | xno)
46 | AC_MSG_ERROR([jzmq requires the ZeroMQ library])
47 | ;;
48 | xyes|x)
49 | ;;
50 | *)
51 | CPPFLAGS="$CPPFLAGS -I${withval}/include"
52 | LDFLAGS="$LDFLAGS -L${withval}/lib"
53 | zeromq_prefix=${withval}
54 | ;;
55 | esac ]
56 | )
57 | if test "x$zeromq_prefix" = "xdetect"; then
58 | PKG_CHECK_MODULES(
59 | [ZeroMQ], [libzmq], [zeromq_prefix=pkgconfig], [zeromq_prefix=])
60 | if test "x$zeromq_prefix" = "xpkgconfig"; then
61 | CPPFLAGS="$CPPFLAGS ${ZeroMQ_CFLAGS}"
62 | LDFLAGS="$LDFLAGS ${ZeroMQ_LIBS}"
63 | fi
64 | fi
65 |
66 | AC_ARG_ENABLE([version],
67 | [AS_HELP_STRING([--enable-version], [builds with version information embedded [default=yes]])])
68 | AM_CONDITIONAL(DISABLE_VERSION, test "x$enable_version" = "xno")
69 |
70 | AC_CHECK_HEADER([zmq.h], [],
71 | [AC_MSG_ERROR([cannot find zmq.h])])
72 |
73 | AC_ARG_ENABLE([self-contained],
74 | [AS_HELP_STRING([--enable-self-contained], [generates a library that embeds all its external dependencies [default=no]])])
75 |
76 | AC_ARG_ENABLE([self-contained-uuid],
77 | [AS_HELP_STRING([--enable-self-contained-uuid], [embeds the libuuid dependency in the shared object [default=no]])])
78 |
79 | AC_CHECK_LIB([zmq], [zmq_init],
80 | [
81 | if test "x$enable_self_contained" = "xyes"; then
82 | LDFLAGS="$LDFLAGS -Wl,-Bstatic -Wl,-lzmq -Wl,-Bdynamic"
83 | else
84 | LIBS="-lzmq $LIBS"
85 | fi
86 | if test "x$enable_self_contained_uuid" = "xyes"; then
87 | LDFLAGS="$LDFLAGS -Wl,-luuid"
88 | fi
89 | ],
90 | [AC_MSG_ERROR([cannot link with -lzmq])])
91 |
92 | # Check for JDK
93 | test "x$JAVAC" = x && AC_CHECK_PROGS(JAVAC, javac -encoding ut8)
94 | test "x$JAVAC" = x && AC_MSG_ERROR([cannot find javac])
95 | AC_SUBST(JAVAC)
96 | AC_SUBST(JAVACFLAGS)
97 |
98 | test "x$JAR" = x && AC_CHECK_PROGS(JAR, jar)
99 | test "x$JAR" = x && AC_MSG_ERROR([cannot find jar])
100 | AC_SUBST(JAR)
101 |
102 | JAVAROOT=.
103 | AC_SUBST(JAVAROOT)
104 |
105 | # Checks for libraries.
106 | AX_JNI_INCLUDE_DIR
107 | for JNI_INCLUDE_DIR in $JNI_INCLUDE_DIRS; do
108 | CPPFLAGS="$CPPFLAGS -I$JNI_INCLUDE_DIR"
109 | done
110 | AC_SUBST(CPPFLAGS)
111 |
112 | # Checks for typedefs, structures, and compiler characteristics.
113 | AC_C_CONST
114 | AC_TYPE_SIZE_T
115 |
116 | AC_OUTPUT(Makefile src/main/c++/Makefile src/main/perf/Makefile)
117 |
--------------------------------------------------------------------------------
/jzmq-jni/debian/changelog:
--------------------------------------------------------------------------------
1 | jzmq (3.1.0-1) precise; urgency=low
2 | * Check changelog for updates
3 |
4 | -- Trevor Bernard Thu, 10 Oct 2013 13:07:44 -0300
5 |
6 | jzmq (2.2.2-1) precise; urgency=low
7 | * Fix issue #241 - Fix travis-ci build
8 | * Update the appropriate build files to the correct version
9 |
10 | -- Trevor Bernard Thu, 01 Aug 2013 09:02:27 -0300
11 |
12 | jzmq (2.2.1-1) precise; urgency=low
13 | * Fix issue ZeroMQ 2.x compatibility
14 |
15 | -- Trevor Bernard Mon, 29 Jul 2013 13:06:19 -0300
16 |
17 | jzmq (2.2.0-1) precise; urgency=low
18 | * Add toString method to ZMsg
19 | * Fix README, plus note about JeroMQ
20 | * Add unit test for issue #216
21 | * Fix NullPointerException in Poller and fix bad null login in JNI
22 | * Fix issue #81 - invalid conversion from 'const jbyte*' to 'jbyte*'
23 | * Fix zero copy send
24 | * Add ByteBuffer API for send and recv
25 | * Fix issue #226 - Socket and Context now implement CLoseable
26 | * Fix issue #228 - Socket and Context no longer override finalize
27 |
28 | -- Trevor Bernard Mon, 27 May 2013 21:46:40 -0300
29 |
30 | jzmq (2.1.3-1) precise; urgency=low
31 | * Fix issue #200 - Correct inaccurate javadocs for setTCPKeepAliveInterval and setTCPKeepAliveIdle
32 | * Fixed unregisterInternal to skip PollItems which were nulled by a previous unregisterInternal.
33 | * Fix Issue #203 - An overriding instance method doesn't have to throw exceptions specified by it's superclass.
34 | * Prevent EINVAL in setsockopt
35 | * Fix issue #197 - Only sign artifacts when it's time to release
36 | * Create CMakeLists.txt
37 | * Work around to a Locale javac bug
38 | * test added to verify sockopt ZMQ_XPUB_VERBOSE
39 | * Add set method for sockopt ZMQ_XPUB_VERBOSE
40 | * recvZeroCopy failure is hidden by failure to set position on ByteBuffer
41 | * Fix #186 - Enforce only calling finalize once in Socket and Context
42 | * Fixed ZMQ.Socket.setRecoveryInterval() to work with v3.0.0 and up.
43 |
44 | -- Trevor Bernard Sun, 14 Apr 2013 21:04:55 -0300
45 |
46 | jzmq (2.1.2-1) precise; urgency=low
47 |
48 | * Remove assert where runtime errors are more appropriate
49 | * Use utf8 when compiling java
50 | * Add unit test for REQ/REP send more
51 | * Update comment on ZDispatcher to warn users about busy spin wait strategy
52 | * Fix regression where compatibility with zmq 2.1.X was broken by zero copy
53 |
54 | -- Trevor Bernard Sun, 17 Feb 2013 20:38:05 -0400
55 |
56 | jzmq (2.1.1-1) precise; urgency=low
57 |
58 | * Add zero copy API to send and recv
59 | * Remove asserts from get_context JNI
60 | * Add ZLoop support
61 | * Poller rewrite
62 | * No longer c assert when trying to write to a closed Socket
63 | * Add a continuous integration support through travis-ci
64 |
65 | -- Trevor Bernard Sun, 17 Feb 2013 20:38:05 -0400
66 |
67 | jzmq (2.1.0-1) unstable; urgency=low
68 |
69 | * Development release
70 |
71 | -- Alois Bělaška Thu, 09 Dec 2010 11:44:56 +0100
72 |
73 | jzmq (2.0.9-1) unstable; urgency=low
74 |
75 | * Initial release
76 |
77 | -- Alois Bělaška Wed, 08 Dec 2010 11:15:56 +0100
78 |
--------------------------------------------------------------------------------
/jzmq-jni/debian/compat:
--------------------------------------------------------------------------------
1 | 7
2 |
--------------------------------------------------------------------------------
/jzmq-jni/debian/control:
--------------------------------------------------------------------------------
1 | Source: jzmq
2 | Section: libs
3 | Priority: optional
4 | Maintainer: Alois Belaska
5 | Build-Depends: debhelper (>= 7), libzmq-dev [amd64 i386]|libzmq3-dev [amd64 i386], sun-java6-jdk | openjdk-6-jdk, libpgm-dev, pkg-config, libtool, autoconf
6 | Standards-Version: 3.9.1
7 | Homepage: https://github.com/zeromq/jzmq
8 |
9 | Package: jzmq
10 | Architecture: any
11 | Depends: libzmq0 (>= 2.0.10)| libzmq1 (>= 2.0.10), libpgm|libpgm-5.1-0, ${shlibs:Depends}, ${misc:Depends}
12 | Description: The Java ZeroMQ bindings
13 | The 0MQ lightweight messaging kernel is a library which extends the standard
14 | socket interfaces with features traditionally provided by specialised
15 | messaging middleware products. 0MQ sockets provide an abstraction
16 | of asynchronous message queues, multiple messaging patterns, message
17 | filtering (subscriptions), seamless access to multiple transport
18 | protocols and more.
19 | This package contains the Java Bindings for ZeroMQ.
20 |
21 |
--------------------------------------------------------------------------------
/jzmq-jni/debian/copyright:
--------------------------------------------------------------------------------
1 | This package was debianized by
2 | Alois Belaska
3 |
4 | The packaging scripts are ©2009-2010 by these authors and are distributed
5 | under the same terms as the zeromq library (LGPL 2 or later.)
6 |
7 |
8 | Licensing information for 0MQ
9 | -----------------------------
10 |
11 | Project homepage, with original source code:
12 | http://www.zeromq.org/
13 |
14 | Copyright and Upstream Authors:
15 |
16 | Copyright © 2007-2010 iMatix Corporation
17 |
18 | License:
19 |
20 | This package is free software; you can redistribute it and/or
21 | modify it under the terms of the GNU Lesser General Public
22 | License as published by the Free Software Foundation; either
23 | version 2 of the License, or (at your option) any later version.
24 |
25 | This package is distributed in the hope that it will be useful,
26 | but WITHOUT ANY WARRANTY; without even the implied warranty of
27 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
28 | Lesser General Public License for more details.
29 |
30 | You should have received a copy of the GNU Lesser General Public
31 | License along with this package; if not, write to the Free Software
32 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
33 |
34 | On Debian systems, the complete text of the GNU Lesser General
35 | Public License can be found in `/usr/share/common-licenses/LGPL'.
36 |
37 | iMatix also offers commercial licenses for 0MQ.
38 |
39 |
40 | Licensing information for the included OpenPGM library
41 | ------------------------------------------------------
42 |
43 | Project homepage, with original source code:
44 | http://code.google.com/p/openpgm/
45 |
46 | Copyright and Upstream Authors:
47 | Copyright © 2006-2010 Miru Limited.
48 | Copyright © 1995, 1996, 2001, 2003 Free Software Foundation, Inc.
49 | Copyright © 2002, 2003 Andi Kleen, SuSE Labs.
50 |
51 | License:
52 | Most of OpenPGM is licensed under the terms of the GNU Lesser Public
53 | License, the LGPL, see the file COPYING for details.
54 |
55 | The ultra-high performance partial checksum & folding routines that are
56 | taken from the Linux kernel and licensed under the terms of the GNU General
57 | Public License, the GPL, see the file COPYING.GPL for details.
58 |
59 | Hence you should treat the libraries libpgm, libpgmsnmp, and libpgmhttp of
60 | OpenPGM as being LGPL licensed and the library libpgmplus as being GPL
61 | licensed.
62 |
63 | (Packager's note: "GPL" in the context of the Linux kernel means GPL 2. 0MQ
64 | doesn't use those files during build or runtime, so it is not relevant for the
65 | license of zeromq itself.))
66 |
67 | Commercial licenses are also offered.
68 |
69 | On Debian systems, the complete text of the GNU Lesser General
70 | Public License can be found in `/usr/share/common-licenses/LGPL'.
71 |
72 | On Debian systems, the complete text of the GNU General Public
73 | License can be found in `/usr/share/common-licenses/GPL-2'.
74 |
75 |
76 |
77 | Licensing information for the included XMLParser library
78 | --------------------------------------------------------
79 |
80 | From xmlParser.hpp:
81 |
82 | Copyright (c) 2002, Frank Vanden Berghen
83 | All rights reserved.
84 |
85 | The following license terms apply to projects that are in some way related to
86 | the "ZeroMQ project", including applications
87 | using "ZeroMQ project" and tools developed
88 | for enhancing "ZeroMQ project". All other projects
89 | (not related to "ZeroMQ project") have to use this
90 | code under the Aladdin Free Public License (AFPL)
91 | See the file "AFPL-license.txt" for more informations about the AFPL license.
92 | (see http://www.artifex.com/downloads/doc/Public.htm for detailed AFPL terms)
93 |
94 | Redistribution and use in source and binary forms, with or without
95 | modification, are permitted provided that the following conditions are met:
96 | * Redistributions of source code must retain the above copyright
97 | notice, this list of conditions and the following disclaimer.
98 | * Redistributions in binary form must reproduce the above copyright
99 | notice, this list of conditions and the following disclaimer in the
100 | documentation and/or other materials provided with the distribution.
101 | * Neither the name of Frank Vanden Berghen nor the
102 | names of its contributors may be used to endorse or promote products
103 | derived from this software without specific prior written permission.
104 |
105 |
--------------------------------------------------------------------------------
/jzmq-jni/debian/docs:
--------------------------------------------------------------------------------
1 | AUTHORS
2 | NEWS
3 | README
4 |
--------------------------------------------------------------------------------
/jzmq-jni/debian/jzmq.install:
--------------------------------------------------------------------------------
1 | usr/lib/libjzmq.so*
2 | usr/share/java/zmq.jar
3 |
--------------------------------------------------------------------------------
/jzmq-jni/debian/rules:
--------------------------------------------------------------------------------
1 | #!/usr/bin/make -f
2 |
3 | #export DH_VERBOSE=1
4 |
5 | DEB_HOST_ARCH := $(shell dpkg-architecture -qDEB_HOST_ARCH)
6 |
7 | ifneq (,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
8 | NUMJOBS = $(patsubst parallel=%,%,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
9 | MAKEFLAGS += -j$(NUMJOBS)
10 | endif
11 |
12 |
13 | configure: configure-stamp
14 | configure-stamp:
15 | dh_testdir
16 |
17 | ./autogen.sh
18 | ./configure $(CROSS) \
19 | --prefix=/usr \
20 | CFLAGS="$(CFLAGS)" \
21 | LDFLAGS="-Wl,--as-needed -Wl,-z,defs" \
22 |
23 | touch configure-stamp
24 |
25 | build: build-stamp
26 |
27 | build-stamp: configure-stamp
28 | dh_testdir
29 |
30 | $(MAKE) $(MAKEFLAGS)
31 |
32 | touch $@
33 |
34 | clean:
35 | dh_testdir
36 | dh_testroot
37 | rm -f build-stamp configure-stamp
38 |
39 | if [ -e Makefile ]; then make distclean; fi
40 | rm -rf config.log
41 |
42 | dh_clean
43 |
44 | install: build
45 | dh_testdir
46 | dh_testroot
47 | dh_prep
48 | dh_installdirs
49 |
50 | $(MAKE) DESTDIR=$(CURDIR)/debian/tmp install
51 |
52 | binary-indep: build install
53 |
54 | binary-arch: build install
55 | dh_testdir
56 | dh_testroot
57 | dh_install
58 | dh_installchangelogs
59 | dh_installdocs
60 | dh_lintian
61 | dh_link
62 | dh_compress
63 | dh_fixperms
64 | dh_makeshlibs
65 | dh_installdeb
66 | dh_shlibdeps
67 | dh_gencontrol
68 | dh_md5sums
69 | dh_builddeb
70 |
71 | binary: binary-indep binary-arch
72 | .PHONY: build clean binary-indep binary-arch binary install configure
73 |
--------------------------------------------------------------------------------
/jzmq-jni/jzmq.spec:
--------------------------------------------------------------------------------
1 | Name: jzmq
2 | Version: 3.1.0
3 | Release: 1%{?dist}
4 | Summary: The Java ZeroMQ bindings
5 | Group: Applications/Internet
6 | License: LGPLv3+
7 | URL: http://www.zeromq.org/
8 | Source: http://www.zeromq.org/local--files/area:download/%{name}-%{version}.tar.gz
9 | Prefix: %{_prefix}
10 | Buildroot: %{_tmppath}/%{name}-%{version}-%{release}-root
11 | BuildRequires: gcc, make, gcc-c++, libstdc++-devel
12 | Requires: libstdc++, zeromq
13 |
14 | %description
15 | The 0MQ lightweight messaging kernel is a library which extends the
16 | standard socket interfaces with features traditionally provided by
17 | specialised messaging middleware products. 0MQ sockets provide an
18 | abstraction of asynchronous message queues, multiple messaging
19 | patterns, message filtering (subscriptions), seamless access to
20 | multiple transport protocols and more.
21 |
22 | This package contains the Java Bindings for ZeroMQ.
23 |
24 | %package devel
25 | Summary: Development files and static library for the Java Bindings for the ZeroMQ library.
26 | Group: Development/Libraries
27 | Requires: %{name} = %{version}-%{release}, pkgconfig
28 |
29 | %description devel
30 | The 0MQ lightweight messaging kernel is a library which extends the
31 | standard socket interfaces with features traditionally provided by
32 | specialised messaging middleware products. 0MQ sockets provide an
33 | abstraction of asynchronous message queues, multiple messaging
34 | patterns, message filtering (subscriptions), seamless access to
35 | multiple transport protocols and more.
36 |
37 | This package contains Java Bindings for ZeroMQ related development libraries and header files.
38 |
39 | %prep
40 | %setup -q
41 |
42 | ./autogen.sh
43 | %build
44 | %configure
45 |
46 | %{__make}
47 |
48 | %install
49 | [ "%{buildroot}" != "/" ] && %{__rm} -rf %{buildroot}
50 |
51 | # Install the package to build area
52 | %makeinstall
53 |
54 | %post
55 | /sbin/ldconfig
56 |
57 | %postun
58 | /sbin/ldconfig
59 |
60 | %clean
61 | [ "%{buildroot}" != "/" ] && %{__rm} -rf %{buildroot}
62 |
63 | %files
64 | %defattr(-,root,root,-)
65 |
66 | # docs in the main package
67 | %doc AUTHORS ChangeLog COPYING COPYING.LESSER NEWS README
68 |
69 | # libraries
70 | %{_libdir}/libjzmq.so*
71 | /usr/share/java/zmq.jar
72 | /usr/share/perf/zmq-perf.jar
73 |
74 | %files devel
75 | %defattr(-,root,root,-)
76 | %{_libdir}/libjzmq.la
77 | %{_libdir}/libjzmq.a
78 |
79 | %changelog
80 | * Thu Dec 09 2010 Alois Belaska
81 | - version of package changed to 2.1.0
82 | * Tue Sep 21 2010 Stefan Majer
83 | - Initial packaging
84 |
--------------------------------------------------------------------------------
/jzmq-jni/nativejar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | native-${native.arch}-${native.os}${native.distro}${native.zmq.version}
4 |
5 | jar
6 |
7 | false
8 |
9 |
10 | ${native.path.resolved}
11 | NATIVE/${native.arch}/${native.os}
12 | 0644
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/jzmq-jni/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 4.0.0
4 |
5 |
6 | org.zeromq
7 | jzmq-parent
8 | 3.1.1-SNAPSHOT
9 |
10 |
11 | org.zeromq
12 | jzmq-jni
13 | jar
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 | os-distro
23 |
24 |
25 | os.distro
26 |
27 |
28 |
29 | -${os.distro}
30 |
31 |
32 |
33 | zmq-version
34 |
35 |
36 | zmq.version
37 |
38 |
39 |
40 | -${zmq.version}
41 |
42 |
43 |
44 | release
45 |
46 | ..${file.separator}..${file.separator}${native.path}
47 | ..${file.separator}..${file.separator}${native.library-path}
48 |
49 |
50 |
51 |
52 |
53 |
54 | org.powermock
55 | powermock-easymock-release-full
56 | 1.6.4
57 | test
58 | pom
59 |
60 |
61 | org.easymock
62 | easymock
63 | 3.4
64 | test
65 |
66 |
67 |
68 |
69 |
70 |
71 | org.commonjava.maven.plugins
72 | directory-maven-plugin
73 |
74 |
75 | org.apache.maven.plugins
76 | maven-gpg-plugin
77 |
78 |
79 | sign-artifacts
80 | verify
81 |
82 | sign
83 |
84 |
85 |
86 |
87 |
88 | maven-assembly-plugin
89 |
90 |
91 |
92 | nativejar.xml
93 |
94 |
95 |
96 |
97 | make-assembly
98 | package
99 |
100 | single
101 |
102 |
103 |
104 |
105 |
106 | org.codehaus.mojo
107 | buildnumber-maven-plugin
108 |
109 |
110 | validate
111 |
112 | create
113 |
114 |
115 |
116 |
117 | false
118 | false
119 | buildTimestamp
120 | {0,date,yyyy-MM-dd HH:mm Z}
121 |
122 |
123 |
124 | org.apache.maven.plugins
125 | maven-release-plugin
126 |
127 | true
128 | false
129 | release
130 | v@{project.version}
131 |
132 |
133 |
134 | org.apache.maven.plugins
135 | maven-scm-plugin
136 |
137 |
138 | org.apache.maven.plugins
139 | maven-jar-plugin
140 | true
141 |
142 |
143 |
144 | true
145 |
146 |
147 | ${buildNumber} ${buildTimestamp}
148 |
149 |
150 |
151 |
152 |
153 | org.apache.maven.plugins
154 | maven-shade-plugin
155 |
156 |
157 | package
158 |
159 | shade
160 |
161 |
162 |
163 |
164 |
165 | org.zeromq.App
166 |
167 |
168 |
169 |
170 |
171 |
172 |
173 |
174 | org.apache.maven.plugins
175 | maven-deploy-plugin
176 |
177 |
178 | org.apache.maven.plugins
179 | maven-source-plugin
180 |
181 |
182 | attach-sources
183 |
184 | jar
185 |
186 |
187 |
188 |
189 |
190 | org.apache.maven.plugins
191 | maven-javadoc-plugin
192 |
193 |
194 | attach-javadoc
195 |
196 | jar
197 |
198 |
199 |
200 |
201 |
202 |
203 |
204 |
--------------------------------------------------------------------------------
/jzmq-jni/src/main/c++/Context.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (c) 2007-2013 Contributors as noted in the AUTHORS file
3 |
4 | This file is part of 0MQ.
5 |
6 | 0MQ is free software; you can redistribute it and/or modify it under
7 | the terms of the GNU Lesser General Public License as published by
8 | the Free Software Foundation; either version 3 of the License, or
9 | (at your option) any later version.
10 |
11 | 0MQ is distributed in the hope that it will be useful,
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | GNU Lesser General Public License for more details.
15 |
16 | You should have received a copy of the GNU Lesser General Public License
17 | along with this program. If not, see .
18 | */
19 |
20 | #include
21 |
22 | #include
23 |
24 | #include "jzmq.hpp"
25 | #include "util.hpp"
26 | #include "org_zeromq_ZMQ_Context.h"
27 |
28 | static jfieldID contextptrFID;
29 |
30 | static void ensure_context (JNIEnv *env, jobject obj);
31 | static void *get_context (JNIEnv *env, jobject obj);
32 | static void put_context (JNIEnv *env, jobject obj, void *s);
33 |
34 |
35 | /**
36 | * Called to construct a Java Context object.
37 | */
38 | JNIEXPORT void JNICALL
39 | Java_org_zeromq_ZMQ_00024Context_construct (JNIEnv *env, jobject obj, jint io_threads)
40 | {
41 | void *c = get_context (env, obj);
42 | if (c)
43 | return;
44 |
45 | c = zmq_init (io_threads);
46 | int err = zmq_errno();
47 | put_context (env, obj, c);
48 |
49 | if (c == NULL) {
50 | raise_exception (env, err);
51 | return;
52 | }
53 | }
54 |
55 | /**
56 | * Called to destroy a Java Context object.
57 | */
58 | JNIEXPORT void JNICALL
59 | Java_org_zeromq_ZMQ_00024Context_destroy (JNIEnv *env, jobject obj) {
60 | void *c = get_context (env, obj);
61 | if (! c)
62 | return;
63 |
64 | int rc = zmq_term (c);
65 | int err = zmq_errno();
66 | c = NULL;
67 | put_context (env, obj, c);
68 |
69 | if (rc != 0) {
70 | raise_exception (env, err);
71 | return;
72 | }
73 | }
74 |
75 | JNIEXPORT jboolean JNICALL
76 | Java_org_zeromq_ZMQ_00024Context_setMaxSockets (JNIEnv * env, jobject obj, jint maxSockets)
77 | {
78 | #if ZMQ_VERSION >= ZMQ_MAKE_VERSION(3,0,0)
79 | void *c = get_context (env, obj);
80 | if (! c)
81 | return JNI_FALSE;
82 | int result = zmq_ctx_set (c, ZMQ_MAX_SOCKETS, maxSockets);
83 | return result == 0;
84 | #else
85 | return JNI_FALSE;
86 | #endif
87 | }
88 |
89 | JNIEXPORT jint JNICALL
90 | Java_org_zeromq_ZMQ_00024Context_getMaxSockets (JNIEnv *env, jobject obj)
91 | {
92 | #if ZMQ_VERSION >= ZMQ_MAKE_VERSION(3,0,0)
93 | void *c = get_context (env, obj);
94 | if (! c)
95 | return -1;
96 |
97 | return zmq_ctx_get (c, ZMQ_MAX_SOCKETS);
98 | #else
99 | return -1;
100 | #endif
101 | }
102 |
103 | /**
104 | * Make sure we have a valid pointer to Java's Context::contextHandle.
105 | */
106 | static void ensure_context (JNIEnv *env, jobject obj)
107 | {
108 | if (contextptrFID == NULL) {
109 | jclass cls = env->GetObjectClass (obj);
110 | assert (cls);
111 | contextptrFID = env->GetFieldID (cls, "contextHandle", "J");
112 | assert (contextptrFID);
113 | env->DeleteLocalRef (cls);
114 | }
115 | }
116 |
117 | /**
118 | * Get the value of Java's Context::contextHandle.
119 | */
120 | static void *get_context (JNIEnv *env, jobject obj)
121 | {
122 | ensure_context (env, obj);
123 | void *s = (void*) env->GetLongField (obj, contextptrFID);
124 |
125 | return s;
126 | }
127 |
128 | /**
129 | * Set the value of Java's Context::contextHandle.
130 | */
131 | static void put_context (JNIEnv *env, jobject obj, void *s)
132 | {
133 | ensure_context (env, obj);
134 | env->SetLongField (obj, contextptrFID, (jlong) s);
135 | }
136 |
--------------------------------------------------------------------------------
/jzmq-jni/src/main/c++/Curve.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (c) 2007-2013 Contributors as noted in the AUTHORS file
3 |
4 | This file is part of 0MQ.
5 |
6 | 0MQ is free software; you can redistribute it and/or modify it under
7 | the terms of the GNU Lesser General Public License as published by
8 | the Free Software Foundation; either version 3 of the License, or
9 | (at your option) any later version.
10 |
11 | 0MQ is distributed in the hope that it will be useful,
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | GNU Lesser General Public License for more details.
15 |
16 | You should have received a copy of the GNU Lesser General Public License
17 | along with this program. If not, see .
18 | */
19 |
20 | #include
21 | #include
22 | #include
23 | #include "jzmq.hpp"
24 | #include "util.hpp"
25 | #include "org_zeromq_ZMQ_Curve.h"
26 |
27 |
28 | JNIEXPORT jobject JNICALL
29 | Java_org_zeromq_ZMQ_00024Curve_generateKeyPair(JNIEnv *env, jclass cls)
30 | {
31 | #if ZMQ_VERSION >= ZMQ_MAKE_VERSION(4,0,0)
32 | char public_key [41];
33 | char secret_key [41];
34 |
35 | int rc = zmq_curve_keypair (public_key, secret_key);
36 | int err = zmq_errno ();
37 |
38 | if (0 != rc) {
39 | raise_exception (env, err);
40 | return NULL;
41 | }
42 |
43 | jstring pk = env->NewStringUTF (public_key);
44 | assert (pk);
45 | jstring sk = env->NewStringUTF (secret_key);
46 | assert (sk);
47 |
48 | jclass clz = env->FindClass ("org/zeromq/ZMQ$Curve$KeyPair");
49 | assert (clz);
50 | jmethodID midInit = env->GetMethodID (clz, "", "(Ljava/lang/String;Ljava/lang/String;)V");
51 | assert (midInit);
52 | jobject result = env->NewObject (clz, midInit, pk, sk);
53 | assert (result);
54 |
55 | return result;
56 | #else
57 | raise_exception (env, ENOTSUP);
58 | return NULL;
59 | #endif
60 | }
61 |
62 | JNIEXPORT jbyteArray JNICALL
63 | Java_org_zeromq_ZMQ_00024Curve_z85Decode(JNIEnv *env, jclass cls, jstring key)
64 | {
65 | #if ZMQ_VERSION >= ZMQ_MAKE_VERSION(4,0,0)
66 | const char *in_key = env->GetStringUTFChars (key, NULL);
67 | assert (in_key);
68 |
69 | uint8_t out_key [32];
70 |
71 | if (NULL == zmq_z85_decode (out_key, (char*)in_key)) {
72 | env->ReleaseStringUTFChars (key, in_key);
73 | return NULL;
74 | }
75 |
76 | env->ReleaseStringUTFChars (key, in_key);
77 | jbyteArray result = env->NewByteArray (32);
78 | env->SetByteArrayRegion (result, 0 , 32, reinterpret_cast(out_key));
79 |
80 | return result;
81 | #else
82 | raise_exception (env, ENOTSUP);
83 | return NULL;
84 | #endif
85 | }
86 |
87 | JNIEXPORT jstring JNICALL
88 | Java_org_zeromq_ZMQ_00024Curve_z85Encode(JNIEnv *env, jclass cls, jbyteArray key)
89 | {
90 | #if ZMQ_VERSION >= ZMQ_MAKE_VERSION(4,0,0)
91 | jbyte *in_key = env->GetByteArrayElements (key, NULL);
92 | assert (in_key);
93 |
94 | char string_key [41];
95 |
96 | if (NULL == zmq_z85_encode (string_key, reinterpret_cast(in_key), 32)) {
97 | env->ReleaseByteArrayElements (key, in_key, 0);
98 | return NULL;
99 | }
100 |
101 | env->ReleaseByteArrayElements (key, in_key, 0);
102 | jstring result = env->NewStringUTF (string_key);
103 | assert (result);
104 |
105 | return result;
106 | #else
107 | raise_exception (env, ENOTSUP);
108 | return NULL;
109 | #endif
110 | }
111 |
--------------------------------------------------------------------------------
/jzmq-jni/src/main/c++/Event.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 | #include
5 |
6 | #include "jzmq.hpp"
7 | #include "util.hpp"
8 | #include "org_zeromq_ZMQ_Event.h"
9 |
10 | static jmethodID constructor;
11 |
12 | JNIEXPORT void JNICALL
13 | Java_org_zeromq_ZMQ_00024Event_nativeInit (JNIEnv *env, jclass cls)
14 | {
15 | constructor = env->GetMethodID(cls, "", "(IILjava/lang/String;)V");
16 | assert(constructor);
17 | }
18 |
19 | static zmq_msg_t*
20 | read_msg(JNIEnv *env, void *socket, zmq_msg_t *msg, int flags)
21 | {
22 | int rc = zmq_msg_init (msg);
23 | if (rc != 0) {
24 | raise_exception (env, zmq_errno());
25 | return NULL;
26 | }
27 |
28 | #if ZMQ_VERSION >= ZMQ_MAKE_VERSION(3,0,0)
29 | rc = zmq_recvmsg (socket, msg, flags);
30 | #else
31 | rc = zmq_recv (socket, msg, flags);
32 | #endif
33 | int err = zmq_errno();
34 | if (rc < 0 && err == EAGAIN) {
35 | rc = zmq_msg_close (msg);
36 | err = zmq_errno();
37 | if (rc != 0) {
38 | raise_exception (env, err);
39 | return NULL;
40 | }
41 | return NULL;
42 | }
43 | if (rc < 0) {
44 | raise_exception (env, err);
45 | rc = zmq_msg_close (msg);
46 | err = zmq_errno();
47 | if (rc != 0) {
48 | raise_exception (env, err);
49 | return NULL;
50 | }
51 | return NULL;
52 | }
53 | return msg;
54 | }
55 |
56 | JNIEXPORT jobject JNICALL
57 | Java_org_zeromq_ZMQ_00024Event_recv (JNIEnv *env, jclass cls, jlong socket, jint flags)
58 | {
59 | #if ZMQ_VERSION >= ZMQ_MAKE_VERSION(3,2,2)
60 | zmq_msg_t event_msg;
61 |
62 | // read event message
63 | if (!read_msg(env, (void *) socket, &event_msg, flags))
64 | return NULL;
65 |
66 | #if ZMQ_VERSION >= ZMQ_MAKE_VERSION(4,0,0)
67 | assert (zmq_msg_more(&event_msg) != 0);
68 |
69 | uint16_t event;
70 | int32_t value;
71 | // copy event data
72 | char *data = (char *) zmq_msg_data(&event_msg);
73 | memcpy(&event, data, sizeof(event));
74 | memcpy(&value, data + sizeof(event), sizeof(value));
75 |
76 | if (zmq_msg_close(&event_msg) < 0) {
77 | raise_exception(env, zmq_errno());
78 | return NULL;
79 | }
80 |
81 | char addr[1025];
82 | char *paddr;
83 | zmq_msg_t addr_msg;
84 |
85 | // read address message
86 | if (!read_msg(env, (void *) socket, &addr_msg, flags))
87 | return NULL;
88 | assert (zmq_msg_more(&addr_msg) == 0);
89 |
90 | // copy the address string
91 | const size_t len = zmq_msg_size(&addr_msg);
92 |
93 | paddr = (char *)(len >= sizeof(addr) ? malloc(len + 1) : &addr);
94 | memcpy(paddr, zmq_msg_data(&addr_msg), len);
95 | *(paddr + len) = '\0';
96 |
97 | if (zmq_msg_close(&addr_msg) < 0) {
98 | raise_exception(env, zmq_errno());
99 | return NULL;
100 | }
101 |
102 | jstring address = env->NewStringUTF(paddr);
103 | if (len >= sizeof(addr))
104 | free(paddr);
105 | assert(address);
106 |
107 | return env->NewObject(cls, constructor, event, value, address);
108 | #else
109 | assert (zmq_msg_more(&event_msg) == 0);
110 |
111 | zmq_event_t event;
112 | // copy event data to event struct
113 | memcpy (&event, zmq_msg_data (&event_msg), sizeof(event));
114 |
115 | if (zmq_msg_close(&event_msg) < 0) {
116 | raise_exception(env, zmq_errno());
117 | return NULL;
118 | }
119 |
120 | // the addr part is a pointer to a c string that libzmq might have already called free on
121 | // it is not to be trusted so better not use it at all
122 | switch (event.event) {
123 | case ZMQ_EVENT_CONNECTED:
124 | return env->NewObject(cls, constructor, event.event, event.data.connected.fd, NULL);
125 | case ZMQ_EVENT_CONNECT_DELAYED:
126 | return env->NewObject(cls, constructor, event.event, event.data.connect_delayed.err, NULL);
127 | case ZMQ_EVENT_CONNECT_RETRIED:
128 | return env->NewObject(cls, constructor, event.event, event.data.connect_retried.interval, NULL);
129 | case ZMQ_EVENT_LISTENING:
130 | return env->NewObject(cls, constructor, event.event, event.data.listening.fd, NULL);
131 | case ZMQ_EVENT_BIND_FAILED:
132 | return env->NewObject(cls, constructor, event.event, event.data.bind_failed.err, NULL);
133 | case ZMQ_EVENT_ACCEPTED:
134 | return env->NewObject(cls, constructor, event.event, event.data.accepted.fd, NULL);
135 | case ZMQ_EVENT_ACCEPT_FAILED:
136 | return env->NewObject(cls, constructor, event.event, event.data.accept_failed.err, NULL);
137 | case ZMQ_EVENT_CLOSED:
138 | return env->NewObject(cls, constructor, event.event, event.data.closed.fd, NULL);
139 | case ZMQ_EVENT_CLOSE_FAILED:
140 | return env->NewObject(cls, constructor, event.event, event.data.close_failed.err, NULL);
141 | case ZMQ_EVENT_DISCONNECTED:
142 | return env->NewObject(cls, constructor, event.event, event.data.disconnected.fd, NULL);
143 | default:
144 | return NULL;
145 | }
146 | #endif // ZMQ_VERSION >= ZMQ_MAKE_VERSION(4,0,0)
147 | #else
148 | return NULL;
149 | #endif // ZMQ_VERSION >= ZMQ_MAKE_VERSION(3,2,2)
150 | }
151 |
--------------------------------------------------------------------------------
/jzmq-jni/src/main/c++/Makefile.am:
--------------------------------------------------------------------------------
1 | jarfile = zmq.jar
2 | jardir = $(datadir)/java
3 |
4 | javac_stamp = javac_stamp
5 |
6 | JZMQ_JAVA_FILES = \
7 | ../java/org/zeromq/EmbeddedLibraryTools.java \
8 | ../java/org/zeromq/ZMQ.java \
9 | ../java/org/zeromq/ZMQException.java
10 |
11 | JZMQ_CPP_FILES = \
12 | ZMQ.cpp \
13 | Context.cpp \
14 | Socket.cpp \
15 | Poller.cpp \
16 | Event.cpp \
17 | util.cpp \
18 | Curve.cpp
19 |
20 | JZMQ_H_FILES = \
21 | org_zeromq_ZMQ.h \
22 | org_zeromq_ZMQ_Context.h \
23 | org_zeromq_ZMQ_Error.h \
24 | org_zeromq_ZMQ_Event.h \
25 | org_zeromq_ZMQ_PollItem.h \
26 | org_zeromq_ZMQ_Poller.h \
27 | org_zeromq_ZMQ_Socket.h \
28 | org_zeromq_ZMQ_Curve.h \
29 | org_zeromq_ZMQ_Curve_KeyPair.h
30 |
31 | JZMQ_HPP_FILES = \
32 | util.hpp
33 |
34 | JZMQ_CLASS_FILES = org/zeromq/*.class
35 |
36 | $(javac_stamp): $(JZMQ_JAVA_FILES)
37 | $(JAVAC) $(JAVACFLAGS) -d . -h . $(JZMQ_JAVA_FILES)
38 | @touch $@
39 |
40 | $(jarfile): $(javac_stamp)
41 | $(JAR) cf $(JARFLAGS) $@ $(JZMQ_CLASS_FILES)
42 |
43 | jar_DATA = $(jarfile)
44 |
45 | dist_noinst_JAVA = $(JZMQ_JAVA_FILES)
46 |
47 | lib_LTLIBRARIES = libjzmq.la
48 | libjzmq_la_SOURCES = $(JZMQ_CPP_FILES)
49 |
50 | nodist_libjzmq_la_SOURCES = \
51 | $(JZMQ_H_FILES) \
52 | $(JZMQ_HPP_FILES)
53 |
54 | libjzmq_la_CXXFLAGS = -Wall
55 |
56 | if DISABLE_VERSION
57 | libjzmq_la_LDFLAGS = -avoid-version
58 | else
59 | libjzmq_la_LDFLAGS = -version-info @JLTVER@
60 | endif
61 |
62 | BUILT_SOURCES = \
63 | $(JZMQ_H_FILES)
64 |
65 | CLEANFILES = \
66 | $(JZMQ_H_FILES) \
67 | $(jarfile) \
68 | $(javac_stamp)
69 |
70 | clean-local:
71 | rm -rf org
72 |
73 | $(JZMQ_H_FILES): $(javac_stamp)
74 |
75 | $(srcdir)/ZMQ.cpp: \
76 | $(JZMQ_H_FILES) \
77 | $(JZMQ_HPP_FILES)
78 |
79 | $(srcdir)/Context.cpp: \
80 | org_zeromq_ZMQ_Context.h \
81 | $(JZMQ_HPP_FILES)
82 |
83 | $(srcdir)/Socket.cpp: \
84 | org_zeromq_ZMQ_Socket.h \
85 | $(JZMQ_HPP_FILES)
86 |
87 | $(srcdir)/Poller.cpp: \
88 | org_zeromq_ZMQ_Poller.h \
89 | $(JZMQ_HPP_FILES)
90 |
91 | $(srcdir)/util.cpp: \
92 | $(JZMQ_HPP_FILES)
93 |
94 | dist-hook:
95 | -rm $(distdir)/*.h
96 |
--------------------------------------------------------------------------------
/jzmq-jni/src/main/c++/Poller.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (c) 2007-2013 Contributors as noted in the AUTHORS file
3 |
4 | This file is part of 0MQ.
5 |
6 | 0MQ is free software; you can redistribute it and/or modify it under
7 | the terms of the GNU Lesser General Public License as published by
8 | the Free Software Foundation; either version 3 of the License, or
9 | (at your option) any later version.
10 |
11 | 0MQ is distributed in the hope that it will be useful,
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | GNU Lesser General Public License for more details.
15 |
16 | You should have received a copy of the GNU Lesser General Public License
17 | along with this program. If not, see .
18 | */
19 |
20 | #include
21 |
22 | #include
23 |
24 | #include "jzmq.hpp"
25 | #include "util.hpp"
26 | #include "org_zeromq_ZMQ_Poller.h"
27 |
28 | static jfieldID field_channel;
29 | static jfieldID field_socket;
30 | static jfieldID field_events;
31 | static jfieldID field_revents;
32 |
33 | static void *fetch_socket (JNIEnv *env, jobject socket);
34 | static int fetch_socket_fd (JNIEnv *env, jobject socket);
35 |
36 | JNIEXPORT jint JNICALL
37 | Java_org_zeromq_ZMQ_00024Poller_run_1poll (JNIEnv *env, jclass cls, jobjectArray socket_0mq, jint count, jlong timeout)
38 | {
39 | int ls = (int) count;
40 | if (ls <= 0) {
41 | return 0;
42 | }
43 |
44 | int ls_0mq = 0;
45 |
46 | if (socket_0mq)
47 | ls_0mq = env->GetArrayLength (socket_0mq);
48 |
49 | if (ls > ls_0mq) {
50 | return 0;
51 | }
52 |
53 | zmq_pollitem_t *pitem = new zmq_pollitem_t [ls];
54 | short pc = 0;
55 | int rc = 0;
56 |
57 | // Add 0MQ sockets. Array containing them can be "sparse": there
58 | // may be null elements. The count argument has the real number
59 | // of valid sockets in the array.
60 | for (int i = 0; i < ls_0mq; ++i) {
61 | jobject s_0mq = env->GetObjectArrayElement (socket_0mq, i);
62 | if (!s_0mq)
63 | continue;
64 | void *s = fetch_socket (env, s_0mq);
65 | int fd = (s == NULL) ? fetch_socket_fd (env, s_0mq) : 0;
66 |
67 | if (s == NULL && fd < 0) {
68 | raise_exception (env, EINVAL);
69 | continue;
70 | }
71 |
72 | env->SetIntField (s_0mq, field_revents, 0);
73 |
74 | pitem [pc].socket = s;
75 | pitem [pc].fd = fd;
76 | pitem [pc].events = env->GetIntField (s_0mq, field_events);
77 | pitem [pc].revents = 0;
78 | ++pc;
79 |
80 | env->DeleteLocalRef (s_0mq);
81 | }
82 |
83 | // Count of non-null sockets must be equal to passed-in arg.
84 | if (pc == ls) {
85 | pc = 0;
86 | long tout = (long) timeout;
87 | rc = zmq_poll (pitem, ls, tout);
88 | }
89 |
90 | // Set 0MQ results.
91 | if (rc > 0 && ls > 0) {
92 | for (int i = 0; i < ls_0mq; ++i) {
93 | jobject s_0mq = env->GetObjectArrayElement (socket_0mq, i);
94 | if (!s_0mq)
95 | continue;
96 | env->SetIntField (s_0mq, field_revents, pitem [pc].revents);
97 | ++pc;
98 | env->DeleteLocalRef (s_0mq);
99 | }
100 | }
101 | else if (rc < 0)
102 | {
103 | raise_exception (env, zmq_errno());
104 | }
105 |
106 | delete [] pitem;
107 | return rc;
108 | }
109 |
110 | /**
111 | * Get the value of socketHandle for the specified Java Socket.
112 | */
113 | static void* fetch_socket (JNIEnv *env, jobject item){
114 |
115 | static jmethodID get_socket_handle_mid = NULL;
116 |
117 | jclass cls;
118 | if (field_socket == NULL) {
119 | cls = env->GetObjectClass (item);
120 | assert (cls);
121 | field_channel = env->GetFieldID (cls, "channel", "Ljava/nio/channels/SelectableChannel;");
122 | field_socket = env->GetFieldID (cls, "socket", "Lorg/zeromq/ZMQ$Socket;");
123 | field_events = env->GetFieldID (cls, "events", "I");
124 | field_revents = env->GetFieldID (cls, "revents", "I");
125 | env->DeleteLocalRef (cls);
126 | }
127 | jobject socket = env->GetObjectField (item, field_socket);
128 | if (socket == NULL)
129 | return NULL;
130 |
131 | if (get_socket_handle_mid == NULL) {
132 | jclass cls = env->GetObjectClass (socket);
133 | assert (cls);
134 | get_socket_handle_mid = env->GetMethodID (cls,
135 | "getSocketHandle", "()J");
136 | env->DeleteLocalRef (cls);
137 | assert (get_socket_handle_mid);
138 | }
139 |
140 | void *s = (void*) env->CallLongMethod (socket, get_socket_handle_mid);
141 | if (env->ExceptionCheck ()) {
142 | s = NULL;
143 | }
144 |
145 | return s;
146 | }
147 | /**
148 | * Get the file descriptor id of java.net.Socket.
149 | * returns 0 if socket is not a SelectableChannel
150 | * returns the file descriptor id or -1 on an error
151 | */
152 | static int fetch_socket_fd (JNIEnv *env, jobject item){
153 |
154 | jclass cls;
155 | jfieldID fid;
156 | jobject channel = env->GetObjectField (item, field_channel);
157 | if (channel == NULL)
158 | return -1;
159 |
160 | cls = env->GetObjectClass (channel);
161 | assert (cls);
162 |
163 | fid = env->GetFieldID (cls, "fdVal", "I");
164 | env->DeleteLocalRef (cls);
165 | if (fid == NULL)
166 | return -1;
167 |
168 | /* return the descriptor */
169 | int fd = env->GetIntField (channel, fid);
170 |
171 | return fd;
172 | }
173 |
--------------------------------------------------------------------------------
/jzmq-jni/src/main/c++/ZMQ.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (c) 2007-2013 Contributors as noted in the AUTHORS file
3 |
4 | This file is part of 0MQ.
5 |
6 | 0MQ is free software; you can redistribute it and/or modify it under
7 | the terms of the GNU Lesser General Public License as published by
8 | the Free Software Foundation; either version 3 of the License, or
9 | (at your option) any later version.
10 |
11 | 0MQ is distributed in the hope that it will be useful,
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | GNU Lesser General Public License for more details.
15 |
16 | You should have received a copy of the GNU Lesser General Public License
17 | along with this program. If not, see .
18 | */
19 |
20 | #include
21 |
22 | #include "jzmq.hpp"
23 | #include "org_zeromq_ZMQ.h"
24 |
25 | static void *get_socket (JNIEnv *env, jobject obj)
26 | {
27 | jclass cls = env->GetObjectClass(obj);
28 | jfieldID socketHandleFID = env->GetFieldID (cls, "socketHandle", "J");
29 | env->DeleteLocalRef(cls);
30 | return (void*) env->GetLongField (obj, socketHandleFID);
31 | }
32 |
33 | JNIEXPORT jint JNICALL
34 | Java_org_zeromq_ZMQ_version_1full (JNIEnv *env, jclass cls)
35 | {
36 | return ZMQ_VERSION;
37 | }
38 |
39 | JNIEXPORT jint JNICALL
40 | Java_org_zeromq_ZMQ_version_1major (JNIEnv *env, jclass cls)
41 | {
42 | return ZMQ_VERSION_MAJOR;
43 | }
44 |
45 | JNIEXPORT jint JNICALL
46 | Java_org_zeromq_ZMQ_version_1minor (JNIEnv *env, jclass cls)
47 | {
48 | return ZMQ_VERSION_MINOR;
49 | }
50 |
51 | JNIEXPORT jint JNICALL
52 | Java_org_zeromq_ZMQ_version_1patch (JNIEnv *env, jclass cls)
53 | {
54 | return ZMQ_VERSION_PATCH;
55 | }
56 |
57 | JNIEXPORT jint JNICALL
58 | Java_org_zeromq_ZMQ_make_1version (JNIEnv *env, jclass cls, jint major, jint minor, jint patch)
59 | {
60 | return ZMQ_MAKE_VERSION(major, minor, patch);
61 | }
62 |
63 | JNIEXPORT jlong JNICALL
64 | Java_org_zeromq_ZMQ_ENOTSUP (JNIEnv *env, jclass cls)
65 | {
66 | return ENOTSUP;
67 | }
68 |
69 | JNIEXPORT jlong JNICALL
70 | Java_org_zeromq_ZMQ_EPROTONOSUPPORT (JNIEnv *env, jclass cls)
71 | {
72 | return EPROTONOSUPPORT;
73 | }
74 |
75 | JNIEXPORT jlong JNICALL
76 | Java_org_zeromq_ZMQ_ENOBUFS (JNIEnv *env, jclass cls)
77 | {
78 | return ENOBUFS;
79 | }
80 |
81 | JNIEXPORT jlong JNICALL
82 | Java_org_zeromq_ZMQ_ENETDOWN (JNIEnv *env, jclass cls)
83 | {
84 | return ENETDOWN;
85 | }
86 |
87 | JNIEXPORT jlong JNICALL
88 | Java_org_zeromq_ZMQ_EADDRINUSE (JNIEnv *env, jclass cls)
89 | {
90 | return EADDRINUSE;
91 | }
92 |
93 | JNIEXPORT jlong JNICALL
94 | Java_org_zeromq_ZMQ_EADDRNOTAVAIL (JNIEnv *env, jclass cls)
95 | {
96 | return EADDRNOTAVAIL;
97 | }
98 |
99 | JNIEXPORT jlong JNICALL
100 | Java_org_zeromq_ZMQ_ECONNREFUSED (JNIEnv *env, jclass cls)
101 | {
102 | return ECONNREFUSED;
103 | }
104 |
105 | JNIEXPORT jlong JNICALL
106 | Java_org_zeromq_ZMQ_EINPROGRESS (JNIEnv *env, jclass cls)
107 | {
108 | return EINPROGRESS;
109 | }
110 |
111 | JNIEXPORT jlong JNICALL
112 | Java_org_zeromq_ZMQ_EHOSTUNREACH (JNIEnv *env, jclass cls)
113 | {
114 | return EHOSTUNREACH;
115 | }
116 |
117 | JNIEXPORT jlong JNICALL
118 | Java_org_zeromq_ZMQ_EMTHREAD (JNIEnv *env, jclass cls)
119 | {
120 | return EMTHREAD;
121 | }
122 |
123 | JNIEXPORT jlong JNICALL
124 | Java_org_zeromq_ZMQ_EFSM (JNIEnv *env, jclass cls)
125 | {
126 | return EFSM;
127 | }
128 |
129 | JNIEXPORT jlong JNICALL
130 | Java_org_zeromq_ZMQ_ENOCOMPATPROTO (JNIEnv *env, jclass cls)
131 | {
132 | return ENOCOMPATPROTO;
133 | }
134 |
135 | JNIEXPORT jlong JNICALL
136 | Java_org_zeromq_ZMQ_ETERM (JNIEnv *env, jclass cls)
137 | {
138 | return ETERM;
139 | }
140 |
141 | JNIEXPORT jlong JNICALL
142 | Java_org_zeromq_ZMQ_ENOTSOCK (JNIEnv *env, jclass cls)
143 | {
144 | return ENOTSOCK;
145 | }
146 |
147 | JNIEXPORT jlong JNICALL
148 | Java_org_zeromq_ZMQ_EAGAIN (JNIEnv *env, jclass cls)
149 | {
150 | return EAGAIN;
151 | }
152 |
153 | JNIEXPORT void JNICALL
154 | Java_org_zeromq_ZMQ_run_1proxy (JNIEnv *env, jclass cls, jobject frontend_, jobject backend_, jobject capture_)
155 | {
156 | #if ZMQ_VERSION >= ZMQ_MAKE_VERSION(3,2,2)
157 | void *frontend = get_socket (env, frontend_);
158 | void *backend = get_socket (env, backend_);
159 | void *capture = NULL;
160 | if (capture_ != NULL)
161 | capture = get_socket (env, capture_);
162 | zmq_proxy (frontend, backend, capture);
163 | #endif
164 | }
165 |
--------------------------------------------------------------------------------
/jzmq-jni/src/main/c++/jzmq.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (c) 2007-2013 Contributors as noted in the AUTHORS file
3 |
4 | This file is part of 0MQ.
5 |
6 | 0MQ is free software; you can redistribute it and/or modify it under
7 | the terms of the GNU Lesser General Public License as published by
8 | the Free Software Foundation; either version 3 of the License, or
9 | (at your option) any later version.
10 |
11 | 0MQ is distributed in the hope that it will be useful,
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | GNU Lesser General Public License for more details.
15 |
16 | You should have received a copy of the GNU Lesser General Public License
17 | along with this program. If not, see .
18 | */
19 |
20 | #ifndef __JZMQ_HPP_INCLUDED__
21 | #define __JZMQ_HPP_INCLUDED__
22 |
23 | #include "config.hpp"
24 |
25 | #if defined HAVE_INTTYPES_H
26 |
27 | #include
28 |
29 | #elif defined HAVE_STDINT_H
30 |
31 | #include
32 |
33 | #elif defined _MSC_VER
34 |
35 | #ifndef int8_t
36 | typedef signed __int8 int8_t;
37 | #endif
38 | #ifndef int16_t
39 | typedef __int16 int16_t;
40 | #endif
41 | #ifndef int32_t
42 | typedef __int32 int32_t;
43 | #endif
44 | #ifndef int64_t
45 | typedef __int64 int64_t;
46 | #endif
47 | #ifndef uint8_t
48 | typedef unsigned __int8 uint8_t;
49 | #endif
50 | #ifndef uint16_t
51 | typedef unsigned __int16 uint16_t;
52 | #endif
53 | #ifndef uint32_t
54 | typedef unsigned __int32 uint32_t;
55 | #endif
56 | #ifndef uint64_t
57 | typedef unsigned __int64 uint64_t;
58 | #endif
59 |
60 | #else
61 |
62 | #error "Don't know how to define stdint types on this platform"
63 |
64 | #endif
65 |
66 | #endif
67 |
--------------------------------------------------------------------------------
/jzmq-jni/src/main/c++/util.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (c) 2007-2013 Contributors as noted in the AUTHORS file
3 |
4 | This file is part of 0MQ.
5 |
6 | 0MQ is free software; you can redistribute it and/or modify it under
7 | the terms of the GNU Lesser General Public License as published by
8 | the Free Software Foundation; either version 3 of the License, or
9 | (at your option) any later version.
10 |
11 | 0MQ is distributed in the hope that it will be useful,
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | GNU Lesser General Public License for more details.
15 |
16 | You should have received a copy of the GNU Lesser General Public License
17 | along with this program. If not, see .
18 | */
19 |
20 | #include
21 |
22 | #include
23 |
24 | #include "util.hpp"
25 |
26 | /**
27 | * Raise an exception that includes 0MQ's error message.
28 | */
29 | void raise_exception (JNIEnv *env, int err)
30 | {
31 | // Get exception class.
32 | jclass exception_class = env->FindClass ("org/zeromq/ZMQException");
33 | assert (exception_class);
34 |
35 | // Get exception class constructor
36 | jmethodID constructor_method = env->GetMethodID(exception_class,
37 | "", "(Ljava/lang/String;I)V");
38 | assert (constructor_method);
39 |
40 | // Get text description of the exception.
41 | const char *err_desc = zmq_strerror (err);
42 |
43 | jstring err_str = env->NewStringUTF(err_desc);
44 |
45 | // Create exception class instance
46 | jthrowable exception = static_cast(env->NewObject(
47 | exception_class, constructor_method, err_str, err));
48 |
49 | // Raise the exception.
50 | int rc = env->Throw (exception);
51 | env->DeleteLocalRef (exception_class);
52 | env->DeleteLocalRef (err_str);
53 |
54 | assert (rc == 0);
55 | }
56 |
--------------------------------------------------------------------------------
/jzmq-jni/src/main/c++/util.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (c) 2007-2013 Contributors as noted in the AUTHORS file
3 |
4 | This file is part of 0MQ.
5 |
6 | 0MQ is free software; you can redistribute it and/or modify it under
7 | the terms of the GNU Lesser General Public License as published by
8 | the Free Software Foundation; either version 3 of the License, or
9 | (at your option) any later version.
10 |
11 | 0MQ is distributed in the hope that it will be useful,
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | GNU Lesser General Public License for more details.
15 |
16 | You should have received a copy of the GNU Lesser General Public License
17 | along with this program. If not, see .
18 | */
19 |
20 | #ifndef __UTIL_HPP_INCLUDED__
21 | #define __UTIL_HPP_INCLUDED__
22 |
23 | #include
24 |
25 | /**
26 | * Raise an exception that includes 0MQ's error message.
27 | */
28 | void raise_exception (JNIEnv *env, int err);
29 |
30 | #endif /* #ifndef __UTIL_HPP_INCLUDED__ */
31 |
--------------------------------------------------------------------------------
/jzmq-jni/src/main/java/org/zeromq/App.java:
--------------------------------------------------------------------------------
1 | package org.zeromq;
2 |
3 | import java.util.Collection;
4 |
5 | /**
6 | * Simple App to display version information about jzmq.
7 | *
8 | */
9 | public class App {
10 |
11 | public static void main(final String[] args) throws Exception {
12 |
13 | final Package p = App.class.getPackage();
14 | final String appname = p.getSpecificationTitle();
15 | final String versionMaven = p.getSpecificationVersion();
16 | String[] version = new String[] { "", "" };
17 | if (p.getImplementationVersion() != null) {
18 | version = p.getImplementationVersion().split(" ", 2);
19 | }
20 |
21 | String zmqVersion = null;
22 |
23 | try {
24 |
25 | final int major = ZMQ.version_major();
26 | final int minor = ZMQ.version_minor();
27 | final int patch = ZMQ.version_patch();
28 | zmqVersion = major + "." + minor + "." + patch;
29 |
30 | } catch (Throwable x) {
31 | zmqVersion = "ERROR! " + x.getMessage();
32 | }
33 |
34 | final String fmt = "%-7.7s %-15.15s %s%n";
35 |
36 | System.out.printf(fmt, "ZeroMQ", "version:", zmqVersion);
37 | System.out.printf(fmt, appname, "version:", versionMaven);
38 | System.out.printf(fmt, appname, "build time:", version[1]);
39 | System.out.printf(fmt, appname, "build commit:", version[0]);
40 |
41 | System.out.println();
42 | System.out.println("JNI lib location: "
43 | + (EmbeddedLibraryTools.LOADED_EMBEDDED_LIBRARY ? "embedded" : "java.library.path"));
44 | System.out.println("current platform: " + EmbeddedLibraryTools.getCurrentPlatformIdentifier());
45 | final Collection files = EmbeddedLibraryTools.getEmbeddedLibraryList();
46 | for (final String file : files) {
47 | System.out.println("embedded library: " + file);
48 | }
49 |
50 | }
51 |
52 | }
53 |
--------------------------------------------------------------------------------
/jzmq-jni/src/main/java/org/zeromq/EmbeddedLibraryTools.java:
--------------------------------------------------------------------------------
1 | package org.zeromq;
2 |
3 | import java.io.*;
4 | import java.net.URL;
5 | import java.util.ArrayList;
6 | import java.util.Collection;
7 | import java.util.Enumeration;
8 | import java.util.List;
9 | import java.util.jar.JarEntry;
10 | import java.util.jar.JarFile;
11 |
12 | public class EmbeddedLibraryTools {
13 |
14 | public static final boolean LOADED_EMBEDDED_LIBRARY;
15 |
16 | static {
17 | LOADED_EMBEDDED_LIBRARY = loadEmbeddedLibrary();
18 | }
19 |
20 | private EmbeddedLibraryTools() {
21 | }
22 |
23 | public static String getCurrentPlatformIdentifier() {
24 | String osName = System.getProperty("os.name");
25 | if (osName.toLowerCase().contains("windows")) {
26 | osName = "Windows";
27 | } else if (osName.toLowerCase().contains("mac os x")) {
28 | osName = "Mac OS X";
29 | } else {
30 | osName = osName.replaceAll("\\s+", "_");
31 | }
32 | return System.getProperty("os.arch") + "/" + osName;
33 | }
34 |
35 | public static Collection getEmbeddedLibraryList() {
36 |
37 | final Collection result = new ArrayList();
38 | final Collection files = catalogClasspath();
39 |
40 | for (final String file : files) {
41 | if (file.startsWith("NATIVE")) {
42 | result.add(file);
43 | }
44 | }
45 |
46 | return result;
47 |
48 | }
49 |
50 | private static void catalogArchive(final File jarfile, final Collection files) {
51 | JarFile j = null;
52 | try {
53 | j = new JarFile(jarfile);
54 | final Enumeration e = j.entries();
55 | while (e.hasMoreElements()) {
56 | final JarEntry entry = e.nextElement();
57 | if (!entry.isDirectory()) {
58 | files.add(entry.getName());
59 | }
60 | }
61 |
62 | } catch (IOException x) {
63 | System.err.println(x.toString());
64 | } finally {
65 | try {
66 | j.close();
67 | } catch (Exception e) {
68 | }
69 | }
70 |
71 | }
72 |
73 | private static Collection catalogClasspath() {
74 |
75 | final List files = new ArrayList();
76 | final String[] classpath = System.getProperty("java.class.path", "").split(File.pathSeparator);
77 |
78 | for (final String path : classpath) {
79 | final File tmp = new File(path);
80 | if (tmp.isFile() && path.toLowerCase().endsWith(".jar")) {
81 | catalogArchive(tmp, files);
82 | } else if (tmp.isDirectory()) {
83 | final int len = tmp.getPath().length() + 1;
84 | catalogFiles(len, tmp, files);
85 | }
86 | }
87 |
88 | return files;
89 |
90 | }
91 |
92 | private static void catalogFiles(final int prefixlen, final File root, final Collection files) {
93 | final File[] ff = root.listFiles();
94 | if (ff == null) {
95 | throw new IllegalStateException("invalid path listed: " + root);
96 | }
97 |
98 | for (final File f : ff) {
99 | if (f.isDirectory()) {
100 | catalogFiles(prefixlen, f, files);
101 | } else {
102 | files.add(f.getPath().substring(prefixlen));
103 | }
104 | }
105 | }
106 |
107 | private static boolean loadEmbeddedLibrary() {
108 |
109 | boolean usingEmbedded = false;
110 |
111 | // attempt to locate embedded native library within JAR at following location:
112 | // /NATIVE/${os.arch}/${os.name}/libjzmq.[so|dylib|dll]
113 | String[] allowedExtensions = new String[]{"so", "dylib", "dll"};
114 | String[] libs;
115 | final String libsFromProps = System.getProperty("jzmq.libs");
116 | if (libsFromProps == null)
117 | libs = new String[]{"libsodium", "sodium", "libzmq", "zmq", "libjzmq", "jzmq"};
118 | else
119 | libs = libsFromProps.split(",");
120 | StringBuilder url = new StringBuilder();
121 | url.append("/NATIVE/");
122 | url.append(getCurrentPlatformIdentifier()).append("/");
123 | for (String lib : libs) {
124 | URL nativeLibraryUrl = null;
125 | // loop through extensions, stopping after finding first one
126 | for (String ext : allowedExtensions) {
127 | nativeLibraryUrl = ZMQ.class.getResource(url.toString() + lib + "." + ext);
128 | if (nativeLibraryUrl != null)
129 | break;
130 | }
131 |
132 | if (nativeLibraryUrl != null) {
133 | // native library found within JAR, extract and load
134 | try {
135 |
136 | final File libfile = File.createTempFile(lib, ".lib");
137 | libfile.deleteOnExit(); // just in case
138 |
139 | final InputStream in = nativeLibraryUrl.openStream();
140 | final OutputStream out = new BufferedOutputStream(new FileOutputStream(libfile));
141 |
142 | int len = 0;
143 | byte[] buffer = new byte[8192];
144 | while ((len = in.read(buffer)) > -1)
145 | out.write(buffer, 0, len);
146 | out.close();
147 | in.close();
148 | System.load(libfile.getAbsolutePath());
149 |
150 | usingEmbedded = true;
151 |
152 | } catch (IOException x) {
153 | // mission failed, do nothing
154 | }
155 |
156 | } // nativeLibraryUrl exists
157 | }
158 | return usingEmbedded;
159 | }
160 | }
161 |
--------------------------------------------------------------------------------
/jzmq-jni/src/main/java/org/zeromq/ZMQException.java:
--------------------------------------------------------------------------------
1 | package org.zeromq;
2 |
3 | /**
4 | * ZeroMQ runtime exception.
5 | *
6 | * @author Alois Belaska <alois.belaska@gmail.com>
7 | */
8 | public class ZMQException extends RuntimeException {
9 | private static final long serialVersionUID = -978820750094924644L;
10 |
11 | private int errorCode = 0;
12 |
13 | public ZMQException(String message, int errorCode) {
14 | super(message);
15 | this.errorCode = errorCode;
16 | }
17 |
18 | public ZMQException(ZMQException cause) {
19 | super(cause.getMessage(), cause);
20 | this.errorCode = cause.errorCode;
21 | }
22 |
23 | /**
24 | * @return error code
25 | */
26 | public int getErrorCode() {
27 | return errorCode;
28 | }
29 |
30 | @Override
31 | public String toString() {
32 | return super.toString() + "(0x" + Integer.toHexString(errorCode) + ")";
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/jzmq-jni/src/main/perf/Makefile.am:
--------------------------------------------------------------------------------
1 | jarfile = zmq-perf.jar
2 | jardir = $(datadir)/perf
3 |
4 | JZMQ_PERF_JAVA_FILES = \
5 | local_lat.java \
6 | local_thr.java \
7 | remote_lat.java \
8 | remote_thr.java
9 |
10 |
11 | JZMQ_PERF_CLASS_FILES = *.class
12 |
13 | $(jarfile):
14 | $(JAVAC) $(JAVACFLAGS) -classpath $(top_builddir)/src/main/java -d . $(JZMQ_PERF_JAVA_FILES)
15 | $(JAR) cf $(JARFLAGS) $@ $(JZMQ_PERF_CLASS_FILES)
16 |
17 | jar_DATA = $(jarfile)
18 |
19 | CLEANFILES = \
20 | -rf org \
21 | $(JZMQ_PERF_CLASS_FILES) \
22 | $(jarfile)
23 |
--------------------------------------------------------------------------------
/jzmq-jni/src/main/perf/local_lat.java:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (c) 2007-2010 iMatix Corporation
3 |
4 | This file is part of 0MQ.
5 |
6 | 0MQ is free software; you can redistribute it and/or modify it under
7 | the terms of the Lesser GNU General Public License as published by
8 | the Free Software Foundation; either version 3 of the License, or
9 | (at your option) any later version.
10 |
11 | 0MQ is distributed in the hope that it will be useful,
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | Lesser GNU General Public License for more details.
15 |
16 | You should have received a copy of the Lesser GNU General Public License
17 | along with this program. If not, see .
18 | */
19 |
20 | import org.zeromq.ZMQ;
21 |
22 | class local_lat
23 | {
24 | public static void main (String [] args)
25 | {
26 | if (args.length != 3) {
27 | System.out.println ("usage: local_lat " +
28 | " ");
29 | return;
30 | }
31 |
32 | String bindTo = args [0];
33 | int messageSize = Integer.parseInt (args [1]);
34 | int roundtripCount = Integer.parseInt (args [2]);
35 |
36 | ZMQ.Context ctx = ZMQ.context (1);
37 | ZMQ.Socket s = ctx.socket (ZMQ.REP);
38 |
39 | // Add your socket options here.
40 | // For example ZMQ_RATE, ZMQ_RECOVERY_IVL and ZMQ_MCAST_LOOP for PGM.
41 |
42 | s.bind (bindTo);
43 |
44 | for (int i = 0; i != roundtripCount; i++) {
45 | byte [] data = s.recv (0);
46 | assert (data.length == messageSize);
47 | s.send (data, 0);
48 | }
49 |
50 | try {
51 | Thread.sleep (1000);
52 | }
53 | catch (InterruptedException e) {
54 | e.printStackTrace ();
55 | }
56 |
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/jzmq-jni/src/main/perf/local_lat.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | java -classpath "../src/zmq.jar:zmq-perf.jar" local_lat $@
--------------------------------------------------------------------------------
/jzmq-jni/src/main/perf/local_thr.java:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (c) 2007-2010 iMatix Corporation
3 |
4 | This file is part of 0MQ.
5 |
6 | 0MQ is free software; you can redistribute it and/or modify it under
7 | the terms of the Lesser GNU General Public License as published by
8 | the Free Software Foundation; either version 3 of the License, or
9 | (at your option) any later version.
10 |
11 | 0MQ is distributed in the hope that it will be useful,
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | Lesser GNU General Public License for more details.
15 |
16 | You should have received a copy of the Lesser GNU General Public License
17 | along with this program. If not, see .
18 | */
19 |
20 | import org.zeromq.ZMQ;
21 |
22 | class local_thr
23 | {
24 | public static void main (String [] args)
25 | {
26 | if (args.length != 3) {
27 | System.out.println ("usage: local_thr " +
28 | " ");
29 | return;
30 | }
31 |
32 | String bindTo = args [0];
33 | long messageSize = Integer.parseInt (args [1]);
34 | long messageCount = Integer.parseInt (args [2]);
35 |
36 | ZMQ.Context ctx = ZMQ.context (1);
37 | ZMQ.Socket s = ctx.socket (ZMQ.PULL);
38 |
39 | // Add your socket options here.
40 | // For example ZMQ_RATE, ZMQ_RECOVERY_IVL and ZMQ_MCAST_LOOP for PGM.
41 |
42 | s.bind (bindTo);
43 |
44 | byte [] data = s.recv (0);
45 | assert (data.length == messageSize);
46 |
47 | long start = System.currentTimeMillis ();
48 |
49 | for (int i = 1; i != messageCount; i ++) {
50 | data = s.recv (0);
51 | assert (data.length == messageSize);
52 | }
53 |
54 | long end = System.currentTimeMillis ();
55 |
56 | long elapsed = (end - start) * 1000;
57 | if (elapsed == 0)
58 | elapsed = 1;
59 |
60 | long throughput = messageCount * 1000000 / elapsed;
61 | double megabits = (double) (throughput * messageSize * 8) / 1000000;
62 |
63 | System.out.println ("message size: " + messageSize + " [B]");
64 | System.out.println ("message count: " + messageCount);
65 | System.out.println ("mean throughput: " + throughput + "[msg/s]");
66 | System.out.println ("mean throughput: " + megabits + "[Mb/s]");
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/jzmq-jni/src/main/perf/local_thr.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | java -classpath "../src/zmq.jar:zmq-perf.jar" local_thr $@
--------------------------------------------------------------------------------
/jzmq-jni/src/main/perf/remote_lat.java:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (c) 2007-2010 iMatix Corporation
3 |
4 | This file is part of 0MQ.
5 |
6 | 0MQ is free software; you can redistribute it and/or modify it under
7 | the terms of the Lesser GNU General Public License as published by
8 | the Free Software Foundation; either version 3 of the License, or
9 | (at your option) any later version.
10 |
11 | 0MQ is distributed in the hope that it will be useful,
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | Lesser GNU General Public License for more details.
15 |
16 | You should have received a copy of the Lesser GNU General Public License
17 | along with this program. If not, see .
18 | */
19 |
20 | import org.zeromq.ZMQ;
21 |
22 | class remote_lat
23 | {
24 | public static void main (String [] args)
25 | {
26 | if (args.length != 3) {
27 | System.out.println ("usage: remote_lat " +
28 | " ");
29 | return;
30 | }
31 |
32 | String connectTo = args [0];
33 | int messageSize = Integer.parseInt (args [1]);
34 | int roundtripCount = Integer.parseInt (args [2]);
35 |
36 | ZMQ.Context ctx = ZMQ.context (1);
37 | ZMQ.Socket s = ctx.socket (ZMQ.REQ);
38 |
39 | // Add your socket options here.
40 | // For example ZMQ_RATE, ZMQ_RECOVERY_IVL and ZMQ_MCAST_LOOP for PGM.
41 |
42 | s.connect (connectTo);
43 |
44 | long start = System.currentTimeMillis ();
45 |
46 | byte data [] = new byte [messageSize];
47 | for (int i = 0; i != roundtripCount; i ++) {
48 | s.send (data, 0);
49 | data = s.recv (0);
50 | assert (data.length == messageSize);
51 | }
52 |
53 | long end = System.currentTimeMillis ();
54 |
55 | long elapsed = (end - start) * 1000;
56 | double latency = (double) elapsed / roundtripCount / 2;
57 |
58 | System.out.println ("message size: " + messageSize + " [B]");
59 | System.out.println ("roundtrip count: " + roundtripCount);
60 | System.out.println ("mean latency: " + latency + " [us]");
61 | }
62 | }
63 |
64 |
--------------------------------------------------------------------------------
/jzmq-jni/src/main/perf/remote_lat.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | java -classpath "../src/zmq.jar:zmq-perf.jar" remote_lat $@
--------------------------------------------------------------------------------
/jzmq-jni/src/main/perf/remote_thr.java:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (c) 2007-2010 iMatix Corporation
3 |
4 | This file is part of 0MQ.
5 |
6 | 0MQ is free software; you can redistribute it and/or modify it under
7 | the terms of the Lesser GNU General Public License as published by
8 | the Free Software Foundation; either version 3 of the License, or
9 | (at your option) any later version.
10 |
11 | 0MQ is distributed in the hope that it will be useful,
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | Lesser GNU General Public License for more details.
15 |
16 | You should have received a copy of the Lesser GNU General Public License
17 | along with this program. If not, see .
18 | */
19 |
20 | import org.zeromq.ZMQ;
21 |
22 | class remote_thr
23 | {
24 | public static void main (String [] args)
25 | {
26 | if (args.length != 3) {
27 | System.out.println ("usage: remote_thr " +
28 | " ");
29 | return;
30 | }
31 |
32 | // Parse the command line arguments.
33 | String connectTo = args [0];
34 | int messageSize = Integer.parseInt (args [1]);
35 | int messageCount = Integer.parseInt (args [2]);
36 |
37 | ZMQ.Context ctx = ZMQ.context (1);
38 | ZMQ.Socket s = ctx.socket (ZMQ.PUSH);
39 |
40 | // Add your socket options here.
41 | // For example ZMQ_RATE, ZMQ_RECOVERY_IVL and ZMQ_MCAST_LOOP for PGM.
42 |
43 | s.connect (connectTo);
44 |
45 | byte msg [] = new byte [messageSize];
46 | for (int i = 0; i != messageCount; i++)
47 | s.send (msg, 0);
48 |
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/jzmq-jni/src/main/perf/remote_thr.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | java -classpath "../src/zmq.jar:zmq-perf.jar" remote_thr $@
--------------------------------------------------------------------------------
/jzmq-jni/src/test/java/org/zeromq/EmbeddedLibraryToolsTest.java:
--------------------------------------------------------------------------------
1 | package org.zeromq;
2 |
3 | import org.easymock.Capture;
4 | import org.easymock.CaptureType;
5 | import org.junit.After;
6 | import org.junit.Test;
7 | import org.junit.runner.RunWith;
8 | import org.powermock.core.classloader.annotations.PrepareForTest;
9 | import org.powermock.modules.junit4.PowerMockRunner;
10 |
11 | import static org.easymock.EasyMock.capture;
12 | import static org.easymock.EasyMock.newCapture;
13 | import static org.junit.Assert.assertEquals;
14 | import static org.junit.Assert.assertTrue;
15 | import static org.powermock.api.easymock.PowerMock.*;
16 |
17 | /**
18 | * Exercises basic manipulations in the EmbeddedLibraryTools for JNI loading.
19 | * Does not give full coverage yet as this has to be per-platform.
20 | */
21 | @RunWith(PowerMockRunner.class)
22 | public class EmbeddedLibraryToolsTest {
23 | private static final String origOsName = System.getProperty("os.name");
24 |
25 | private static final String origOsArch = System.getProperty("os.arch");
26 |
27 |
28 | @Test
29 | public void rewriteWindowsXP() {
30 | setOsProperties("Windows XP", "x86");
31 | assertPlatformIdentifierEquals("x86/Windows");
32 | }
33 |
34 | @Test
35 | public void rewriteWindows8() {
36 | // Windows 8 reported as 6.2 (http://bugs.java.com/view_bug.do?bug_id=7170169)
37 | setOsProperties("Windows 6.2", "x86");
38 | assertPlatformIdentifierEquals("x86/Windows");
39 | }
40 |
41 | @Test
42 | public void rewriteMacOSX() {
43 | setOsProperties("mac os x", "x86_64");
44 | assertPlatformIdentifierEquals("x86_64/Mac OS X");
45 | }
46 |
47 | @Test
48 | public void passThroughLinux32Bit() {
49 | setOsProperties("Linux", "amd64");
50 | assertPlatformIdentifierEquals("amd64/Linux");
51 | }
52 |
53 | @Test
54 | public void rewriteSpacesInPath() {
55 | setOsProperties("Digital Unix", "alpha");
56 | assertPlatformIdentifierEquals("alpha/Digital_Unix");
57 | }
58 |
59 | @Test
60 | @PrepareForTest(EmbeddedLibraryTools.class)
61 | public void multiLibLoad() throws Exception {
62 | mockStaticPartial(System.class, "load");
63 | Capture loadCapture = newCapture(CaptureType.ALL);
64 | System.load(capture(loadCapture));
65 | expectLastCall().times(2);
66 | replayAll();
67 | setOsProperties("Linux", "testarch");
68 | assertTrue(EmbeddedLibraryTools.LOADED_EMBEDDED_LIBRARY);
69 | verifyAll();
70 | assertTrue(loadCapture.getValues().get(0).contains("libzmq"));
71 | assertTrue(loadCapture.getValues().get(1).contains("libjzmq"));
72 | }
73 |
74 | @Test
75 | @PrepareForTest(EmbeddedLibraryTools.class)
76 | public void libsAsProp() throws Exception {
77 | try {
78 | System.setProperty("jzmq.libs", "foo,libjzmq");
79 | mockStaticPartial(System.class, "load");
80 | Capture loadCapture = newCapture(CaptureType.ALL);
81 | System.load(capture(loadCapture));
82 | expectLastCall().times(2);
83 | replayAll();
84 | setOsProperties("Linux", "testarch");
85 | assertTrue(EmbeddedLibraryTools.LOADED_EMBEDDED_LIBRARY);
86 | verifyAll();
87 | assertTrue(loadCapture.getValues().get(0).contains("foo"));
88 | assertTrue(loadCapture.getValues().get(1).contains("libjzmq"));
89 | } finally {
90 | System.clearProperty("jzmq.libs");
91 | }
92 | }
93 |
94 |
95 | @After
96 | public void resetOsProperties() {
97 | setOsProperties(origOsName, origOsArch);
98 | }
99 |
100 | private void assertPlatformIdentifierEquals(String expected) {
101 | String id = EmbeddedLibraryTools.getCurrentPlatformIdentifier();
102 | assertEquals(expected, id);
103 | }
104 |
105 | private void setOsProperties(String osName, String osArch) {
106 | System.setProperty("os.name", osName);
107 | System.setProperty("os.arch", osArch);
108 | }
109 | }
110 |
--------------------------------------------------------------------------------
/jzmq-jni/src/test/resources/NATIVE/testarch/Linux/foo.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zeromq/jzmq/00e699eff7bcd5a837048c016ec46990b338afb8/jzmq-jni/src/test/resources/NATIVE/testarch/Linux/foo.dll
--------------------------------------------------------------------------------
/jzmq-jni/src/test/resources/NATIVE/testarch/Linux/libjzmq.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zeromq/jzmq/00e699eff7bcd5a837048c016ec46990b338afb8/jzmq-jni/src/test/resources/NATIVE/testarch/Linux/libjzmq.so
--------------------------------------------------------------------------------
/jzmq-jni/src/test/resources/NATIVE/testarch/Linux/libzmq.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zeromq/jzmq/00e699eff7bcd5a837048c016ec46990b338afb8/jzmq-jni/src/test/resources/NATIVE/testarch/Linux/libzmq.so
--------------------------------------------------------------------------------
/jzmq/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 4.0.0
4 |
5 |
6 | org.zeromq
7 | jzmq-parent
8 | 3.1.1-SNAPSHOT
9 |
10 |
11 | org.zeromq
12 | jzmq
13 |
14 |
15 |
16 | org.zeromq
17 | jzmq-core
18 | 3.1.1-SNAPSHOT
19 |
20 |
21 | org.zeromq
22 | jzmq-devices
23 | 3.1.1-SNAPSHOT
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/maven.readme:
--------------------------------------------------------------------------------
1 | Depend on JZMQ
2 | ==============
3 | Add the following to your pom.xml:
4 |
5 |
6 | org.zeromq
7 | jzmq
8 | ${jzmq.version}
9 | compile
10 |
11 |
12 |
13 | org.zeromq
14 | jzmq
15 | ${jzmq.version}
16 | native-${os.arch}-${native.os}
17 |
18 |
19 |
20 |
21 | ${os.name}
22 |
23 |
24 |
25 |
26 | Windows
27 |
28 |
29 | windows
30 |
31 |
32 |
33 | Windows
34 |
35 |
36 |
37 |
38 | If you're not supporting Windows, you can remove the and
39 | elements and replace "${native.os}" with "${os.name}".
40 |
41 | Build JZMQ artifacts
42 | ====================
43 | 1. Build native binary. On Linux, this is:
44 | ./autogen.sh && ./configure && make
45 | 2. Package with Maven:
46 | mvn clean package
47 | 3. Look in the target/ directory for jzmq-[version].jar and
48 | jzmq-[version]-native-[arch]-[os].jar.
49 |
50 | Deploy snapshots
51 | ================
52 | 1. Check that the correct version is set in pom.xml. The version should end in
53 | "-SNAPSHOT".
54 | 2. Build as above.
55 | 3. Deploy with Maven:
56 | mvn deploy
57 | 4. You can deploy individual native JARs like so:
58 | mvn deploy:deploy-file -Durl=https://oss.sonatype.org/content/repositories/snapshots/ -DrepositoryId=sonatype-nexus-snapshots -DpomFile=pom.xml -Dclassifier=native-[arch]-[os] -Dfile=target/jzmq-[version]-native-[arch]-[os].jar
59 |
60 | Release
61 | =======
62 | 1. Check that the correct version is set in pom.xml. The version should end in
63 | "-SNAPSHOT".
64 | 2. Build as above.
65 | 3. Clean up:
66 | mvn release:clean
67 | 4. Do a dry run:
68 | mvn release:prepare -DdryRun
69 | 5. If all goes well, it's time to release. Since this alters git repository
70 | state, it's best to create another branch:
71 | git checkout -b release-[version]
72 | 6. Do the release, accepting the default values when prompted:
73 | mvn release:clean release:prepare release:perform
74 | 7. You can deploy individual native JARs like so:
75 | mvn gpg:sign-and-deploy-file -Durl=https://oss.sonatype.org/service/local/staging/deploy/maven2/ -DrepositoryId=sonatype-nexus-staging -DpomFile=pom.xml -Dclassifier=native-[arch]-[os] -Dfile=target/jzmq-[version]-native-[arch]-[os].jar
76 | 8. Move the artifacts out of staging as instructed at
77 | https://docs.sonatype.org/display/Repository/Sonatype+OSS+Maven+Repository+Usage+Guide
78 | 9. Once everything's done, merge the release branch back into master:
79 | git checkout master
80 | git merge release-[version]
81 | git commit -m "merge completed release branch [version]"
82 | 10. Push to github:
83 | git push
84 |
85 | If anything goes wrong during step 6, you can roll back with the following
86 | commands:
87 | git tag -d v[version]
88 | git branch -D release-[version]
--------------------------------------------------------------------------------
/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 4.0.0
4 |
5 | org.sonatype.oss
6 | oss-parent
7 | 7
8 |
9 | org.zeromq
10 | jzmq-parent
11 | 3.1.1-SNAPSHOT
12 | pom
13 |
14 | The 0MQ lightweight messaging kernel is a library which extends
15 | the standard socket interfaces with features traditionally
16 | provided by specialised messaging middleware products. 0MQ sockets
17 | provide an abstraction of asynchronous message queues, multiple
18 | messaging patterns, message filtering (subscriptions), seamless
19 | access to multiple transport protocols and more.
20 |
21 | This package contains the Java Bindings for ZeroMQ.
22 |
23 | https://zeromq.org/
24 |
25 | scm:git:git://github.com/zeromq/jzmq.git
26 | scm:git:ssh://git@github.com/zeromq/jzmq.git
27 | https://github.com/zeromq/jzmq
28 | HEAD
29 |
30 |
31 |
32 | LGPLv3+
33 | http://www.gnu.org/licenses/lgpl.txt
34 |
35 |
36 |
37 |
38 | zeromq
39 | The ØMQ project
40 |
41 |
42 |
43 | jzmq
44 | jzmq-core
45 | jzmq-devices
46 | jzmq-jni
47 |
48 |
49 | UTF-8
50 | 1.6
51 | 1.6
52 | ${os.arch}
53 | ${native.path}
54 | ${native.library-path}
55 |
56 |
57 |
58 | JNI-Config-For-Linux
59 |
60 |
61 | os.name
62 | Linux
63 |
64 |
65 |
66 | ${os.name}
67 | ${root.directory}/jzmq-jni/src/main/c++/.libs/libjzmq.so
68 | ${root.directory}/jzmq-jni/src/main/c++/.libs/
69 |
70 |
71 |
72 | JNI-Config-For-Windows
73 |
74 |
75 | windows
76 |
77 |
78 |
79 | Windows
80 | ${root.directory}/jzmq-jni/lib/jzmq.dll
81 | ${root.directory}/jzmq-jni/lib
82 |
83 |
84 |
85 | JNI-Config-For-Mac
86 |
87 |
88 | mac
89 |
90 |
91 |
92 | ${os.name}
93 | ${root.directory}/jzmq-jni/src/main/c++/.libs/libjzmq.dylib
94 | ${root.directory}/jzmq-jni/src/main/c++/.libs/
95 |
96 |
97 |
98 | deploy-local-maven
99 |
100 |
101 | maven.releases
102 | ${env.RELEASE_REPO}
103 |
104 |
105 | maven.snapshots
106 | ${env.SNAPSHOT_REPO}
107 |
108 |
109 |
110 |
111 |
112 |
113 | junit
114 | junit
115 | 4.13.1
116 | test
117 |
118 |
119 |
120 |
121 |
122 |
123 | org.commonjava.maven.plugins
124 | directory-maven-plugin
125 | 0.1
126 |
127 |
128 | directories
129 |
130 | highest-basedir
131 |
132 | initialize
133 |
134 | root.directory
135 |
136 |
137 |
138 |
139 |
140 | org.apache.maven.plugins
141 | maven-gpg-plugin
142 | 1.4
143 |
144 |
145 | maven-assembly-plugin
146 | 2.3
147 |
148 |
149 | org.codehaus.mojo
150 | buildnumber-maven-plugin
151 | 1.0
152 |
153 |
154 | org.apache.maven.plugins
155 | maven-release-plugin
156 | 2.5
157 |
158 |
159 | org.apache.maven.plugins
160 | maven-scm-plugin
161 | 1.7
162 |
163 |
164 | org.apache.maven.plugins
165 | maven-jar-plugin
166 | 2.3.1
167 |
168 |
169 | org.apache.maven.plugins
170 | maven-surefire-plugin
171 | 2.16
172 |
173 | 1
174 | true
175 | -Djava.library.path=${native.library-path.resolved}
176 |
177 |
178 |
179 | org.apache.maven.plugins
180 | maven-shade-plugin
181 | 1.4
182 |
183 |
184 | org.apache.maven.plugins
185 | maven-deploy-plugin
186 | 2.6
187 |
188 |
189 | org.apache.maven.plugins
190 | maven-source-plugin
191 | 2.1.2
192 |
193 |
194 | org.apache.maven.plugins
195 | maven-javadoc-plugin
196 | 2.7
197 |
198 |
199 |
200 |
201 |
202 |
--------------------------------------------------------------------------------