Пример #1
0
 /**
  * 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;
 }
 public byte[] getArray() {
   return buffer.getBytes();
 }
 public byte[] getArrayDirect() {
   return buffer.getBytesDirect();
 }
 public int size() {
   return buffer.getLength();
 }
 /**
  * Writes the specified byte to this output stream.
  *
  * @param b the <code>byte</code>.
  * @throws IOException if an I/O error occurs. In particular, an <code>IOException</code> may be
  *     thrown if the output stream has been closed.
  */
 public void write(int b) throws IOException {
   buffer.append((byte) b);
 }
Пример #6
0
 /**
  * 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;
 }
Пример #7
0
 /**
  * Returns the number of packages that the reader has read
  *
  * @return int
  */
 public int count() {
   return buffer.countPackages();
 }
Пример #8
0
 public boolean hasPackage() {
   return buffer.countPackages(true) > 0;
 }