Package org.apache.sshd.common.io.nio2
Class Nio2Service
- java.lang.Object
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
,java.nio.channels.Channel
,Closeable
,IoService
,IoServiceEventListenerManager
- Direct Known Subclasses:
Nio2Acceptor
,Nio2Connector
public abstract class Nio2Service extends AbstractInnerCloseable implements IoService
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.apache.sshd.common.util.closeable.AbstractCloseable
AbstractCloseable.State
-
-
Field Summary
Fields Modifier and Type Field Description static java.util.Map<Property<?>,java.util.AbstractMap.SimpleImmutableEntry<java.net.SocketOption<?>,java.lang.Object>>
CONFIGURABLE_OPTIONS
protected java.util.concurrent.atomic.AtomicBoolean
disposing
private IoServiceEventListener
eventListener
private java.util.concurrent.ExecutorService
executor
private java.nio.channels.AsynchronousChannelGroup
group
private IoHandler
handler
protected PropertyResolver
propertyResolver
protected java.util.Map<java.lang.Long,IoSession>
sessions
-
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
-
Fields inherited from interface org.apache.sshd.common.io.IoService
DEFAULT_REUSE_ADDRESS
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
Nio2Service(PropertyResolver propertyResolver, IoHandler handler, java.nio.channels.AsynchronousChannelGroup group, java.util.concurrent.ExecutorService resumeTasks)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
dispose()
protected java.nio.channels.AsynchronousChannelGroup
getChannelGroup()
protected java.util.concurrent.ExecutorService
getExecutorService()
protected Closeable
getInnerCloseable()
IoHandler
getIoHandler()
IoServiceEventListener
getIoServiceEventListener()
java.util.Map<java.lang.Long,IoSession>
getManagedSessions()
Returns the map of all sessions which are currently managed by this service.void
sessionClosed(Nio2Session session)
void
setIoServiceEventListener(IoServiceEventListener listener)
protected <T> boolean
setOption(java.nio.channels.NetworkChannel socket, Property<?> property, java.net.SocketOption<T> option, T defaultValue)
protected <S extends java.nio.channels.NetworkChannel>
SsetSocketOptions(S socket)
protected void
unmapSession(java.lang.Long sessionId)
-
Methods inherited from class org.apache.sshd.common.util.closeable.AbstractInnerCloseable
doCloseGracefully, doCloseImmediately
-
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, toString, wait, wait, wait
-
Methods inherited from interface org.apache.sshd.common.Closeable
addCloseFutureListener, close, close, isClosed, isClosing, isOpen, removeCloseFutureListener
-
-
-
-
Field Detail
-
CONFIGURABLE_OPTIONS
public static final java.util.Map<Property<?>,java.util.AbstractMap.SimpleImmutableEntry<java.net.SocketOption<?>,java.lang.Object>> CONFIGURABLE_OPTIONS
-
sessions
protected final java.util.Map<java.lang.Long,IoSession> sessions
-
disposing
protected final java.util.concurrent.atomic.AtomicBoolean disposing
-
propertyResolver
protected final PropertyResolver propertyResolver
-
handler
private final IoHandler handler
-
group
private final java.nio.channels.AsynchronousChannelGroup group
-
executor
private final java.util.concurrent.ExecutorService executor
-
eventListener
private IoServiceEventListener eventListener
-
-
Constructor Detail
-
Nio2Service
protected Nio2Service(PropertyResolver propertyResolver, IoHandler handler, java.nio.channels.AsynchronousChannelGroup group, java.util.concurrent.ExecutorService resumeTasks)
-
-
Method Detail
-
getIoServiceEventListener
public IoServiceEventListener getIoServiceEventListener()
- Specified by:
getIoServiceEventListener
in interfaceIoServiceEventListenerManager
-
setIoServiceEventListener
public void setIoServiceEventListener(IoServiceEventListener listener)
- Specified by:
setIoServiceEventListener
in interfaceIoServiceEventListenerManager
-
getChannelGroup
protected java.nio.channels.AsynchronousChannelGroup getChannelGroup()
-
getExecutorService
protected java.util.concurrent.ExecutorService getExecutorService()
-
getIoHandler
public IoHandler getIoHandler()
-
dispose
public void dispose()
-
getInnerCloseable
protected Closeable getInnerCloseable()
- Specified by:
getInnerCloseable
in classAbstractInnerCloseable
-
getManagedSessions
public java.util.Map<java.lang.Long,IoSession> getManagedSessions()
Description copied from interface:IoService
Returns the map of all sessions which are currently managed by this service. The key of map is theID
of the session.- Specified by:
getManagedSessions
in interfaceIoService
- Returns:
- the sessions. An empty collection if there's no session.
-
sessionClosed
public void sessionClosed(Nio2Session session)
-
unmapSession
protected void unmapSession(java.lang.Long sessionId)
-
setSocketOptions
protected <S extends java.nio.channels.NetworkChannel> S setSocketOptions(S socket) throws java.io.IOException
- Throws:
java.io.IOException
-
setOption
protected <T> boolean setOption(java.nio.channels.NetworkChannel socket, Property<?> property, java.net.SocketOption<T> option, T defaultValue) throws java.io.IOException
- Throws:
java.io.IOException
-
-