net.sf.asyncobjects.net.nio
Class NIOStream<T extends ACloseable>

java.lang.Object
  extended by net.sf.asyncobjects.AsyncUnicastServer<T>
      extended by net.sf.asyncobjects.net.nio.NIOStream<T>
Type Parameters:
T - input or output stream
All Implemented Interfaces:
ACloseable, AsyncObject, ExplicitSharing
Direct Known Subclasses:
NIOSocketInputStream, NIOSocketOutputStream

public abstract class NIOStream<T extends ACloseable>
extends AsyncUnicastServer<T>
implements ACloseable

Base class for NIO Streams. The class implemetns common initalization logic.

Author:
const

Field Summary
protected  boolean isClosed
          if true the stream is considered to be closed
 
Method Summary
 void awake()
          awake signal
 Promise<Void> close()
          Close stream
protected  void ensureOpen()
          Ensure that stream is open
protected  ByteBuffer getDirectBuffer()
           
protected  void returnDirectBuffer(ByteBuffer buffer)
          Return buffer to the runner
protected abstract  void shutdownStream()
          Shutdown stream
 
Methods inherited from class net.sf.asyncobjects.AsyncUnicastServer
dereference, export, isImmediate, myVat, promise
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface net.sf.asyncobjects.AsyncObject
dereference, isImmediate
 

Field Detail

isClosed

protected boolean isClosed
if true the stream is considered to be closed

Method Detail

awake

public void awake()
awake signal


shutdownStream

protected abstract void shutdownStream()
                                throws IOException
Shutdown stream

Throws:
IOException - if there is a problem with shutdowing

close

public Promise<Void> close()
Close stream

Specified by:
close in interface ACloseable
Returns:
a promise that resolves to null or breaks with exception.

ensureOpen

protected void ensureOpen()
Ensure that stream is open


getDirectBuffer

protected ByteBuffer getDirectBuffer()
Returns:
the direct buffer from runner

returnDirectBuffer

protected void returnDirectBuffer(ByteBuffer buffer)
Return buffer to the runner

Parameters:
buffer - a buffer to return


Copyright © 2002-2007 Constantine Plotnikov. All Rights Reserved.