/** * Send buffer to cluster listener (callback). Is message complete receiver send message to * callback? * * @see org.apache.catalina.tribes.transport.ReceiverBase#messageDataReceived(ChannelMessage) * @see XByteBuffer#doesPackageExist() * @see XByteBuffer#extractPackage(boolean) * @return number of received packages/messages * @throws java.io.IOException */ public ChannelMessage[] execute() throws java.io.IOException { int pkgCnt = buffer.countPackages(); ChannelMessage[] result = new ChannelMessage[pkgCnt]; for (int i = 0; i < pkgCnt; i++) { ChannelMessage data = buffer.extractPackage(true); result[i] = data; } return result; }
/** * Append new bytes to buffer. * * @see XByteBuffer#countPackages() * @param data new transfer buffer * @param len length in buffer * @return number of messages that sent to callback * @throws java.io.IOException */ public int append(ByteBuffer data, int len, boolean count) throws java.io.IOException { buffer.append(data, len); int pkgCnt = -1; if (count) pkgCnt = buffer.countPackages(); return pkgCnt; }
/** * Returns the number of packages that the reader has read * * @return int */ public int count() { return buffer.countPackages(); }
public boolean hasPackage() { return buffer.countPackages(true) > 0; }