org.apache.mina.handler.chain
Interface IoHandlerCommand

All Known Implementing Classes:
IoHandlerChain

public interface IoHandlerCommand

A IoHandlerCommand encapsulates a unit of processing work to be performed, whose purpose is to examine and/or modify the state of a transaction that is represented by custom attributes provided by IoSession. Individual IoHandlerCommands can be assembled into a IoHandlerChain, which allows them to either complete the required processing or delegate further processing to the next IoHandlerCommand in the IoHandlerChain.

IoHandlerCommand implementations typically retrieve and store state information in the IoSession that is passed as a parameter to the execute(NextCommand,IoSession,Object) method, using custom session attributes. To improve interoperability of IoHandlerCommand implementations, a useful design pattern is to expose the key values used as JavaBeans properties of the IoHandlerCommand implementation class itself. For example, a IoHandlerCommand that requires an input and an output key might implement the following properties:

   private String inputKey = "input";
   public String getInputKey() {
     return (this.inputKey);
   }
   public void setInputKey(String inputKey) {
     this.inputKey = inputKey;
   }

   private String outputKey = "output";
   public String getOutputKey() {
     return (this.outputKey);
   }
   public void setOutputKey(String outputKey) {
     this.outputKey = outputKey;
   }
 

And the operation of accessing the "input" information in the context would be executed by calling:

   String input = (String) session.getAttribute(getInputKey());
 

instead of hard coding the attribute name. The use of the "Key" suffix on such property names is a useful convention to identify properties being used in this fashion, as opposed to JavaBeans properties that simply configure the internal operation of this IoHandlerCommand.

Version:
$Rev: 391231 $, $Date: 2006-04-04 15:21:55 +0900 (Tue, 04 Apr 2006) $
Author:
Apache Directory Project

Nested Class Summary
static interface IoHandlerCommand.NextCommand
          Represents an indirect reference to the next IoHandlerCommand of the IoHandlerChain.
 
Method Summary
 void execute(IoHandlerCommand.NextCommand next, IoSession session, Object message)
          Execute a unit of processing work to be performed.
 

Method Detail

execute

void execute(IoHandlerCommand.NextCommand next,
             IoSession session,
             Object message)
             throws Exception

Execute a unit of processing work to be performed. This IoHandlerCommand may either complete the required processing and just return to stop the processing, or delegate remaining processing to the next IoHandlerCommand in a IoHandlerChain containing this IoHandlerCommand by calling IoHandlerCommand.NextCommand.execute(IoSession,Object).

Parameters:
next - an indirect reference to the next IoHandlerCommand that provides a way to forward the request to the next IoHandlerCommand.
session - the IoSession which is associated with this request
message - the message object of this request
Throws:
Exception - general purpose exception return to indicate abnormal termination