Package org.apache.sshd.common.io.nio2
Class Nio2Session
java.lang.Object
org.apache.sshd.common.util.logging.AbstractLoggingBean
org.apache.sshd.common.util.closeable.IoBaseCloseable
org.apache.sshd.common.util.closeable.AbstractCloseable
org.apache.sshd.common.io.nio2.Nio2Session
- All Implemented Interfaces:
Closeable
,AutoCloseable
,Channel
,Closeable
,IoSession
,ConnectionEndpointsIndicator
- Author:
- Apache MINA SSHD Project
-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.sshd.common.util.closeable.AbstractCloseable
AbstractCloseable.State
-
Field Summary
Fields inherited from class org.apache.sshd.common.util.closeable.AbstractCloseable
closeFuture, futureLock, state
Fields inherited from class org.apache.sshd.common.util.logging.AbstractLoggingBean
log
-
Constructor Summary
ConstructorDescriptionNio2Session
(Nio2Service service, PropertyResolver propertyResolver, IoHandler handler, AsynchronousSocketChannel socket, SocketAddress acceptanceAddress) -
Method Summary
Modifier and TypeMethodDescriptionprotected Nio2CompletionHandler<Integer,
Object> createReadCycleCompletionHandler
(ByteBuffer buffer, Readable bufReader) protected Nio2CompletionHandler<Integer,
Object> createWriteCycleCompletionHandler
(Nio2DefaultIoWriteFuture future, AsynchronousSocketChannel socket, ByteBuffer buffer) protected CloseFuture
protected void
protected void
doReadCycle
(ByteBuffer buffer, Nio2CompletionHandler<Integer, Object> completion) protected void
doReadCycle
(ByteBuffer buffer, Readable bufReader) protected void
doShutdownOutputStream
(Nio2DefaultIoWriteFuture future, AsynchronousSocketChannel socket) protected void
doWriteCycle
(ByteBuffer buffer, Nio2CompletionHandler<Integer, Object> completion) protected void
exceptionCaught
(Throwable exc) protected void
finishWrite
(Nio2DefaultIoWriteFuture future) getAttribute
(Object key) long
getId()
protected void
handleCompletedWriteCycle
(Nio2DefaultIoWriteFuture future, AsynchronousSocketChannel socket, ByteBuffer buffer, int writeLen, Nio2CompletionHandler<Integer, Object> completionHandler, Integer result, Object attachment) protected void
handleReadCycleCompletion
(ByteBuffer buffer, Readable bufReader, Nio2CompletionHandler<Integer, Object> completionHandler, Integer result, Object attachment) protected void
handleReadCycleFailure
(ByteBuffer buffer, Readable bufReader, Throwable exc, Object attachment) protected void
handleWriteCycleFailure
(Nio2DefaultIoWriteFuture future, AsynchronousSocketChannel socket, ByteBuffer buffer, int writeLen, Throwable exc, Object attachment) removeAttribute
(Object key) void
setAttribute
(Object key, Object value) setAttributeIfAbsent
(Object key, Object value) void
void
void
startReading
(byte[] buf) void
startReading
(byte[] buf, int offset, int len) void
startReading
(int bufSize) void
startReading
(ByteBuffer buffer) protected void
void
suspend()
Intended for tests simulating a sudden connection drop only! Do not call otherwise.void
toString()
writeBuffer
(Buffer buffer) Methods inherited from class org.apache.sshd.common.util.closeable.AbstractCloseable
addCloseFutureListener, builder, close, getFutureLock, isClosed, isClosing, preClose, removeCloseFutureListener
Methods inherited from class org.apache.sshd.common.util.logging.AbstractLoggingBean
debug, debug, debug, debug, debug, error, error, error, error, error, getSimplifiedLogger, info, info, warn, warn, warn, warn, warn, warn, warn, warn
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.apache.sshd.common.Closeable
addCloseFutureListener, close, isClosed, isClosing, isOpen, removeCloseFutureListener
-
Field Details
-
DEFAULT_READBUF_SIZE
public static final int DEFAULT_READBUF_SIZE- See Also:
-
-
Constructor Details
-
Nio2Session
public Nio2Session(Nio2Service service, PropertyResolver propertyResolver, IoHandler handler, AsynchronousSocketChannel socket, SocketAddress acceptanceAddress) throws IOException - Throws:
IOException
-
-
Method Details
-
getId
public long getId() -
getAttribute
- Specified by:
getAttribute
in interfaceIoSession
-
setAttribute
- Specified by:
setAttribute
in interfaceIoSession
-
setAttributeIfAbsent
- Specified by:
setAttributeIfAbsent
in interfaceIoSession
-
removeAttribute
- Specified by:
removeAttribute
in interfaceIoSession
-
getRemoteAddress
- Specified by:
getRemoteAddress
in interfaceConnectionEndpointsIndicator
-
getLocalAddress
- Specified by:
getLocalAddress
in interfaceConnectionEndpointsIndicator
-
getAcceptanceAddress
- Specified by:
getAcceptanceAddress
in interfaceIoSession
-
getSocket
-
getIoHandler
-
suspend
public void suspend()Intended for tests simulating a sudden connection drop only! Do not call otherwise. -
writeBuffer
- Specified by:
writeBuffer
in interfaceIoSession
- Throws:
IOException
-
exceptionCaught
-
doCloseGracefully
- Overrides:
doCloseGracefully
in classAbstractCloseable
-
doCloseImmediately
protected void doCloseImmediately()- Overrides:
doCloseImmediately
in classAbstractCloseable
-
getService
- Specified by:
getService
in interfaceIoSession
-
shutdownOutputStream
- Specified by:
shutdownOutputStream
in interfaceIoSession
- Throws:
IOException
-
doShutdownOutputStream
protected void doShutdownOutputStream(Nio2DefaultIoWriteFuture future, AsynchronousSocketChannel socket) throws IOException - Throws:
IOException
-
startReading
public void startReading() -
startReading
public void startReading(int bufSize) -
startReading
public void startReading(byte[] buf) -
startReading
public void startReading(byte[] buf, int offset, int len) -
startReading
-
doReadCycle
-
createReadCycleCompletionHandler
protected Nio2CompletionHandler<Integer,Object> createReadCycleCompletionHandler(ByteBuffer buffer, Readable bufReader) -
handleReadCycleCompletion
protected void handleReadCycleCompletion(ByteBuffer buffer, Readable bufReader, Nio2CompletionHandler<Integer, Object> completionHandler, Integer result, Object attachment) -
handleReadCycleFailure
protected void handleReadCycleFailure(ByteBuffer buffer, Readable bufReader, Throwable exc, Object attachment) -
suspendRead
public void suspendRead()- Specified by:
suspendRead
in interfaceIoSession
-
resumeRead
public void resumeRead()- Specified by:
resumeRead
in interfaceIoSession
-
doReadCycle
-
startWriting
protected void startWriting() -
doWriteCycle
-
createWriteCycleCompletionHandler
protected Nio2CompletionHandler<Integer,Object> createWriteCycleCompletionHandler(Nio2DefaultIoWriteFuture future, AsynchronousSocketChannel socket, ByteBuffer buffer) -
handleCompletedWriteCycle
protected void handleCompletedWriteCycle(Nio2DefaultIoWriteFuture future, AsynchronousSocketChannel socket, ByteBuffer buffer, int writeLen, Nio2CompletionHandler<Integer, Object> completionHandler, Integer result, Object attachment) -
handleWriteCycleFailure
protected void handleWriteCycleFailure(Nio2DefaultIoWriteFuture future, AsynchronousSocketChannel socket, ByteBuffer buffer, int writeLen, Throwable exc, Object attachment) -
finishWrite
-
toString
-