Can't instantiate XMPPConnection in 4.0.0

Hi all,

I am trying to monitor a chat room and insert all chats into an RDBMS. There are a lot of examples that instantiate an XMPPConnection like so…

XMPPConnection connection = new XMPPConnection(config);

but in 4.0.0 this class is abstract and thus can’t be instantiated. Is the documentation out of date or am I just doing something stupid?

Any help/thoughts are appreciated.

sg

Which documentation are you refering too?

Thingslike these…

http://www.igniterealtime.org/builds/smack/docs/latest/documentation/overview.ht ml

http://www.igniterealtime.org/builds/smack/docs/latest/documentation/connections .html

There must be something stupid I am doing because the class is abstract, I can’t instantiate it, can you?

For instance, I can’t make my compiler build this code…

public class App

{

public static void main( String[] args )

{

Connection connection = new XMPPConnection(“jabber.org”);

connection.connect();

connection.login(“mtucker”, “password”);

    Chat chat = connection.getChatManager().createChat("jsmith@jivesoftware.com", new MessageListener() {

public void processMessage(Chat chat, Message message) {

System.out.println("Received message: " + message);

}

});

chat.sendMessage(“Howdy!”);

}

}

My IDE wants to know what a “Connection” is. This class doesn’t exists in 4.0.0 which I found by opening up the smack-core jar and searching for it. There must be something in 4.0.0 that describes how connections are not supposed to be created right?

The docs are not up to date, thanks for pointing this out (SMACK-574). It’s now

XMPPConnection connection = new XMPPTCPConnection(…)

Tip: Your IDE may provide a class hirarchy view, which would show which classes extends the abstract XMPPConnection. The javadoc of XMPPConnection also states this (“Direct known subclasses”).

and will become

> AbstractXMPPConnection connection = new XMPPTCPConnection()

in Smack 4.1

Uh, do you plan to introduce more of these public API changes in 4.x releases?

I remember you saying, API changes would only be in major releases as per “sem ver” (or maybe it was only my expectation).

h, do you plan to introduce more of these public API changes in 4.x releases?
I don’t expect more changes besides beecb8a6

I remember you saying, API changes would only be in major releases as per “sem ver” (or maybe it was only my expectation).
I don’t remeber me saying “would”, but it could be possible.

It is correct that sem ver would mean that I’ve to name it 5.0. But I felt like this being the only public API change after 4.0, and the fact that it’s a minor one, increasing the major version number was not justified.

Ah ok thanks.

Seeing that there’s still the interface, the API break might be harmless or even non-existent, except for the XMPPConnectionRegistry class.

You basically need AbstractXMPPConnection when you are doing connect() or login(). Everything else uses the new Interface XMPPConnection.

I also don’t expect that most people wont use XMPPConnectionRegistry.

Oh, have overlooked the lack of connect() and login()…

Any reason for that? That makes the interface less useful again.

Any reason for that? That makes the interface less useful again.
Why does it make the interface less useful? The fact that no class in smack-extensions requires those methods should make it clear that declaring them would mean overdefining the interface.