@ManagedObject(value="Manager of the NIO Selectors") public abstract class SelectorManager extends ContainerLifeCycle implements Dumpable
SelectorManager manages a number of ManagedSelectors that
simplify the non-blocking primitives provided by the JVM via the java.nio package.
SelectorManager subclasses implement methods to return protocol-specific
EndPoints and Connections.
| Modifier and Type | Class and Description |
|---|---|
static interface |
SelectorManager.AcceptListener
A listener for accept events.
|
AbstractLifeCycle.AbstractLifeCycleListenerContainer.InheritedListener, Container.ListenerLifeCycle.Listener| Modifier and Type | Field and Description |
|---|---|
static int |
DEFAULT_CONNECT_TIMEOUT |
| Modifier and Type | Method and Description |
|---|---|
void |
accept(SelectableChannel channel) |
void |
accept(SelectableChannel channel,
Object attachment)
Registers a channel to perform non-blocking read/write operations.
|
Closeable |
acceptor(SelectableChannel server)
Registers a server channel for accept operations.
|
void |
addAcceptListener(SelectorManager.AcceptListener listener) |
void |
addEventListener(EventListener listener) |
void |
connect(SelectableChannel channel,
Object attachment)
Registers a channel to perform a non-blocking connect.
|
void |
connectionClosed(Connection connection)
Callback method invoked when a connection is closed.
|
void |
connectionOpened(Connection connection)
Callback method invoked when a connection is opened.
|
long |
getConnectTimeout()
Get the connect timeout
|
Executor |
getExecutor() |
int |
getReservedThreads()
Deprecated.
|
Scheduler |
getScheduler() |
int |
getSelectorCount() |
abstract Connection |
newConnection(SelectableChannel channel,
EndPoint endpoint,
Object attachment)
Factory method to create
Connection. |
void |
removeAcceptListener(SelectorManager.AcceptListener listener) |
void |
removeEventListener(EventListener listener) |
void |
setConnectTimeout(long milliseconds)
Set the connect timeout (in milliseconds)
|
void |
setReservedThreads(int threads)
Deprecated.
|
addBean, addBean, addEventListener, addManaged, contains, destroy, dump, dump, dump, dump, dump, dumpObject, dumpStdErr, getBean, getBeans, getBeans, getContainedBeans, isAuto, isManaged, isUnmanaged, manage, removeBean, removeBeans, removeEventListener, setBeans, setStopTimeout, unmanage, updateBean, updateBean, updateBeansaddLifeCycleListener, getState, getState, getStopTimeout, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, start, stop, toStringequals, getClass, hashCode, notify, notifyAll, wait, wait, waitdump, dump, dump, dumpContainer, dumpIterable, dumpMapEntries, dumpObject, dumpObjects, dumpSelf, namedpublic static final int DEFAULT_CONNECT_TIMEOUT
@ManagedAttribute(value="The Executor") public Executor getExecutor()
@ManagedAttribute(value="The Scheduler") public Scheduler getScheduler()
@ManagedAttribute(value="The Connection timeout (ms)") public long getConnectTimeout()
public void setConnectTimeout(long milliseconds)
milliseconds - the number of milliseconds for the timeout@Deprecated public int getReservedThreads()
@Deprecated public void setReservedThreads(int threads)
threads - ignored@ManagedAttribute(value="The number of NIO Selectors") public int getSelectorCount()
public void connect(SelectableChannel channel, Object attachment)
Registers a channel to perform a non-blocking connect.
The channel must be set in non-blocking mode, SocketChannel.connect(SocketAddress)
must be called prior to calling this method, and the connect operation must not be completed
(the return value of SocketChannel.connect(SocketAddress) must be false).
channel - the channel to registerattachment - the attachment objectaccept(SelectableChannel, Object)public void accept(SelectableChannel channel)
channel - the channel to acceptaccept(SelectableChannel, Object)public void accept(SelectableChannel channel, Object attachment)
Registers a channel to perform non-blocking read/write operations.
This method is called just after a channel has been accepted by ServerSocketChannel.accept(),
or just after having performed a blocking connect via Socket.connect(SocketAddress, int), or
just after a non-blocking connect via SocketChannel.connect(SocketAddress) that completed
successfully.
channel - the channel to registerattachment - the attachment objectpublic Closeable acceptor(SelectableChannel server)
Registers a server channel for accept operations.
When a SocketChannel is accepted from the given ServerSocketChannel
then the accepted(SelectableChannel) method is called, which must be
overridden by a derivation of this class to handle the accepted channel
server - the server channel to registerpublic void connectionOpened(Connection connection)
Callback method invoked when a connection is opened.
connection - the connection just openedpublic void connectionClosed(Connection connection)
Callback method invoked when a connection is closed.
connection - the connection just closedpublic abstract Connection newConnection(SelectableChannel channel, EndPoint endpoint, Object attachment) throws IOException
Factory method to create Connection.
channel - the channel associated to the connectionendpoint - the endpointattachment - the attachmentIOException - if unable to create new connectionpublic void addEventListener(EventListener listener)
public void removeEventListener(EventListener listener)
public void addAcceptListener(SelectorManager.AcceptListener listener)
public void removeAcceptListener(SelectorManager.AcceptListener listener)
Copyright © 2010 - 2020 Adobe. All Rights Reserved