Package org.apache.catalina.tribes.io
Class ObjectReader
- java.lang.Object
- 
- org.apache.catalina.tribes.io.ObjectReader
 
- 
 public class ObjectReader extends java.lang.ObjectThe object reader object is an object used in conjunction with java.nio TCP messages. This object stores the message bytes in aXByteBufferuntil 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 SummaryFields Modifier and Type Field Description protected booleanaccessedprotected longlastAccessprotected static StringManagersm
 - 
Constructor SummaryConstructors Constructor Description ObjectReader(int packetSize)ObjectReader(java.net.Socket socket)Creates anObjectReaderfor a TCP socketObjectReader(java.nio.channels.SocketChannel channel)Creates anObjectReaderfor a TCP NIO socket channel
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaccess()intappend(byte[] data, int off, int len, boolean count)intappend(java.nio.ByteBuffer data, int len, boolean count)Append new bytes to buffer.intbufferSize()voidclose()intcount()Returns the number of packages that the reader has readChannelMessage[]execute()Send buffer to cluster listener (callback).voidfinish()longgetLastAccess()booleanhasPackage()booleanisAccessed()booleanisCancelled()voidsetCancelled(boolean cancelled)voidsetLastAccess(long lastAccess)
 
- 
- 
- 
Field Detail- 
smprotected static final StringManager sm 
 - 
lastAccessprotected long lastAccess 
 - 
accessedprotected boolean accessed 
 
- 
 - 
Constructor Detail- 
ObjectReaderpublic ObjectReader(int packetSize) 
 - 
ObjectReaderpublic ObjectReader(java.nio.channels.SocketChannel channel) Creates anObjectReaderfor a TCP NIO socket channel- Parameters:
- channel- - the channel to be read.
 
 - 
ObjectReaderpublic ObjectReader(java.net.Socket socket) Creates anObjectReaderfor a TCP socket- Parameters:
- socket- Socket
 
 
- 
 - 
Method Detail- 
accesspublic void access() 
 - 
finishpublic void finish() 
 - 
isAccessedpublic boolean isAccessed() 
 - 
appendpublic int append(java.nio.ByteBuffer data, int len, boolean count)Append new bytes to buffer.- Parameters:
- data- new transfer buffer
- len- length in buffer
- count- whether to return the count
- Returns:
- number of messages that was sent to callback (or -1 if count == false)
- See Also:
- XByteBuffer.countPackages()
 
 - 
appendpublic int append(byte[] data, int off, int len, boolean count)
 - 
executepublic ChannelMessage[] execute() Send buffer to cluster listener (callback). Is message complete receiver send message to callback?- Returns:
- number of received packages/messages
- See Also:
- ReceiverBase.messageDataReceived(ChannelMessage),- XByteBuffer.doesPackageExist(),- XByteBuffer.extractPackage(boolean)
 
 - 
bufferSizepublic int bufferSize() 
 - 
hasPackagepublic boolean hasPackage() 
 - 
countpublic int count() Returns the number of packages that the reader has read- Returns:
- int
 
 - 
closepublic void close() 
 - 
getLastAccesspublic long getLastAccess() 
 - 
isCancelledpublic boolean isCancelled() 
 - 
setLastAccesspublic void setLastAccess(long lastAccess) 
 - 
setCancelledpublic void setCancelled(boolean cancelled) 
 
- 
 
-