FileDocCategorySizeDatePackage
ChannelInterceptor.javaAPI DocApache Tomcat 6.0.147659Fri Jul 20 04:20:34 BST 2007org.apache.catalina.tribes

ChannelInterceptor

public interface ChannelInterceptor implements Heartbeat, MembershipListener
A ChannelInterceptor is an interceptor that intercepts messages and membership messages in the channel stack. This allows interceptors to modify the message or perform other actions when a message is sent or received.
Interceptors are tied together in a linked list.
see
org.apache.catalina.tribes.group.ChannelInterceptorBase
author
Filip Hanik
version
$Revision: 467222 $, $Date: 2006-10-24 05:17:11 +0200 (mar., 24 oct. 2006) $

Fields Summary
Constructors Summary
Methods Summary
public voidfireInterceptorEvent(org.apache.catalina.tribes.ChannelInterceptor$InterceptorEvent event)

public MembergetLocalMember(boolean incAliveTime)
Intercepts the code>Channel.getLocalMember(boolean) method

param
incAliveTime boolean
return
Member
see
Channel#getLocalMember(boolean)

public MembergetMember(Member mbr)
Intercepts the code>Channel.getMember(Member) method

param
mbr Member
return
Member - the actual member information, including stay alive
see
Channel#getMember(Member)

public Member[]getMembers()
Intercepts the code>Channel.getMembers() method

return
Member[]
see
Channel#getMembers()

public org.apache.catalina.tribes.ChannelInterceptorgetNext()
Retrieve the next interceptor in the list

return
ChannelInterceptor - returns the next interceptor in the list or null if no more interceptors exist

public intgetOptionFlag()
An interceptor can react to a message based on a set bit on the message options.
When a message is sent, the options can be retrieved from ChannelMessage.getOptions() and if the bit is set, this interceptor will react to it.
A simple evaluation if an interceptor should react to the message would be:
boolean react = (getOptionFlag() == (getOptionFlag() & ChannelMessage.getOptions()));
The default option is 0, meaning there is no way for the application to trigger the interceptor. The interceptor itself will decide.

return
int
see
ChannelMessage#getOptions()

public org.apache.catalina.tribes.ChannelInterceptorgetPrevious()
Retrieve the previous interceptor in the list

return
ChannelInterceptor - returns the previous interceptor in the list or null if no more interceptors exist

public booleanhasMembers()
Intercepts the Channel.hasMembers() method

return
boolean - if the channel has members in its membership group
see
Channel#hasMembers()

public voidheartbeat()
The heartbeat() method gets invoked periodically to allow interceptors to clean up resources, time out object and perform actions that are unrelated to sending/receiving data.

public voidmessageReceived(ChannelMessage data)
the messageReceived is invoked when a message is received. ChannelMessage.getAddress() is the sender, or the reply-to address if it has been overwritten.

param
data ChannelMessage

public voidsendMessage(Member[] destination, ChannelMessage msg, org.apache.catalina.tribes.group.InterceptorPayload payload)
The sendMessage method is called when a message is being sent to one more destinations. The interceptor can modify any of the parameters and then pass on the message down the stack by invoking getNext().sendMessage(destination,msg,payload)
Alternatively the interceptor can stop the message from being sent by not invoking getNext().sendMessage(destination,msg,payload)
If the message is to be sent asynchronous the application can be notified of completion and errors by passing in an error handler attached to a payload object.
The ChannelMessage.getAddress contains Channel.getLocalMember, and can be overwritten to simulate a message sent from another node.

param
destination Member[] - the destination for this message
param
msg ChannelMessage - the message to be sent
param
payload InterceptorPayload - the payload, carrying an error handler and future useful data, can be null
throws
ChannelException
see
ErrorHandler
see
InterceptorPayload

public voidsetNext(org.apache.catalina.tribes.ChannelInterceptor next)
Set the next interceptor in the list of interceptors

param
next ChannelInterceptor

public voidsetOptionFlag(int flag)
Sets the option flag

param
flag int
see
#getOptionFlag()

public voidsetPrevious(org.apache.catalina.tribes.ChannelInterceptor previous)
Set the previous interceptor in the list

param
previous ChannelInterceptor

public voidstart(int svc)
Starts up the channel. This can be called multiple times for individual services to start The svc parameter can be the logical or value of any constants

param
svc int value of
Channel.DEFAULT - will start all services
Channel.MBR_RX_SEQ - starts the membership receiver
Channel.MBR_TX_SEQ - starts the membership broadcaster
Channel.SND_TX_SEQ - starts the replication transmitter
Channel.SND_RX_SEQ - starts the replication receiver
throws
ChannelException if a startup error occurs or the service is already started.
see
Channel

public voidstop(int svc)
Shuts down the channel. This can be called multiple times for individual services to shutdown The svc parameter can be the logical or value of any constants

param
svc int value of
Channel.DEFAULT - will shutdown all services
Channel.MBR_RX_SEQ - stops the membership receiver
Channel.MBR_TX_SEQ - stops the membership broadcaster
Channel.SND_TX_SEQ - stops the replication transmitter
Channel.SND_RX_SEQ - stops the replication receiver
throws
ChannelException if a startup error occurs or the service is already started.
see
Channel