powered by Jive Software

Various updates

Hey all,

Smack 1.0.1 has been released, which is an important bug fix for those using Smack in applets.

Work is now being done on the 1.1 release. One interesting feature that will be available in the 5/1 daily build is pluggable IQ parsing. For example, say you wanted Smack to support the Jabber time protocol (http://www.jabber.org/protocol/time.html). Prior to 1.1, there was no easy way to handle this functionality. Now, IQ providers can be registered with the PacketReader class to handle custom IQ packet types.

Full information about how to register and use IQ providers is now in the Javadocs of PacketReader. For those that want to play with this functionality, see the attached files:

  • smack.providers – a Smack providers file that registers jabber:iq:time IQ handling.

  • Time.java – an IQ instance for Time information.


smack.providers (151 Bytes)
Time.java (1618 Bytes)

Actually, here’'s the info from the PacketReader Javadoc for those that are interested.

/** * Listens for XML traffic from the XMPP server and * parses it into packet objects. The packet reader also * manages all packet listeners and collectors.<p> * * By default, this class only knows how to process IQ * packets with query sub-packets that are in a few * namespaces: *      * jabber:iq:auth *      * jabber:iq:roster *      * jabber:iq:register</ul> * * Because many more IQ types are part of XMPP and its * extensions, a pluggable IQ parsing mechanism is * provided. IQ providers are registered by creating a * smack.providers file in the WEB-INF directory of your * JAR file. The file is an XML document that contains * one or more iqProvider entries, as in the following * example: * * <?xml version="1.0"?> * <smackProviders> *     <iqProvider namespace="jabber:iq:time" *      className="org.jivesoftware.smack.packet.Time"/> * </smackProviders> * * Each IQ provider is associated with a namespace. If * multiple provider entries attempt to register to * handle the same namespace, the first entry loaded * from the classpath will take precendence. The IQ * provider class can either implement the IQProvider * interface, or extend the IQ class. In the former * case, each IQProvider is responsible for parsing * the raw XML stream to create an IQ instance. In the * latter case, bean introspection is used to try to * automatically set properties of the IQ instance using * the values found in the IQ packet XML. For example, * an XMPP time packet resembles the following: * <iq type=''get'' to=''joe@example.com'' *  from=''mary@example.com'' id=''time_1''> *     <query xmlns=''jabber:iq:time''> *         <utc>20020910T17:58:35</utc> *         <tz>MDT</tz> *         <display>Tue Sep 10 12:58:35 2002</display> *     </query> * </iq> * * In order for this packet to be automatically mapped * to the Time object listed in the providers file * above, it must have the methods setUtc(String), * setTz(String), and setDisplay(tz). The introspection * service will automatically try to convert the String * value from the XML into a boolean, int, long, float, * double, or Class depending on the * type the IQ instance expects. */