net.sf.beep4j.ext
Class ChannelHandlerAdapter

java.lang.Object
  extended by net.sf.beep4j.ext.ChannelHandlerAdapter
All Implemented Interfaces:
ChannelHandler

public abstract class ChannelHandlerAdapter
extends java.lang.Object
implements ChannelHandler

Base implementation for ChannelHandler implementors. Implement the remaining unimplemented methods and override the methods you deem necessary.

Author:
Simon Raess

Constructor Summary
ChannelHandlerAdapter()
           
 
Method Summary
 void channelClosed()
          Notifies this handler that the channel has been closed.
 void channelCloseRequested(CloseChannelRequest request)
          Notifies this handler that the remote peer requested to close the channel associated with this handler.
 void channelOpened(Channel channel)
          Notifies this handler that the channel has been successfully opened.
 void channelStartFailed(int code, java.lang.String message)
          This method ignores this event.
protected  Channel getChannel()
          Gets the channel object set by the channelOpened(Channel) method.
 void messageReceived(Message message, Reply reply)
          Notifies this handler that a message has been received.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ChannelHandlerAdapter

public ChannelHandlerAdapter()
Method Detail

getChannel

protected Channel getChannel()
Gets the channel object set by the channelOpened(Channel) method.

Returns:
the Channel object

channelStartFailed

public void channelStartFailed(int code,
                               java.lang.String message)
This method ignores this event. If you want to react to it you must override this method.

Specified by:
channelStartFailed in interface ChannelHandler
Parameters:
code - the reply code
message - the diagnostic message

channelOpened

public void channelOpened(Channel channel)
Notifies this handler that the channel has been successfully opened. This method keeps a reference to the Channel object, which can be retrieved through the getChannel() method.

Specified by:
channelOpened in interface ChannelHandler
Parameters:
channel - the Channel object

messageReceived

public void messageReceived(Message message,
                            Reply reply)
Notifies this handler that a message has been received. If you expect messages to be received, implement this method. This default implementation throws an exception.

Specified by:
messageReceived in interface ChannelHandler
Parameters:
message - the received message
reply - the reply that can be used to send a reply

channelCloseRequested

public void channelCloseRequested(CloseChannelRequest request)
Notifies this handler that the remote peer requested to close the channel associated with this handler. This method accepts the request. If you want to have the oppurtunity to cancel a close request, you must override this method.

Specified by:
channelCloseRequested in interface ChannelHandler
Parameters:
request - the request to be declined or accepted

channelClosed

public void channelClosed()
Notifies this handler that the channel has been closed. This method sets the channel reference to null.

Specified by:
channelClosed in interface ChannelHandler


Copyright © 2007 null. All Rights Reserved.