Welcome to another blog post! It's been a long time since my last post and since the last version there have been two major refactorings which are now finished. There are also new features like Multi-User Chat support which have reached a status where they can be considered complete. Reason enough to release version 0.2.0! Let's have a look at the important changes.
Refactoring 1: Create an XMPP Core Library
The first refactoring I am talking about is that Babbler has emerged into two modules: An "xmpp-core" module which mainly consists of mappings between Java classes and XMPP and an "xmpp-client" module for XMPP client functionality, which implements "real" business logic for clients.
The reason for this separation is simple: I wanted to have an "xmpp-core" module, which could serve client and server implementations alike, at least theoretically.
Its purpose is comparable to Tinder, but it's much cleaner, more complete and doesn't have the "jivesoftware stamp" attached to it. Besides mapping to XMPP stanzas and extensions it also provides a few utility methods and classes, e.g. for generating the verification string for Entity Capabilities.
If interest arose, it could now be easily provided as own library, similarly to Tinder.
What you can do with it now is that you can generate XMPP-style XML in an easy way using standard JAXB:
Writer writer = new StringWriter(); XMLStreamWriter xmlStreamWriter = XMLOutputFactory.newFactory().createXMLStreamWriter(writer); XMLStreamWriter xmppStreamWriter = XmppUtils.createXmppStreamWriter(xmlStreamWriter, true); JAXBContext jaxbContext = JAXBContext.newInstance(Message.class, Sent.class); Marshaller marshaller = jaxbContext.createMarshaller(); marshaller.setProperty(Marshaller.JAXB_FRAGMENT, true); Message forwardedMessage = new Message(Jid.valueOf("romeo@example.net"), Message.Type.CHAT, "Hi!!"); Message message = new Message(Jid.valueOf("juliet@example.net")); message.getExtensions().add(new Sent(new Forwarded(forwardedMessage))); marshaller.marshal(message, xmppStreamWriter); System.out.println(writer.toString());
Which would output the following:
<message to="juliet@example.net"> <sent xmlns="urn:xmpp:carbons:2"> <forwarded xmlns="urn:xmpp:forward:0"> <message xmlns="jabber:client" to="romeo@example.net" type="chat"> <body>Hi!!</body> </message> </forwarded> </sent> </message>
Cool, isn't it? Especially, that it sets the correct namespace for the inner message, but doesn't set it for the outer message (since it's the default namespace there).
Refactoring 2: XmppSession Instead of Connection
The second major refactoring was the concept of using an "XmppSession" instead of a "Connection". The session can have multiple connection methods which are tried during establishing the XMPP session. If connecting with TCP fails for some reason, the session can try alternative connection methods such as BOSH as fallback.
I've illustrated this approach here:
New Features
Besides these major refactorings, there were other changes in form of new features, improvements and more documentation.
One of the major addition is the Multi-User Chat support. In my last blog post, I've also announced support for Real-Time Text would find its way into 0.2.0, but unfortunately it's not yet finished.
You can find the changelog and documentation on the project site.
---
That's it for now, I hope you like it. If you have something to say, just leave a comment!
Since it's not yet available in Maven Central / Sonatype, here's if anyone wants it via Maven :
ReplyDelete<dependency>
<groupId>org.xmpp</groupId>
<artifactId>xmpp-core</artifactId>
<version>0.2.0</version>
</dependency>
<dependency>
<groupId>org.xmpp</groupId>
<artifactId>xmpp-server</artifactId>
<version>0.2.0</version>
</dependency>
Repository:
<repository>
<id>bippo-nexus-public</id>
<url>http://nexus.bippo.co.id/nexus/content/groups/public/</url>
</repository>
The client:
Delete<dependency>
<groupId>org.xmpp</groupId>
<artifactId>xmpp-client</artifactId>
<version>0.2.0</version>
</dependency>
With Maven dependency you get sources and JavaDocs automatically in IDE, which is not included if downloading the binary JAR manually.
Deleteyou can download the libs with the maven xml also here: http://jar-download.com/
ReplyDelete