org.jboss.messaging.channel.plugins.handler
Class AbstractChannelHandler

java.lang.Object
  extended byorg.jboss.messaging.channel.plugins.handler.AbstractChannelHandler
All Implemented Interfaces:
ChannelHandler (src) , Consumer (src)
Direct Known Subclasses:
ExclusiveChannelHandler (src) , SharedChannelHandler (src)

public abstract class AbstractChannelHandler
extends java.lang.Object
implements ChannelHandler (src)

An abstract channel handler


Field Summary
protected  MessageSet (src) messages
          The message set
 
Constructor Summary
AbstractChannelHandler(MessageSet (src)  messages)
          Create a new AbstractChannelHandler.
 
Method Summary
 boolean accepts(MessageReference (src)  reference, boolean active)
          Check whether the consumer accepts the message.
protected abstract  void addConsumer(Consumer (src)  consumer, long wait)
          Add a consumer
 void addMessage(MessageReference (src)  reference)
          Add a message to the channel handler.
protected abstract  Consumer (src) findConsumer(MessageReference (src)  reference)
          Find a consumer for a message
 void onMessage(MessageReference (src)  reference)
          Invoked when a message needs consuming
protected abstract  void removeConsumer(Consumer (src)  consumer)
          Remove a consumer
 MessageReference (src) removeMessage(Consumer (src)  consumer)
          Remove a message from the channel handler.
 void stopWaitMessage(Consumer (src)  consumer)
          Remove a consumer that is waiting for a message.
 void waitMessage(Consumer (src)  consumer, long wait)
          Wait for a message from the channel handler.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

messages

protected MessageSet (src)  messages
The message set

Constructor Detail

AbstractChannelHandler

public AbstractChannelHandler(MessageSet (src)  messages)
Create a new AbstractChannelHandler.

Parameters:
messages - the messages
Method Detail

accepts

public boolean accepts(MessageReference (src)  reference,
                       boolean active)
Description copied from interface: Consumer (src)
Check whether the consumer accepts the message.

Specified by:
accepts in interface Consumer (src)
Parameters:
reference - the message reference
active - whether to check for activity, pass false to test for acceptance, true when extra checks for an active consumer are required.
Returns:
true when it accepts the message, false otherwise

onMessage

public void onMessage(MessageReference (src)  reference)
Description copied from interface: Consumer (src)
Invoked when a message needs consuming

Specified by:
onMessage in interface Consumer (src)
Parameters:
reference - the message reference

addMessage

public void addMessage(MessageReference (src)  reference)
Description copied from interface: ChannelHandler (src)
Add a message to the channel handler.

Specified by:
addMessage in interface ChannelHandler (src)
Parameters:
reference - the message reference to add

removeMessage

public MessageReference (src)  removeMessage(Consumer (src)  consumer)
Description copied from interface: ChannelHandler (src)
Remove a message from the channel handler.

Specified by:
removeMessage in interface ChannelHandler (src)
Parameters:
consumer - the consumer used to accept the message
Returns:
a message or null if there are no messages

waitMessage

public void waitMessage(Consumer (src)  consumer,
                        long wait)
Description copied from interface: ChannelHandler (src)
Wait for a message from the channel handler.

Specified by:
waitMessage in interface ChannelHandler (src)
Parameters:
consumer - the consumer that will wait for a message
wait - the length of time

stopWaitMessage

public void stopWaitMessage(Consumer (src)  consumer)
Description copied from interface: ChannelHandler (src)
Remove a consumer that is waiting for a message.

Specified by:
stopWaitMessage in interface ChannelHandler (src)
Parameters:
consumer - the consumer to remove.

addConsumer

protected abstract void addConsumer(Consumer (src)  consumer,
                                    long wait)
Add a consumer

Parameters:
consumer - the consumer to wait for a message
wait - the length of time to wait

removeConsumer

protected abstract void removeConsumer(Consumer (src)  consumer)
Remove a consumer

Parameters:
consumer - the consumer to remove

findConsumer

protected abstract Consumer (src)  findConsumer(MessageReference (src)  reference)
Find a consumer for a message

Parameters:
reference - the message
Returns:
the consumer or null if there are none for the message