Mindoo Blog - Cutting edge technologies - About Java, Lotus Notes and iPhone

  • New on Github: Domino JNA - Cross-platform access to IBM Notes/Domino C API methods from Java

    Karsten Lehmann  8 April 2016 19:11:37
    I would like to introduce you to a pet project that I have been working on for the last months:

    Domino JNA -

    Cross-platform access to IBM Notes/Domino C API methods from Java

    As you might have already read in this blog in the past, we have been playing with the Domino C API for some time now and found out that you can speed up view reading dramatically when you talk directly to the C API instead of using IBM's Java classes.

    The C API also provides lots of other functionality for which no Java or LotusScript methods exist yet.

    It has always been possible to build your own DLL with C code calling Domino methods and use it via Java's Native Interface (JNI). We did this in applications developed for customers and partners, e.g. to render Richtext to HTML format, directly stream attachments (IBM's API first stores files temporarily to disk, not a good idea) or replicate databases with a progress callback.

    But the problem has always been that the native code has to be compiled for each platform.

    JNA to the rescue

    Java Native Access is a project that gives Java developers access to native shared libraries without creating their own DLL or library file.
    You simply call Java methods and make sure that your method arguments match those on the C side.

    So I created my first small sample application months ago calling some Domino code, found out that it worked in Windows 32 bit, found out that I had to change something for Windows 64 bit to get more than just crashes, found out that the whole stuff did nothing than crashing in Linux systems, read lots of Domino C API documentation, build testcases, documented the API methods....

    ...and months later I uploaded the whole stuff to Github. :-)

    Here it is:


    An API is nothing without documentation and sample code. And I am working on that, but this takes time. There are already a few testcases available for the view functions.

    Since talking to low level functions is not what everybody likes, I am also creating helper functions that make working with the API easier. I rename stuff, I add stuff and hide stuff. So please be aware that this project is definitely not finish and will change, but I want to share the code today because it already creates value and works quite well for us.

    What does it do already?

    Here are some of the things you can do with the first version:
    • view lookups using different key formats (e.g. strings, numbers, dates, date ranges) and equality/inequality searches (e.g. find less or greater than a search key)
    • decodes all available types of view column data types (string, string list, number, number list, datetime, datetime list) and row data (e.g. just note id, UNID, counts, unread flag etc.)
    • read view data as another Notes user
    • separation of Notes views and their data into multiple databases (like programmatically creating private views and keeping them up-to-date incrementally)
    • special optimized functions for local databases (e.g. when API is running on the server and databases are on the server as well):
      • dynamic filtering of view rows based on a Note id list with paging support (this really rocks!)
      • reading categorized views with expanded/collapsed entries and min/max level
    • read design collection with design elements in a database
    • support for view resorting (changing the collation in C API terms)
    • fulltext index creation with all available options
    • supports incremental synchronization of Domino databases
      by reading noteid lists of modified and deleted documents (IBM's Java API does not return ids of deleted docs)
    • clearing the replication history
    • compute @Usernameslist values for any Notes user

    License

    The Github repository contains a Maven project with the API code and setup instructions. All is available under Apache 2.0 license.

    As next step, I want to add the code to an XPages Extension Library plugin to make it easier to use from XPages code.


    Please provide feedback if the project is working for you.

    Comments

    1Jesper Kiaer  09.04.2016 00:33:24  New on Github: Domino JNA - Cross-platform access to IBM Notes/Domino C API methods from Java

    That is really great stuff! Looking forward to try it! :-)

    JNA is really nice and I have used it for some small projects over the last years.

    I even did a blog about it some years ago on JNA and Domino C API to help people get started on it.

    { Link }

    2Ulrich Krause  10.04.2016 02:52:40  New on Github: Domino JNA - Cross-platform access to IBM Notes/Domino C API methods from Java

    Hot stuff. Great. Thx for sharing

    3Paul Withers  11.04.2016 00:03:19  New on Github: Domino JNA - Cross-platform access to IBM Notes/Domino C API methods from Java

    Out of interest, the core Java API has a bug with getAllEntriesByKey and getAllDocumentsByKey where if you pass multiple keys including a Double, it works if the only Double is the last element of the keys. But it fails if a Double is anywhere else in the keys Vector but the last element. It's fine in LS, so it seems to be Java implementation so your API shouldn't suffer from the same problem. But I'd be interested to know if yours fixes the bug.

    4Shillem Volpato  11.04.2016 12:05:48  New on Github: Domino JNA - Cross-platform access to IBM Notes/Domino C API methods from Java

    Awesome. Looking forward to seeing more coming

    5Karsten Lehmann  11.04.2016 14:44:22  New on Github: Domino JNA - Cross-platform access to IBM Notes/Domino C API methods from Java

    Paul,

    I just tried it with a view that is sorted by double-string-double. I can run lookups against the view with double-string-double keys without problems.

    6Tommy Valand  19.04.2016 08:23:42  New on Github: Domino JNA - Cross-platform access to IBM Notes/Domino C API methods from Java

    Great work!

    7mp3 skull  24.03.2017 22:57:27  New on Github: Domino JNA - Cross-platform access to IBM Notes/Domino C API methods from Java

    { Link }

    • Remember me