Beans and PacketExtensions

Hi all.

I’‘ve seen several topics on related issues, but i still didn’'t get this one to work.

I’‘ve added to my smack.providers the mapping between the namespace/elementName pair and a Bean class with getter/setter to the respective properties. I’‘m pretty sure it picks it up as i was getting a ClassCastException and now after deciding to use the file instead of dynamic provider registration it went away (and my XMPP connection stopped going down). I’'m now trusting Bean mapping instead of implementing PacketExtensionProvider.

So question is… is this the way to get the Bean object, after value setting by smack?

MyBean bean = (MyBean)packet.getExtension(“mynamespace”, “myelement”);

I’‘m getting null for the bean object here, even if tracing the xmpp packet sent i’'m getting:

Any idea?

Thanks in advance,

Ricardo

Hola Ricardo,

The Packet#getExtension method expects the first parameter to be elementName and the second parameter to be the namespace. So in your example you will need to change the code to:

MyBean bean = (MyBean)packet.getExtension(“myelement”, “mynamespace”);[/code]

Regards,

– Gato

Ouch… thanks a million.

I got to play around with several other smack features trying to overcome this

Ricardo