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

## org.apache.catalina.tribes.io
Class ObjectReader

    java.lang.Object
      org.apache.catalina.tribes.io.ObjectReader

    public class ObjectReader

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. This object uses an XByteBuffer which is an extendable object buffer that also allows for message encoding and decoding.

Version:
  $Id: ObjectReader.java 939515 2010-04-29 23:59:49Z kkolinko $
Author:
  Filip Hanik

Field Summary
`protected boolean` | `accessed`
`protected long` | `lastAccess`
`protected static Log` | `log`

Constructor Summary
`ObjectReader(java.net.Socket socket)` Creates an `ObjectReader` for a TCP socket
`ObjectReader(java.nio.channels.SocketChannel channel)` Creates an `ObjectReader` for a TCP NIO socket channel

Method Summary
`void` | `access()`
`int` | `append(byte[] data, int off, int len, boolean count)`
`int` | `append(java.nio.ByteBuffer data, int len, boolean count)` Append new bytes to buffer.
`int` | `bufferSize()`
`void` | `close()`
`int` | `count()` Returns the number of packages that the reader has read
`ChannelMessage[]` | `execute()` Send buffer to cluster listener (callback).
`void` | `finish()`
`long` | `getLastAccess()`
`boolean` | `hasPackage()`
`boolean` | `isAccessed()`
`boolean` | `isCancelled()`
`void` | `setCancelled(boolean cancelled)`
`void` | `setLastAccess(long lastAccess)`

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

Field Detail

### log

    protected static Log log

### lastAccess

    protected long lastAccess

### accessed

    protected boolean accessed

Constructor Detail

### ObjectReader

    public ObjectReader(java.nio.channels.SocketChannel channel)

  Creates an `ObjectReader` for a TCP NIO socket channel

  Parameters:
    `channel` - - the channel to be read.

### ObjectReader

    public ObjectReader(java.net.Socket socket)

  Creates an `ObjectReader` for a TCP socket

  Parameters:
    `socket` - Socket

Method Detail

### access

    public void access()

### finish

    public void finish()

### isAccessed

    public boolean isAccessed()

### append

    public int append(java.nio.ByteBuffer data,
                      int len,
                      boolean count)
               throws java.io.IOException

  Append new bytes to buffer.

  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:
    `XByteBuffer.countPackages()`

### append

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

  Throws:
    `java.io.IOException`

### execute

    public ChannelMessage[] execute()
                             throws java.io.IOException

  Send buffer to cluster listener (callback). Is message complete receiver send message to callback?

  Returns:
    number of received packages/messages
  Throws:
    `java.io.IOException`
  See Also:
    `org.apache.catalina.tribes.transport.ClusterReceiverBase#messageDataReceived(ChannelMessage)`, `XByteBuffer.doesPackageExist()`, `XByteBuffer.extractPackage(boolean)`

### 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)

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

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