Package org.apache.mina.common.support
Class DelegatedIoAcceptor
- java.lang.Object
-
- org.apache.mina.common.support.DelegatedIoAcceptor
-
- All Implemented Interfaces:
IoAcceptor
,IoService
- Direct Known Subclasses:
DatagramAcceptor
public class DelegatedIoAcceptor extends java.lang.Object implements IoAcceptor
A delegatedIoAcceptor
that wraps the otherIoAcceptor
.
-
-
Field Summary
Fields Modifier and Type Field Description protected IoAcceptor
delegate
-
Constructor Summary
Constructors Modifier Constructor Description protected
DelegatedIoAcceptor()
Creates a new instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addListener(IoServiceListener listener)
Adds anIoServiceListener
that listens any events related with this service.void
bind(java.net.SocketAddress address, IoHandler handler)
Binds to the specifiedaddress
and handles incoming connections with the specifiedhandler
.void
bind(java.net.SocketAddress address, IoHandler handler, IoServiceConfig config)
Binds to the specifiedaddress
and handles incoming connections with the specifiedhandler
.IoServiceConfig
getDefaultConfig()
Returns the default configuration which is used when you didn't specify any configuration.DefaultIoFilterChainBuilder
getFilterChain()
A shortcut for ( ( DefaultIoFilterChainBuilder )IoService.getFilterChainBuilder()
).IoFilterChainBuilder
getFilterChainBuilder()
Returns the globalIoFilterChainBuilder
which will modify theIoFilterChain
of allIoSession
s which is managed by this service.java.util.Set<java.net.SocketAddress>
getManagedServiceAddresses()
Returns allSocketAddress
es this service is managing.java.util.Set<IoSession>
getManagedSessions(java.net.SocketAddress serviceAddress)
Returns all sessions with the specified remote or local address, which are currently managed by this service.protected void
init(IoAcceptor delegate)
Sets the delegate.boolean
isManaged(java.net.SocketAddress address)
Returns true if this service is managing the specified serviceAddress.IoSession
newSession(java.net.SocketAddress remoteAddress, java.net.SocketAddress localAddress)
(Optional) Returns anIoSession
that is bound to the specified localAddress and remoteAddress which reuses the localAddress that is already bound byIoAcceptor
viaIoAcceptor.bind(SocketAddress, IoHandler)
.void
removeListener(IoServiceListener listener)
Removed an existingIoServiceListener
that listens any events related with this service.void
setFilterChainBuilder(IoFilterChainBuilder builder)
Sets the globalIoFilterChainBuilder
which will modify theIoFilterChain
of allIoSession
s which is managed by this service.void
unbind(java.net.SocketAddress address)
Unbinds from the specifiedaddress
and disconnects all clients connected there.void
unbindAll()
Unbinds all addresses which were bound by this acceptor.
-
-
-
Field Detail
-
delegate
protected IoAcceptor delegate
-
-
Method Detail
-
init
protected void init(IoAcceptor delegate)
Sets the delegate. This method should be invoked before any operations is requested.
-
bind
public void bind(java.net.SocketAddress address, IoHandler handler) throws java.io.IOException
Description copied from interface:IoAcceptor
Binds to the specifiedaddress
and handles incoming connections with the specifiedhandler
.- Specified by:
bind
in interfaceIoAcceptor
- Throws:
java.io.IOException
- if failed to bind
-
bind
public void bind(java.net.SocketAddress address, IoHandler handler, IoServiceConfig config) throws java.io.IOException
Description copied from interface:IoAcceptor
Binds to the specifiedaddress
and handles incoming connections with the specifiedhandler
.- Specified by:
bind
in interfaceIoAcceptor
config
- the configuration- Throws:
java.io.IOException
- if failed to bind
-
unbind
public void unbind(java.net.SocketAddress address)
Description copied from interface:IoAcceptor
Unbinds from the specifiedaddress
and disconnects all clients connected there.- Specified by:
unbind
in interfaceIoAcceptor
-
unbindAll
public void unbindAll()
Description copied from interface:IoAcceptor
Unbinds all addresses which were bound by this acceptor.- Specified by:
unbindAll
in interfaceIoAcceptor
-
isManaged
public boolean isManaged(java.net.SocketAddress address)
Description copied from interface:IoService
Returns true if this service is managing the specified serviceAddress. If this service is anIoAcceptor
, serviceAddress is a bind address. If this service is anIoConnector
, serviceAddress is a remote address.
-
getManagedServiceAddresses
public java.util.Set<java.net.SocketAddress> getManagedServiceAddresses()
Description copied from interface:IoService
Returns allSocketAddress
es this service is managing. If this service is anIoAcceptor
, a set of bind addresses will be returned. If this service is anIoConnector
, a set of remote addresses will be returned.- Specified by:
getManagedServiceAddresses
in interfaceIoService
-
getManagedSessions
public java.util.Set<IoSession> getManagedSessions(java.net.SocketAddress serviceAddress)
Description copied from interface:IoService
Returns all sessions with the specified remote or local address, which are currently managed by this service.IoAcceptor
will assume the specified address is a local address, andIoConnector
will assume it's a remote address.- Specified by:
getManagedSessions
in interfaceIoService
- Parameters:
serviceAddress
- the address to return all sessions for.- Returns:
- the sessions. An empty collection if there's no session.
-
newSession
public IoSession newSession(java.net.SocketAddress remoteAddress, java.net.SocketAddress localAddress)
Description copied from interface:IoAcceptor
(Optional) Returns anIoSession
that is bound to the specified localAddress and remoteAddress which reuses the localAddress that is already bound byIoAcceptor
viaIoAcceptor.bind(SocketAddress, IoHandler)
.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.- Specified by:
newSession
in interfaceIoAcceptor
-
getDefaultConfig
public IoServiceConfig getDefaultConfig()
Description copied from interface:IoService
Returns the default configuration which is used when you didn't specify any configuration.- Specified by:
getDefaultConfig
in interfaceIoService
-
getFilterChainBuilder
public IoFilterChainBuilder getFilterChainBuilder()
Description copied from interface:IoService
Returns the globalIoFilterChainBuilder
which will modify theIoFilterChain
of allIoSession
s which is managed by this service. The default value is an emptyDefaultIoFilterChainBuilder
.- Specified by:
getFilterChainBuilder
in interfaceIoService
-
setFilterChainBuilder
public void setFilterChainBuilder(IoFilterChainBuilder builder)
Description copied from interface:IoService
Sets the globalIoFilterChainBuilder
which will modify theIoFilterChain
of allIoSession
s which is managed by this service. If you specify null this property will be set to an emptyDefaultIoFilterChainBuilder
.- Specified by:
setFilterChainBuilder
in interfaceIoService
-
getFilterChain
public DefaultIoFilterChainBuilder getFilterChain()
Description copied from interface:IoService
A shortcut for ( ( DefaultIoFilterChainBuilder )IoService.getFilterChainBuilder()
). Please note that the returned object is not a realIoFilterChain
but aDefaultIoFilterChainBuilder
. Modifying the returned builder won't affect the existingIoSession
s at all, becauseIoFilterChainBuilder
s affect only newly createdIoSession
s.- Specified by:
getFilterChain
in interfaceIoService
-
addListener
public void addListener(IoServiceListener listener)
Description copied from interface:IoService
Adds anIoServiceListener
that listens any events related with this service.- Specified by:
addListener
in interfaceIoService
-
removeListener
public void removeListener(IoServiceListener listener)
Description copied from interface:IoService
Removed an existingIoServiceListener
that listens any events related with this service.- Specified by:
removeListener
in interfaceIoService
-
-