org.apache.mina.common.support
Class DelegatedIoAcceptor

java.lang.Object
  extended by 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 delegated IoAcceptor that wraps the other IoAcceptor.


Field Summary
protected  IoAcceptor delegate
           
 
Constructor Summary
protected DelegatedIoAcceptor()
          Creates a new instance.
 
Method Summary
 void addListener(IoServiceListener listener)
          Adds an IoServiceListener that listens any events related with this service.
 void bind(java.net.SocketAddress address, IoHandler handler)
          Binds to the specified address and handles incoming connections with the specified handler.
 void bind(java.net.SocketAddress address, IoHandler handler, IoServiceConfig config)
          Binds to the specified address and handles incoming connections with the specified handler.
 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 global IoFilterChainBuilder which will modify the IoFilterChain of all IoSessions which is managed by this service.
 java.util.Set<java.net.SocketAddress> getManagedServiceAddresses()
          Returns all SocketAddresses 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 an IoSession that is bound to the specified localAddress and remoteAddress which reuses the localAddress that is already bound by IoAcceptor via IoAcceptor.bind(SocketAddress, IoHandler).
 void removeListener(IoServiceListener listener)
          Removed an existing IoServiceListener that listens any events related with this service.
 void setFilterChainBuilder(IoFilterChainBuilder builder)
          Sets the global IoFilterChainBuilder which will modify the IoFilterChain of all IoSessions which is managed by this service.
 void unbind(java.net.SocketAddress address)
          Unbinds from the specified address and disconnects all clients connected there.
 void unbindAll()
          Unbinds all addresses which were bound by this acceptor.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

delegate

protected IoAcceptor delegate
Constructor Detail

DelegatedIoAcceptor

protected DelegatedIoAcceptor()
Creates a new instance.

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 specified address and handles incoming connections with the specified handler.

Specified by:
bind in interface IoAcceptor
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 specified address and handles incoming connections with the specified handler.

Specified by:
bind in interface IoAcceptor
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 specified address and disconnects all clients connected there.

Specified by:
unbind in interface IoAcceptor

unbindAll

public void unbindAll()
Description copied from interface: IoAcceptor
Unbinds all addresses which were bound by this acceptor.

Specified by:
unbindAll in interface IoAcceptor

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 an IoAcceptor, serviceAddress is a bind address. If this service is an IoConnector, serviceAddress is a remote address.

Specified by:
isManaged in interface IoService

getManagedServiceAddresses

public java.util.Set<java.net.SocketAddress> getManagedServiceAddresses()
Description copied from interface: IoService
Returns all SocketAddresses this service is managing. If this service is an IoAcceptor, a set of bind addresses will be returned. If this service is an IoConnector, a set of remote addresses will be returned.

Specified by:
getManagedServiceAddresses in interface IoService

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, and IoConnector will assume it's a remote address.

Specified by:
getManagedSessions in interface IoService
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 an IoSession that is bound to the specified localAddress and remoteAddress which reuses the localAddress that is already bound by IoAcceptor via IoAcceptor.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 interface IoAcceptor

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 interface IoService

getFilterChainBuilder

public IoFilterChainBuilder getFilterChainBuilder()
Description copied from interface: IoService
Returns the global IoFilterChainBuilder which will modify the IoFilterChain of all IoSessions which is managed by this service. The default value is an empty DefaultIoFilterChainBuilder.

Specified by:
getFilterChainBuilder in interface IoService

setFilterChainBuilder

public void setFilterChainBuilder(IoFilterChainBuilder builder)
Description copied from interface: IoService
Sets the global IoFilterChainBuilder which will modify the IoFilterChain of all IoSessions which is managed by this service. If you specify null this property will be set to an empty DefaultIoFilterChainBuilder.

Specified by:
setFilterChainBuilder in interface IoService

getFilterChain

public DefaultIoFilterChainBuilder getFilterChain()
Description copied from interface: IoService
A shortcut for ( ( DefaultIoFilterChainBuilder ) IoService.getFilterChainBuilder() ). Please note that the returned object is not a real IoFilterChain but a DefaultIoFilterChainBuilder. Modifying the returned builder won't affect the existing IoSessions at all, because IoFilterChainBuilders affect only newly created IoSessions.

Specified by:
getFilterChain in interface IoService

addListener

public void addListener(IoServiceListener listener)
Description copied from interface: IoService
Adds an IoServiceListener that listens any events related with this service.

Specified by:
addListener in interface IoService

removeListener

public void removeListener(IoServiceListener listener)
Description copied from interface: IoService
Removed an existing IoServiceListener that listens any events related with this service.

Specified by:
removeListener in interface IoService