org.apache.catalina.tribes.io

Class ObjectReader

public class ObjectReader extends Object

The object reader object is an object used in conjunction with java.nio TCP messages. This object stores the message bytes in a XByteBuffer until a full package has been received. This object uses an XByteBuffer which is an extendable object buffer that also allows for message encoding and decoding.

Version: $Revision: 467173 $, $Date: 2006-10-24 01:12:17 +0200 (Tue, 24 Oct 2006) $

Author: Filip Hanik

Field Summary
protected booleanaccessed
protected longlastAccess
protected static Loglog
Constructor Summary
ObjectReader(SocketChannel channel)
Creates an ObjectReader for a TCP NIO socket channel
ObjectReader(Socket socket)
Creates an ObjectReader for a TCP socket
Method Summary
voidaccess()
intappend(ByteBuffer data, int len, boolean count)
Append new bytes to buffer.
intappend(byte[] data, int off, int len, boolean count)
intbufferSize()
voidclose()
intcount()
Returns the number of packages that the reader has read
ChannelMessage[]execute()
Send buffer to cluster listener (callback).
voidfinish()
longgetLastAccess()
booleanhasPackage()
booleanisAccessed()
booleanisCancelled()
voidsetCancelled(boolean cancelled)
voidsetLastAccess(long lastAccess)

Field Detail

accessed

protected boolean accessed

lastAccess

protected long lastAccess

log

protected static Log log

Constructor Detail

ObjectReader

public ObjectReader(SocketChannel channel)
Creates an ObjectReader for a TCP NIO socket channel

Parameters: channel - the channel to be read.

ObjectReader

public ObjectReader(Socket socket)
Creates an ObjectReader for a TCP socket

Parameters: socket Socket

Method Detail

access

public void access()

append

public int append(ByteBuffer data, int len, boolean count)
Append new bytes to buffer.

Parameters: data new transfer buffer off offset len length in buffer

Returns: number of messages that sended to callback

Throws: java.io.IOException

See Also: countPackages

append

public int append(byte[] data, int off, int len, boolean count)

bufferSize

public int bufferSize()

close

public void close()

count

public int count()
Returns the number of packages that the reader has read

Returns: int

execute

public ChannelMessage[] execute()
Send buffer to cluster listener (callback). Is message complete receiver send message to callback?

Returns: number of received packages/messages

Throws: java.io.IOException

See Also: org.apache.catalina.tribes.transport.ClusterReceiverBase#messageDataReceived(ChannelMessage) doesPackageExist

finish

public void finish()

getLastAccess

public long getLastAccess()

hasPackage

public boolean hasPackage()

isAccessed

public boolean isAccessed()

isCancelled

public boolean isCancelled()

setCancelled

public void setCancelled(boolean cancelled)

setLastAccess

public void setLastAccess(long lastAccess)
Copyright © 2000-2011 Apache Software Foundation. All Rights Reserved.