com.mooapi.server.protocol.codec
Class MooServerProtocolDecoder

java.lang.Object
  extended by org.apache.mina.filter.codec.ProtocolDecoderAdapter
      extended by org.apache.mina.filter.codec.CumulativeProtocolDecoder
          extended by com.mooapi.server.protocol.codec.MooServerProtocolDecoder
All Implemented Interfaces:
org.apache.mina.filter.codec.ProtocolDecoder

public class MooServerProtocolDecoder
extends org.apache.mina.filter.codec.CumulativeProtocolDecoder

MooAPI input parser.

Author:
Steve Taylor

Constructor Summary
MooServerProtocolDecoder()
          Delegate initialization to the relevant property setters.
MooServerProtocolDecoder(MooServer mooServer)
          Initialize.
 
Method Summary
protected  boolean doDecode(org.apache.mina.common.IoSession session, org.apache.mina.common.ByteBuffer in, org.apache.mina.filter.codec.ProtocolDecoderOutput out)
          Parse a stream of bytes.
 void setClientCommandCodec(ClientCommandCodec clientCommandCodec)
          Set the codec used to encode/decode client commands.
 void setDebug(boolean debug)
          Set the debugging status.
 void setMessageCodec(MessageCodec messageCodec)
          Set the codec used to encode/decode messages.
 void setMooServer(MooServer mooServer)
          Set the MooAPI server instance.
 
Methods inherited from class org.apache.mina.filter.codec.CumulativeProtocolDecoder
decode, dispose
 
Methods inherited from class org.apache.mina.filter.codec.ProtocolDecoderAdapter
finishDecode
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MooServerProtocolDecoder

public MooServerProtocolDecoder(MooServer mooServer)
Initialize.

Parameters:
mooServer - A MooAPI server instance.

MooServerProtocolDecoder

public MooServerProtocolDecoder()
Delegate initialization to the relevant property setters.

Method Detail

setMooServer

public void setMooServer(MooServer mooServer)
Set the MooAPI server instance.

Parameters:
mooServer - The MooAPI server.

setDebug

public void setDebug(boolean debug)
Set the debugging status.

Parameters:
debug - The debugging status.

setClientCommandCodec

public void setClientCommandCodec(ClientCommandCodec clientCommandCodec)
Set the codec used to encode/decode client commands.

Parameters:
clientCommandCodec - The client command codec.

setMessageCodec

public void setMessageCodec(MessageCodec messageCodec)
Set the codec used to encode/decode messages.

Parameters:
messageCodec - The message codec.

doDecode

protected boolean doDecode(org.apache.mina.common.IoSession session,
                           org.apache.mina.common.ByteBuffer in,
                           org.apache.mina.filter.codec.ProtocolDecoderOutput out)
                    throws java.lang.Exception
Parse a stream of bytes. On success, the bytes are consumed. Invalid commands are consumed but not used and cause an exception to be thrown. On failure caused by insufficient bytes, an exception is thrown and the buffer is left intact.

Specified by:
doDecode in class org.apache.mina.filter.codec.CumulativeProtocolDecoder
Parameters:
session - The MooAPI connection's peer.
in - The buffer containing encoded commands.
out - The protocol decoder.
Returns:
true to attempt to decode more bytes.
Throws:
java.lang.RuntimeException - On buffer underflow or an invalid command.
java.lang.Exception


Copyright © 2009. All Rights Reserved.