The following artifacts have been renamed:
Experimental work on a server implementation has revealed, that it’s useful to have a “common” module of -let’s say- the WebSocket implementation, which now includes codecs, which can be used likewise by a client and server implementation. The “common” artifacts therefore contain code, which could be shared by clients and servers.
Motivation:
The old Jid class always constructed a new instance with every call of asBareJid(). The interface now allows to reference the enclosing class’ fields and returning only a “bare” view of the enclosing Jid instead of creating new instances. This is a performance improvement to avoid creating too many objects and decreases GC pressure.
Jid being an interface allows for more flexibility. E.g. there’s now a package-private MalformedJid implementation, which is internally used during parsing and allows to send a malformed-jid stanza error.
The XMPP Address Format uses PRECIS for internationalizing the local part. The previous Jid implementation used RFC 7564, which case folded the Jid’s local part. The updated PRECIS specification RFC 8264 only lower cases it. This has the following impact:
Old Jid behavior:
Jid jid = Jid.of('fußball@domain'); // jid.toString() == "fussball@domain"
New Jid behavior:
Jid jid = Jid.of('fußball@domain'); // jid.toString() == "fußball@domain"
There’s a new artifact xmpp-nio-netty-client, which enables you to use Java NIO for TCP connections using the Netty framework.
Background: The current (and default) implementation (see SocketConnectionConfiguration) uses two threads per connection, one for reading, one for writing. This is required, because it uses java.net.Socket internally, which uses blocking IO. For most client applications this is not an issue and totally acceptable, because clients rarely open multiple connections.
However, the advantage of NIO is that it doesn’t use blocking IO, so now you can use only one (!) thread for a large number of connections:
NioEventLoopGroup eventLoopGroup = new NioEventLoopGroup(1); NettyTcpConnectionConfiguration tcpConnectionConfiguration = NettyTcpConnectionConfiguration.builder() .hostname("localhost") .port(5222) .eventLoopGroup(eventLoopGroup) .build(); for (int i = 0; i < 100; i++) { XmppClient xmppClient = XmppClient.create("localhost", configuration, tcpConnectionConfiguration); xmppClient.connect(); }
As you can see, you can reuse the same NioEventLoopGroup for multiple connection configurations.
Sample usage:
ConsistentColor color = ConsistentColor.generate(input); float red = color.getRed(); float green = color.getGreen(); float blue = color.getBlue();
(float is used for easier integration with java.awt.Color.)
For all threads being started you can now specify a custom thread factory. This might be useful when using this library in Java EE with a ManagedThreadFactory:
@Resource private ManagedThreadFactory mtf;
XmppSessionConfiguration configuration = XmppSessionConfiguration.builder() .threadFactory(mtf) .build();