Casting Packet Extension

Hi!

I created a new PacketExtension, ie ‘‘Alias’’, and the corresponding extension provider (should I subscribe this provider somewhere?!). In testing packets are send and received, extension inclusive.

However, I can not cast the DefaultPacketExtension received from packet.getExtension(elementName, nameSpace) to my original extension ‘‘Alias’’. The xml of the extension seems to be ok, however, there is one thing a bit strange: the last and second to last xml elements changed places.

Anyone any idea how to solve my casting problem?! Tenx!

Cheers,

Thomas

Thomas,

You should register your extension provider in the smack.providers file. Also make sure that the META-INF folder is present in your classpath.

Once you do that you won’'t need to cast a DefaultPacketExtension to your specific extension since Smack will locate and use your provider which in turn will answer an instance of your packet extension.

Let me know if you need more help with this.

Regards,

– Gato

Gato,

Thanks a lot! This solves the problem indeed.

Cheers,

Thomas