Wildfire 3.2.4 Javadoc

org.jivesoftware.wildfire.interceptor
Class PacketCopier

java.lang.Object
  extended by org.jivesoftware.wildfire.interceptor.PacketCopier
All Implemented Interfaces:
ComponentEventListener, PacketInterceptor

public class PacketCopier
extends Object
implements PacketInterceptor, ComponentEventListener

Packet interceptor that notifies of packets activity to components that previously subscribed to the notificator. Notifications to components will be made using a Message sent to the component itself. The Message will include an extension that will contain the intercepted packet as well as extra information such us incoming and processed.

Author:
Gaston Dombiak

Method Summary
 void addSubscriber(JID componentJID, Component component, boolean iqEnabled, boolean messageEnabled, boolean presenceEnabled, boolean incoming, boolean processed)
          Creates new subscription for the specified component with the specified settings.
 void componentInfoReceived(Component component, IQ iq)
          The server has received a disco#info response from the component.
 void componentRegistered(Component component, JID componentJID)
          A component was registered with the Component Manager.
 void componentUnregistered(Component component, JID componentJID)
          A component was removed.
static PacketCopier getInstance()
          Returns unique instance of this class.
 void interceptPacket(Packet packet, Session session, boolean incoming, boolean processed)
          Invokes the interceptor on the specified packet.
 void removeSubscriber(JID componentJID)
          Removes the subscription of the specified component.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static PacketCopier getInstance()
Returns unique instance of this class.

Returns:
unique instance of this class.

addSubscriber

public void addSubscriber(JID componentJID,
                          Component component,
                          boolean iqEnabled,
                          boolean messageEnabled,
                          boolean presenceEnabled,
                          boolean incoming,
                          boolean processed)
Creates new subscription for the specified component with the specified settings.

Parameters:
componentJID - the address of the component connected to the server.
component - the component that will be notified of packet activity.
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.

removeSubscriber

public void removeSubscriber(JID componentJID)
Removes the subscription of the specified component.

Parameters:
componentJID - the address of the component connected to the server.

interceptPacket

public void interceptPacket(Packet packet,
                            Session session,
                            boolean incoming,
                            boolean processed)
                     throws PacketRejectedException
Description copied from interface: PacketInterceptor
Invokes the interceptor on the specified packet. The interceptor can either modify the packet, or throw a PacketRejectedException to block it from being sent or processed (when read).

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.

Specified by:
interceptPacket in interface PacketInterceptor
Parameters:
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).
Throws:
PacketRejectedException - if the packet should be prevented from being processed.

componentInfoReceived

public void componentInfoReceived(Component component,
                                  IQ iq)
Description copied from interface: ComponentEventListener
The server has received a disco#info response from the component. Once a component is registered with the server, the server will send a disco#info request to the component to discover if service discover is supported by the component. This event is triggered when the server received the response of the component.

Specified by:
componentInfoReceived in interface ComponentEventListener
Parameters:
component - the component that answered the disco#info request.
iq - the IQ packet with the disco#info sent by the component.

componentRegistered

public void componentRegistered(Component component,
                                JID componentJID)
Description copied from interface: ComponentEventListener
A component was registered with the Component Manager. At this point the component has been intialized and started. XMPP entities can exchange packets with the component. However, the component is still not listed as a disco#items of the server since the component has not answered the disco#info request sent by the server.

Specified by:
componentRegistered in interface ComponentEventListener
Parameters:
component - the newly added component.
componentJID - address where the component can be located (e.g. search.myserver.com)

componentUnregistered

public void componentUnregistered(Component component,
                                  JID componentJID)
Description copied from interface: ComponentEventListener
A component was removed.

Specified by:
componentUnregistered in interface ComponentEventListener
Parameters:
component - the removed component.
componentJID - address where the component was located (e.g. search.myserver.com)

Wildfire 3.2.4 Javadoc

Copyright © 2003-2007 Jive Software.