SocketObjectReader (Tomcat API Documentation)
Keywords: org.apache.catalina.cluster.io.SocketObjectReader class

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.catalina.cluster.io
Class SocketObjectReader

    java.lang.Object
      org.apache.catalina.cluster.io.SocketObjectReader

public class SocketObjectReader
extends java.lang.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. When a full package has been received, the append method will call messageDataReceived on the callback object associated with this object reader.
This object uses an XByteBuffer which is an extendable object buffer that also allows for message encoding and decoding.

Since:
  5.5.10
Version:
  $Id: SocketObjectReader.java 939539 2010-04-30 01:31:33Z kkolinko $
Author:
  Filip Hanik, Peter Rossbach

Constructor Summary
`SocketObjectReader(java.net.Socket socket, ListenCallback callback)` use this socket and callback to receive messages

Method Summary
`int` | `append(byte[] data, int off, int len)` Append new bytes to buffer.
`int` | `execute()` send message to callback
`int` | `write(byte[] data)` write data to socket (ack)

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### SocketObjectReader

    public SocketObjectReader(java.net.Socket socket,
                              ListenCallback callback)

  use this socket and callback to receive messages

Parameters:
  `socket` - listener socket
  `callback` - ClusterReceiverBase listener

Method Detail

### append

    public int append(byte[] data,
                      int off,
                      int len)
               throws java.io.IOException

  Append new bytes to buffer. Is message complete receiver send message to callback

  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:
    `ClusterReceiverBase.messageDataReceived(ClusterData)`, `XByteBuffer.doesPackageExist()`, `XByteBuffer.extractPackage(boolean)`

### execute

    public int execute()
                throws java.io.IOException

  send message to callback

  Returns:
    Count of packages written
  Throws:
    `java.io.IOException`
  See Also:
    `append(byte[], int, int)`

### write

    public int write(byte[] data)
              throws java.io.IOException

  write data to socket (ack)

  Parameters:
    `data` -
  Returns:
    Always zero
  Throws:
    `java.io.IOException`
  See Also:
    `ClusterReceiverBase.sendAck()`

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2000-2012 Apache Software Foundation. All Rights Reserved.