public class PacketCopier extends Object implements PacketInterceptor, ComponentEventListener
Modifier and Type | Method and Description |
---|---|
void |
addSubscriber(org.xmpp.packet.JID componentJID,
boolean iqEnabled,
boolean messageEnabled,
boolean presenceEnabled,
boolean incoming,
boolean processed)
Creates new subscription for the specified component with the specified settings.
|
void |
componentInfoReceived(org.xmpp.packet.IQ iq)
The server has received a disco#info response from the component.
|
void |
componentRegistered(org.xmpp.packet.JID componentJID)
A component was registered with the Component Manager.
|
void |
componentUnregistered(org.xmpp.packet.JID componentJID)
A component was removed.
|
static PacketCopier |
getInstance()
Returns unique instance of this class.
|
void |
interceptPacket(org.xmpp.packet.Packet packet,
Session session,
boolean incoming,
boolean processed)
Invokes the interceptor on the specified packet.
|
void |
removeSubscriber(org.xmpp.packet.JID componentJID)
Removes the subscription of the specified component.
|
public static PacketCopier getInstance()
public void addSubscriber(org.xmpp.packet.JID componentJID, boolean iqEnabled, boolean messageEnabled, boolean presenceEnabled, boolean incoming, boolean processed)
componentJID
- the address of the component connected to the server.iqEnabled
- true if interested in IQ packets of any type.messageEnabled
- true if interested in Message packets.presenceEnabled
- true if interested in Presence packets.incoming
- true if interested in incoming traffic. false means outgoing.processed
- true if want to be notified after packets were processed.public void removeSubscriber(org.xmpp.packet.JID componentJID)
componentJID
- the address of the component connected to the server.public void interceptPacket(org.xmpp.packet.Packet packet, Session session, boolean incoming, boolean processed) throws PacketRejectedException
PacketInterceptor
An exception can only be thrown when processed is false which means that the read packet has not been processed yet or the packet was not sent yet. If the exception is thrown with a "read" packet then the sender of the packet will receive an answer with an error. But if the exception is thrown with a "sent" packet then nothing will happen.
Note that for each packet, every interceptor will be called twice: once before processing is complete (processing==true) and once after processing is complete. Typically, an interceptor will want to ignore one or the other case.
interceptPacket
in interface PacketInterceptor
packet
- the packet to take action on.session
- the session that received or is sending the packet.incoming
- flag that indicates if the packet was read by the server or sent from
the server.processed
- flag that indicates if the action (read/send) was performed. (PRE vs. POST).PacketRejectedException
- if the packet should be prevented from being processed.public void componentInfoReceived(org.xmpp.packet.IQ iq)
ComponentEventListener
componentInfoReceived
in interface ComponentEventListener
iq
- the IQ packet with the disco#info sent by the component.public void componentRegistered(org.xmpp.packet.JID componentJID)
ComponentEventListener
componentRegistered
in interface ComponentEventListener
componentJID
- address where the component can be located (e.g. search.myserver.com)public void componentUnregistered(org.xmpp.packet.JID componentJID)
ComponentEventListener
componentUnregistered
in interface ComponentEventListener
componentJID
- address where the component was located (e.g. search.myserver.com)Copyright © 2003-2008 Jive Software.