The JVM is the runtime environment for Java-based applications.
We can write programs that run in the JVM (Java Virtual Machine) with a multitude of different languages.
Today, Java and Kotlin are the two languages most used by Android developers, and like Google, many now prefer Kotlin.
It's not too late to refactor your Java application ;)
You can follow our migration guide here if you are currently using our Java SDK, which is now deprecated in favor of the SDK JVM :
Entirely written in Kotlin, it allows us to easily call Java code as well.
This language was written by JetBrains, well known for its numerous IDEs such as IntellIJ Idea, CLion or Webstorm.
The JAR is available on Maven: https://bintray.com/maven/kuzzleio/sdk-jvm
You can now add it to your classpath:
<dependency>
<groupId>io.kuzzle</groupId>
<artifactId>sdk-jvm</artifactId>
<version>1.0.1</version>
<type>pom</type>
</dependency>
implementation 'io.kuzzle:sdk-jvm:1.0.1'
<dependency org='io.kuzzle' name='sdk-jvm' rev='1.0.1'>
<artifact name='sdk-jvm' ext='pom' ></artifact>
</dependency>
Login to your Kuzzle instance now!
First you need to instantiate the SDK by choosing the communication protocol. Only the WebSocket is available for the moment, but HTTP support will arrive very soon.
Here is the Kotlin code:
val ws = WebSocket("kuzzle");
val kuzzle = Kuzzle(ws).apply {
connect()
};
Now you can start communicating with Kuzzle via the API. The structure of our SDKs is modelled on our API with a division into controllers and actions.
Here is an example of authentication with auth:login:
// Login with username "Yoann"
kuzzle.authController.login("local", ConcurrentHashMap<String, Any?>().apply {
put("username", "Yoann")
put("password", "thisarticleisfire")
}).get()
// The SDK instance is now authenticated
Or to create a new document with document:create :
val document: ConcurrentHashMap<String, Any?> = ConcurrentHashMap<String, Any?>().apply {
put("firstname", "Yoann")
put("type", "alien")
}
val result: ConcurrentHashMap<String, Any?> =
kuzzle
.documentController
.create("nyc-open-data", "yellow-taxi", document)
.get();
Our documentation, written in Kotlin and Java, is available here.
You can also consult our Getting Started Kotlin and Java.
In the near future we plan to develop support for the HTTP protocol, which is very important for mobile development, so as not to drain the battery through a persistent WebSocket connection.
There is also still work to be done on the documentation to make it more accessible, notably by writing Getting Started and new guides.
Finally, as the Kuzzle API is constantly being enriched with new actions, we will also have work to integrate them into the current SDK.
If you have any questions about the SDK, you can ask the core-team on Stackoverflow or come and discuss it with the community on Discord: http://join.discord.kuzzle.io.