Here's my doDecode(), HTH:

   @Override
   protected boolean doDecode(IoSession session, ByteBuffer in,
ProtocolDecoderOutput out) throws Exception {

       Part1 part1 = null;
       Part2 part2 = null;
       ByteBuffer contentBuffer = null;
       MessageType messageType = null;

       try {
           part1 = getPart1(in);
           part2 = getPart2(in);


           byte[] messageTypeBytes = getTlv(in, CONTENT_TYPE_TAG);
           int messageTypeCode = byteArrayToInt(messageTypeBytes);
           messageType = MessageType.getMessageType(messageTypeCode);
           if(messageType == null) {
               throw new DecoderException("unknown message type code " +
messageTypeCode);
           }

           // TODO see if we can avoid using arrays and stay with the
buffer
           int contentLength = byteArrayToInt(getTlv(in,
CONTENT_LENGTH_TAG));
           if (contentLength > 0) {
               byte[] contentBytes = new byte[contentLength];
               in.get(contentBytes);

               contentBuffer = ByteBuffer.allocate(contentLength);
               contentBuffer.put(contentBytes);
               contentBuffer.flip();
           }

       } catch (BufferUnderflowException  e) {
           in.rewind();
           return false;
       }

       Message message;
       try {
           message = new Message(messageType, transportBinding,
sessionBinding, contentBuffer);
       } catch (Throwable e){
           String errStr = "while creating a new message";
           logger.error(errStr);
           throw new DecoderException(errStr, e);
       }

       if (contentBuffer != null) {
           contentBuffer.release();
       }

       out.write(message);

       return true;
   }


On 8/8/06, Paul Chen <[EMAIL PROTECTED]> wrote:

Hi, folks,

If you have one that you can share, that's much appreciated.
We are facing a lot of issues with it such as Unregisterable
type exception or server hang...

Thanks a bunch


Reply via email to