Component vs IQHandler

When creating a component you are saying that the server will provide a new service and packets should be routed to the component to execute the new service. Therefore, each component will provide a new subdomain (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 be able to run your component as an external component. That means that it will be a different process in the OS and that the component will connect to the server using sockets.

 

On the other hand, IQHandler is an internal class of Jive Messenger where each subclass will handle a certain type of IQ packet. So IQ packets sent to the server whose domain matches the server domain or IQ packets with no TO attribute will be handled by the server. The server will delegate the responsibility to an IQHandler subclass. The subclass to use 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 option could 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 an external component then you should use the ComponentManager for sending packets:

 

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.com will be redirected by the server to the external component. The external component will process the packet and send back a reply to the user.External components use a different port than clients or servers. Make sure to connect to the external components port as shown in the admin console.

 

你可能感兴趣的:(jvm,OS)