Class ObjectReader
java.lang.Object
org.apache.catalina.tribes.io.ObjectReader
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.-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected booleanprotected longprotected static final StringManager -
Constructor Summary
ConstructorsConstructorDescriptionObjectReader(int packetSize) ObjectReader(Socket socket) Creates anObjectReaderfor a TCP socketObjectReader(SocketChannel channel) Creates anObjectReaderfor a TCP NIO socket channel -
Method Summary
Modifier and TypeMethodDescriptionvoidaccess()intappend(byte[] data, int off, int len, boolean count) intappend(ByteBuffer data, int len, boolean count) Append new bytes to buffer.intvoidclose()intcount()Returns the number of packages that the reader has readexecute()Send buffer to cluster listener (callback).voidfinish()longbooleanbooleanbooleanvoidsetCancelled(boolean cancelled) voidsetLastAccess(long lastAccess)
-
Field Details
-
sm
-
lastAccess
protected long lastAccess -
accessed
protected boolean accessed
-
-
Constructor Details
-
ObjectReader
public ObjectReader(int packetSize) -
ObjectReader
Creates anObjectReaderfor a TCP NIO socket channel- Parameters:
channel- - the channel to be read.
-
ObjectReader
Creates anObjectReaderfor a TCP socket- Parameters:
socket- Socket
-
-
Method Details
-
access
public void access() -
finish
public void finish() -
isAccessed
public boolean isAccessed() -
append
Append new bytes to buffer.- Parameters:
data- new transfer bufferlen- length in buffercount- whether to return the count- Returns:
- number of messages that was sent to callback (or -1 if count == false)
- See Also:
-
append
public int append(byte[] data, int off, int len, boolean count) -
execute
Send buffer to cluster listener (callback). Is message complete receiver send message to callback?- Returns:
- array of received packages/messages
- See Also:
-
bufferSize
public int bufferSize() -
hasPackage
public boolean hasPackage() -
count
public int count()Returns the number of packages that the reader has read- Returns:
- int
-
close
public void close() -
getLastAccess
public long getLastAccess() -
isCancelled
public boolean isCancelled() -
setLastAccess
public void setLastAccess(long lastAccess) -
setCancelled
public void setCancelled(boolean cancelled)
-