Component vs IQHandler
When creating a component you are saying that the server willprovide a new service and packets should be routed to the component toexecute the new service. Therefore, each component will provide a newsubdomain (eg. search.myserver.com) for the server (eg. myserver.com).So packets whose domain matches the subdomain that your component is handling will be routed to your component. This includes Presence,Message and IQ packets. Moreover, when you build a component you may beable to run your component as an external component. That means that itwill be a different process in the OS and that the component willconnect to the server using sockets.Onthe other hand, IQHandler is an internal class of Jive Messenger whereeach subclass will handle a certain type of IQ packet. So IQ packetssent to the server whose domain matches the server domain or IQ packetswith no TO attribute will be handled by the server. The server willdelegate the responsibility to an IQHandler subclass. The subclass touse will depend on the namespace of the child element in the IQ packet.
To send packets from your plugin you have two options. The first optioncould be used if your plugin will always run on the same JVM of JM.
XMPPServer.getInstance().getPacketRouter().route(<Packet>);
but, if your plugin contains a component that may be used as anexternal component then you should use the ComponentManager for sendingpackets:
componentManager.sendPacket(this, <Packet>);
External components are transparent to people that want to use a service in an XMPP server. Lets say that a server's domain is example.com and you connect the weather example, included in Whack, to the server. The weather external component will use the address weather.example.com. That means that any packet sent to weather.example.comwill be redirected by the server to the external component. Theexternal component will process the packet and send back a reply to theuser.External components use a different port than clients or servers. Makesure to connect to the external components port as shown in the adminconsole.
页:
[1]