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_OPTIONSprotected java.util.concurrent.atomic.AtomicBooleandisposingprivate IoServiceEventListenereventListenerprivate java.util.concurrent.ExecutorServiceexecutorprivate java.nio.channels.AsynchronousChannelGroupgroupprivate IoHandlerhandlerprivate booleannoMoreSessionsprotected PropertyResolverpropertyResolverprotected 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 protectedNio2Service(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 voiddispose()protected java.nio.channels.AsynchronousChannelGroupgetChannelGroup()protected java.util.concurrent.ExecutorServicegetExecutorService()protected CloseablegetInnerCloseable()IoHandlergetIoHandler()IoServiceEventListenergetIoServiceEventListener()java.util.Map<java.lang.Long,IoSession>getManagedSessions()Returns the map of all sessions which are currently managed by this service.protected IoSessionmapSession(IoSession session)voidsessionClosed(Nio2Session session)voidsetIoServiceEventListener(IoServiceEventListener listener)protected <T> booleansetOption(java.nio.channels.NetworkChannel socket, Property<?> property, java.net.SocketOption<T> option, T defaultValue)protected <S extends java.nio.channels.NetworkChannel>
SsetSocketOptions(S socket)private java.util.Collection<IoSession>snapshot()protected voidunmapSession(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
-
noMoreSessions
private boolean noMoreSessions
-
-
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:
getIoServiceEventListenerin interfaceIoServiceEventListenerManager
-
setIoServiceEventListener
public void setIoServiceEventListener(IoServiceEventListener listener)
- Specified by:
setIoServiceEventListenerin 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:
getInnerCloseablein classAbstractInnerCloseable
-
getManagedSessions
public java.util.Map<java.lang.Long,IoSession> getManagedSessions()
Description copied from interface:IoServiceReturns the map of all sessions which are currently managed by this service. The key of map is theIDof the session.- Specified by:
getManagedSessionsin interfaceIoService- Returns:
- the sessions. An empty collection if there's no session.
-
sessionClosed
public void sessionClosed(Nio2Session session)
-
snapshot
private java.util.Collection<IoSession> snapshot()
-
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
-
-