org.apache.activemq.apollo.transport
Interface ProtocolCodec

All Known Implementing Classes:
ObjectStreamProtocolCodec

public interface ProtocolCodec

Interface to encode and decode commands in and out of a a non blocking channel.

Author:
Hiram Chirino

Nested Class Summary
static class ProtocolCodec.BufferState
           
 
Method Summary
 ProtocolCodec.BufferState flush()
          Attempts to complete the previous write which did not complete.
 long getReadCounter()
           
 long getWriteCounter()
           
 java.lang.String protocol()
           
 java.lang.Object read()
          Non-blocking channel based decoding.
 void setReadableByteChannel(java.nio.channels.ReadableByteChannel channel)
           
 void setWritableByteChannel(java.nio.channels.WritableByteChannel channel)
           
 void unread(org.fusesource.hawtbuf.Buffer buffer)
          Pushes back a buffer as being unread.
 ProtocolCodec.BufferState write(java.lang.Object value)
          Non-blocking channel based encoding.
 

Method Detail

protocol

java.lang.String protocol()
Returns:
The name of the protocol associated with the the channel codec.

setReadableByteChannel

void setReadableByteChannel(java.nio.channels.ReadableByteChannel channel)
Parameters:
channel -

read

java.lang.Object read()
                      throws java.io.IOException
Non-blocking channel based decoding.

Returns:
Throws:
java.io.IOException

unread

void unread(org.fusesource.hawtbuf.Buffer buffer)
Pushes back a buffer as being unread. The protocol discriminator may do this before before any reads occur.

Parameters:
buffer -

getReadCounter

long getReadCounter()
Returns:
The number of bytes received.

setWritableByteChannel

void setWritableByteChannel(java.nio.channels.WritableByteChannel channel)

write

ProtocolCodec.BufferState write(java.lang.Object value)
                                throws java.io.IOException
Non-blocking channel based encoding.

Returns:
true if the write completed.
Throws:
java.io.IOException

flush

ProtocolCodec.BufferState flush()
                                throws java.io.IOException
Attempts to complete the previous write which did not complete.

Returns:
Throws:
java.io.IOException

getWriteCounter

long getWriteCounter()
Returns:
The number of bytes written.


Copyright © 2005-2011 The Apache Software Foundation. All Rights Reserved.