au.com.terabit.ssl
Class SSLAsynchChannel

java.lang.Object
  extended by au.com.terabit.jproactor.AsynchChannel
      extended by au.com.terabit.ssl.SSLAsynchChannel
All Implemented Interfaces:
AsynchChannelHandler, AsynchReadHandler, AsynchWriteHandler

public class SSLAsynchChannel
extends AsynchChannel
implements AsynchReadHandler, AsynchWriteHandler, AsynchChannelHandler

Author:
Alexander Libman, Yevgeny Libman Copyright © 2003 Terabit Pty Ltd. All rights reserved. Notes: We have deal with 3 type of buffers a) raw (network) buffers b) channel application data buffers c) user buffers From SSLEngine doc: " The SSLEngine produces/consumes complete SSL/TLS packets only, and does not store application data internally between calls to wrap()/unwrap(). " That explains why we have to support channel application data bufferes and can not exchange data between raw networks bufffers and user buffers.

Nested Class Summary
 
Nested classes/interfaces inherited from class au.com.terabit.jproactor.AsynchChannel
AsynchChannel.State
 
Field Summary
 
Fields inherited from class au.com.terabit.jproactor.AsynchChannel
m_channelState, m_lock, m_readInfo, m_readQue, m_writeInfo, m_writeQue
 
Constructor Summary
SSLAsynchChannel(boolean mode, javax.net.ssl.SSLContext ctx, AsynchChannelHandlerFactory usrFactory)
           
 
Method Summary
 void channelAttached(AsynchChannel channel)
          Notifies that this handler is associated with the TCPAsynchChannel instance.
 void channelClosed(AsynchChannel channel)
          Notifies that cnannel is closed.
protected  AsynchChannel finishAccept(OpAccept accept)
           
protected  boolean finishConnect(OpConnect op)
           
protected  int finishRead(OpRead op)
           
protected  int finishWrite(OpWrite op)
           
 void readCompleted(OpRead opRead)
          Notifies that read operation has finished.
protected  void startAccept(OpAccept op)
           
protected  boolean startClose()
           
protected  void startConnect(OpConnect op)
           
protected  void startRead(OpRead op)
           
 void startTimer(OpTimer op)
           
protected  void startWrite(OpWrite op)
           
 void writeCompleted(OpWrite opWrite)
          Notifies that write operation has finished.
 
Methods inherited from class au.com.terabit.jproactor.AsynchChannel
accept, checkForClose, close, connect, dispatchCompletions, enqueueOperation, executeListAndAdd, executeListAndDispatch, executeOp, executeOpAndAdd, getChannelHandler, isClosed, isCloseFinished, isCloseStarted, isConnected, isOpened, read_n, read, schedulerTimer, setChannelHandler, setClosing, setConnected, write_n, write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SSLAsynchChannel

public SSLAsynchChannel(boolean mode,
                        javax.net.ssl.SSLContext ctx,
                        AsynchChannelHandlerFactory usrFactory)
Method Detail

channelAttached

public void channelAttached(AsynchChannel channel)
                     throws java.lang.Exception
Description copied from interface: AsynchChannelHandler
Notifies that this handler is associated with the TCPAsynchChannel instance.

One AsynchHandler can be shared with multiple socket channels, e.g. chat server. This mehtod is called by TCPAsynchChannel.

Specified by:
channelAttached in interface AsynchChannelHandler
Parameters:
channel - a new channel that is associated with this protocol.
Throws:
java.lang.Exception

channelClosed

public void channelClosed(AsynchChannel channel)
                   throws java.lang.Exception
Description copied from interface: AsynchChannelHandler
Notifies that cnannel is closed.

Specified by:
channelClosed in interface AsynchChannelHandler
Parameters:
channel - asynchronous channel that was closed
Throws:
java.lang.Exception

readCompleted

public void readCompleted(OpRead opRead)
                   throws java.lang.Exception
Description copied from interface: AsynchReadHandler
Notifies that read operation has finished. Called by IOOperation.onComplete()

Specified by:
readCompleted in interface AsynchReadHandler
Throws:
java.lang.Exception

writeCompleted

public void writeCompleted(OpWrite opWrite)
                    throws java.lang.Exception
Description copied from interface: AsynchWriteHandler
Notifies that write operation has finished. Called by IOOperation.onComplete()

Specified by:
writeCompleted in interface AsynchWriteHandler
Throws:
java.lang.Exception

startClose

protected boolean startClose()
Specified by:
startClose in class AsynchChannel

startRead

protected void startRead(OpRead op)
                  throws java.lang.Exception
Specified by:
startRead in class AsynchChannel
Throws:
java.lang.Exception

startWrite

protected void startWrite(OpWrite op)
                   throws java.lang.Exception
Specified by:
startWrite in class AsynchChannel
Throws:
java.lang.Exception

startAccept

protected void startAccept(OpAccept op)
                    throws java.lang.Exception
Specified by:
startAccept in class AsynchChannel
Throws:
java.lang.Exception

startConnect

protected void startConnect(OpConnect op)
                     throws java.lang.Exception
Specified by:
startConnect in class AsynchChannel
Throws:
java.lang.Exception

startTimer

public void startTimer(OpTimer op)
                throws java.lang.Exception
Specified by:
startTimer in class AsynchChannel
Throws:
java.lang.Exception

finishRead

protected int finishRead(OpRead op)
                  throws java.lang.Exception
Specified by:
finishRead in class AsynchChannel
Returns:
> 0 number bytes read 0 not finished yet < 0 errors or end of data
Throws:
java.lang.Exception

finishWrite

protected int finishWrite(OpWrite op)
                   throws java.lang.Exception
Specified by:
finishWrite in class AsynchChannel
Returns:
> 0 number bytes written 0 not finished yet < 0 errors or peer closed
Throws:
java.lang.Exception

finishConnect

protected boolean finishConnect(OpConnect op)
                         throws java.lang.Exception
Specified by:
finishConnect in class AsynchChannel
Returns:
true if connect finished false if not may be to fix: 1 finished OK, 0 not finished yet -1 finished with errors
Throws:
java.lang.Exception

finishAccept

protected AsynchChannel finishAccept(OpAccept accept)
                              throws java.lang.Exception
Specified by:
finishAccept in class AsynchChannel
Returns:
new accepted AsynchChannel null not finished yet
Throws:
java.lang.Exception