|
Openfire 3.5.2 Javadoc | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.jivesoftware.openfire.interceptor.InterceptorManager
public class InterceptorManager
An InterceptorManager manages the list of global interceptors and per-user interceptors that are invoked before and after packets are read and sent. If an interceptor is installed for a user then it will receive all packets sent or received for any connection of that user.
PacketInterceptors that are invoked before the packet is sent or processed
(when read) may change the original packet or reject the packet by throwing
a PacketRejectedException
. If the interceptor rejects a received packet
then the sender of the packet receive a
not_allowed
error.
PacketInterceptor
Constructor Summary | |
---|---|
InterceptorManager()
|
Method Summary | |
---|---|
void |
addInterceptor(int index,
PacketInterceptor interceptor)
Inserts a new interceptor at specified index in the list of currently configured interceptors. |
void |
addInterceptor(PacketInterceptor interceptor)
Inserts a new interceptor at the end of the list of currently configured interceptors. |
void |
addUserInterceptor(String username,
int index,
PacketInterceptor interceptor)
Inserts a new interceptor at specified index in the list of currently configured interceptors for a specific username. |
static InterceptorManager |
getInstance()
Returns a singleton instance of InterceptorManager. |
List<PacketInterceptor> |
getInterceptors()
Returns an unmodifiable list of global packet interceptors. |
List<PacketInterceptor> |
getUserInterceptors(String username)
Returns an unmodifable list of packet interceptors that are related to the specified username. |
void |
invokeInterceptors(Packet packet,
Session session,
boolean read,
boolean processed)
Invokes all currently-installed interceptors on the specified packet. |
boolean |
removeInterceptor(PacketInterceptor interceptor)
Removes the global interceptor from the list. |
boolean |
removeUserInterceptor(String username,
PacketInterceptor interceptor)
Removes the interceptor from the list of interceptors that are related to a specific username. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public InterceptorManager()
Method Detail |
---|
public static InterceptorManager getInstance()
public List<PacketInterceptor> getInterceptors()
public void addInterceptor(PacketInterceptor interceptor)
interceptor
- the interceptor to add.public void addInterceptor(int index, PacketInterceptor interceptor)
index
- the index in the list to insert the new interceptor at.interceptor
- the interceptor to add.public boolean removeInterceptor(PacketInterceptor interceptor)
interceptor
- the interceptor to remove.
public List<PacketInterceptor> getUserInterceptors(String username)
username
- the name of the user.
public void addUserInterceptor(String username, int index, PacketInterceptor interceptor)
username
- the name of the user.index
- the index in the list to insert the new interceptor at.interceptor
- the interceptor to add.public boolean removeUserInterceptor(String username, PacketInterceptor interceptor)
username
- the name of the user.interceptor
- the interceptor to remove.
public void invokeInterceptors(Packet packet, Session session, boolean read, boolean processed) throws PacketRejectedException
Interceptors are executed before and after processing an incoming packet and sending a packet to a user. This means that interceptors are able to alter or reject packets before they are processed further. If possible, interceptors should perform their work in a short time so that overall performance is not compromised.
packet
- the packet that has been read or is about to be sent.session
- the session that received the packet or that the packet
will be sent to.read
- true indicates that the packet was read. When false, the packet
is being sent to a user.processed
- true if the packet has already processed (incoming or outgoing).
If the packet hasn't already been processed, this flag will be false.
PacketRejectedException
- if the packet should be prevented from being processed.
|
Openfire 3.5.2 Javadoc | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |