public final class NioDatagramAcceptor extends AbstractIoAcceptor implements DatagramAcceptor, IoProcessor<NioSession>
IoAcceptor for datagram transport (UDP/IP).AbstractIoAcceptor.AcceptorOperationFutureAbstractIoService.ServiceOperationFuturebindLockdisposalLock, LOGGER, sessionConfig| Constructor and Description |
|---|
NioDatagramAcceptor()
Creates a new instance.
|
NioDatagramAcceptor(Executor executor)
Creates a new instance.
|
| Modifier and Type | Method and Description |
|---|---|
void |
add(NioSession session)
Adds the specified
session to the I/O processor so that
the I/O processor starts to perform any I/O operations related
with the session. |
protected Set<SocketAddress> |
bindInternal(List<? extends SocketAddress> localAddresses)
Starts the acceptor, and register the given addresses
|
protected void |
close(DatagramChannel handle) |
protected void |
destroy() |
protected void |
dispose0()
Implement this method to release any acquired resources.
|
void |
flush(NioSession session)
Flushes the internal write request queue of the specified
session. |
InetSocketAddress |
getDefaultLocalAddress()
Returns the default local address to bind when no argument is specified
in
IoAcceptor.bind() method. |
InetSocketAddress |
getLocalAddress()
Returns the local address which is bound currently.
|
DatagramSessionConfig |
getSessionConfig() |
IoSessionRecycler |
getSessionRecycler() |
TransportMetadata |
getTransportMetadata() |
protected void |
init() |
protected boolean |
isReadable(DatagramChannel handle) |
protected boolean |
isWritable(DatagramChannel handle) |
protected SocketAddress |
localAddress(DatagramChannel handle) |
protected NioSession |
newSession(IoProcessor<NioSession> processor,
DatagramChannel handle,
SocketAddress remoteAddress) |
IoSession |
newSession(SocketAddress remoteAddress,
SocketAddress localAddress)
(Optional) Returns an
IoSession that is bound to the specified
localAddress and the specified remoteAddress which
reuses the local address that is already bound by this service. |
protected DatagramChannel |
open(SocketAddress localAddress) |
protected SocketAddress |
receive(DatagramChannel handle,
IoBuffer buffer) |
void |
remove(NioSession session)
Removes and closes the specified
session from the I/O
processor so that the I/O processor closes the connection
associated with the session and releases any other related
resources. |
protected int |
select() |
protected int |
select(long timeout) |
protected Set<SelectionKey> |
selectedHandles() |
protected int |
send(NioSession session,
IoBuffer buffer,
SocketAddress remoteAddress) |
void |
setDefaultLocalAddress(InetSocketAddress localAddress)
Sets the default local InetSocketAddress to bind when no argument is specified in
IoAcceptor.bind() method. |
protected void |
setInterestedInWrite(NioSession session,
boolean isInterested) |
void |
setSessionRecycler(IoSessionRecycler sessionRecycler)
Sets the
IoSessionRecycler for this service. |
protected void |
unbind0(List<? extends SocketAddress> localAddresses)
Implement this method to perform the actual unbind operation.
|
void |
updateTrafficControl(NioSession session)
Controls the traffic of the specified
session depending of the
IoSession.isReadSuspended() and IoSession.isWriteSuspended()
flags |
protected void |
wakeup() |
void |
write(NioSession session,
WriteRequest writeRequest)
Writes the WriteRequest for the specified
session. |
bind, bind, bind, bind, bind, getDefaultLocalAddresses, getLocalAddresses, isCloseOnDeactivation, setCloseOnDeactivation, setDefaultLocalAddress, setDefaultLocalAddresses, setDefaultLocalAddresses, setDefaultLocalAddresses, toString, unbind, unbind, unbind, unbindaddListener, broadcast, dispose, dispose, executeWorker, executeWorker, finishSessionInitialization0, getActivationTime, getFilterChain, getFilterChainBuilder, getHandler, getListeners, getManagedSessionCount, getManagedSessions, getScheduledWriteBytes, getScheduledWriteMessages, getSessionDataStructureFactory, getStatistics, initSession, isActive, isDisposed, isDisposing, removeListener, setFilterChainBuilder, setHandler, setSessionDataStructureFactoryclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitbind, bind, bind, bind, bind, getDefaultLocalAddresses, getLocalAddresses, isCloseOnDeactivation, setCloseOnDeactivation, setDefaultLocalAddress, setDefaultLocalAddresses, setDefaultLocalAddresses, setDefaultLocalAddresses, unbind, unbind, unbind, unbindaddListener, broadcast, dispose, dispose, getActivationTime, getFilterChain, getFilterChainBuilder, getHandler, getManagedSessionCount, getManagedSessions, getScheduledWriteBytes, getScheduledWriteMessages, getSessionDataStructureFactory, getStatistics, isActive, isDisposed, isDisposing, removeListener, setFilterChainBuilder, setHandler, setSessionDataStructureFactorydispose, isDisposed, isDisposingpublic NioDatagramAcceptor()
public NioDatagramAcceptor(Executor executor)
executor - The executor to usepublic void add(NioSession session)
session to the I/O processor so that
the I/O processor starts to perform any I/O operations related
with the session.add in interface IoProcessor<NioSession>session - The added sessionprotected final Set<SocketAddress> bindInternal(List<? extends SocketAddress> localAddresses) throws Exception
bindInternal in class AbstractIoAcceptorlocalAddresses - The address to bind toSet of the local addresses which is bound actuallyException - If the bind failedprotected void close(DatagramChannel handle) throws Exception
Exceptionprotected void dispose0()
throws Exception
AbstractIoService.dispose().dispose0 in class AbstractIoServiceException - If the dispose failedpublic void flush(NioSession session)
session.flush in interface IoProcessor<NioSession>session - The session we want the message to be writtenpublic InetSocketAddress getDefaultLocalAddress()
AbstractIoAcceptorIoAcceptor.bind() method. Please note that the default will not be
used if any local address is specified. If more than one address are
set, only one of them will be returned, but it's not necessarily the
firstly specified address in IoAcceptor.setDefaultLocalAddresses(List).getDefaultLocalAddress in interface IoAcceptorgetDefaultLocalAddress in interface DatagramAcceptorgetDefaultLocalAddress in class AbstractIoAcceptorpublic InetSocketAddress getLocalAddress()
AbstractIoAcceptorgetLocalAddress in interface IoAcceptorgetLocalAddress in interface DatagramAcceptorgetLocalAddress in class AbstractIoAcceptorpublic DatagramSessionConfig getSessionConfig()
getSessionConfig in interface IoServicegetSessionConfig in interface DatagramAcceptorIoSessions
created by this service.public final IoSessionRecycler getSessionRecycler()
getSessionRecycler in interface DatagramAcceptorIoSessionRecycler for this service.public TransportMetadata getTransportMetadata()
getTransportMetadata in interface IoServiceTransportMetadata that this service runs on.protected boolean isReadable(DatagramChannel handle)
protected boolean isWritable(DatagramChannel handle)
protected SocketAddress localAddress(DatagramChannel handle) throws Exception
Exceptionprotected NioSession newSession(IoProcessor<NioSession> processor, DatagramChannel handle, SocketAddress remoteAddress)
public final IoSession newSession(SocketAddress remoteAddress, SocketAddress localAddress)
IoSession that is bound to the specified
localAddress and the specified remoteAddress which
reuses the local address that is already bound by this service.
This operation is optional. Please throw UnsupportedOperationException
if the transport type doesn't support this operation. This operation is
usually implemented for connectionless transport types.
newSession in interface IoAcceptorremoteAddress - The remote address bound to the servicelocalAddress - The local address the session will be bound toprotected DatagramChannel open(SocketAddress localAddress) throws Exception
Exceptionprotected SocketAddress receive(DatagramChannel handle, IoBuffer buffer) throws Exception
Exceptionpublic void remove(NioSession session)
session from the I/O
processor so that the I/O processor closes the connection
associated with the session and releases any other related
resources.remove in interface IoProcessor<NioSession>session - The session to be removedprotected Set<SelectionKey> selectedHandles()
protected int send(NioSession session, IoBuffer buffer, SocketAddress remoteAddress) throws Exception
Exceptionpublic void setDefaultLocalAddress(InetSocketAddress localAddress)
DatagramAcceptorIoAcceptor.bind() method. Please note that the default will not be used
if any local InetSocketAddress is specified.
This method overrides the IoAcceptor.setDefaultLocalAddress(java.net.SocketAddress) method.setDefaultLocalAddress in interface DatagramAcceptorlocalAddress - The local addressprotected void setInterestedInWrite(NioSession session, boolean isInterested) throws Exception
Exceptionpublic final void setSessionRecycler(IoSessionRecycler sessionRecycler)
DatagramAcceptorIoSessionRecycler for this service.setSessionRecycler in interface DatagramAcceptorsessionRecycler - null to use the default recyclerprotected final void unbind0(List<? extends SocketAddress> localAddresses) throws Exception
unbind0 in class AbstractIoAcceptorlocalAddresses - The address to unbind fromException - If the unbind failedpublic void updateTrafficControl(NioSession session)
session depending of the
IoSession.isReadSuspended() and IoSession.isWriteSuspended()
flagsupdateTrafficControl in interface IoProcessor<NioSession>session - The session to be updatedprotected void wakeup()
public void write(NioSession session, WriteRequest writeRequest)
session.write in interface IoProcessor<NioSession>session - The session we want the message to be writtenwriteRequest - the WriteRequest to writeCopyright © 2004–2024 Apache MINA Project. All rights reserved.