org.apache.mina.common.support

Class BaseIoService

Implemented Interfaces:
IoService
Known Direct Subclasses:
BaseIoAcceptor, BaseIoConnector

public abstract class BaseIoService
extends java.lang.Object
implements IoService

Base implementation of IoServices.

Constructor Summary

BaseIoService()

Method Summary

void
addListener(IoServiceListener listener)
Adds an IoServiceListener that listens any events related with this service.
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.
protected IoServiceListenerSupport
getListeners()
Set
getManagedServiceAddresses()
Returns all SocketAddresses this service is managing.
Set
getManagedSessions(SocketAddress serviceAddress)
Returns all sessions with the specified remote or local address, which are currently managed by this service.
boolean
isManaged(SocketAddress serviceAddress)
Returns true if this service is managing the specified serviceAddress.
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.

Constructor Details

BaseIoService

protected BaseIoService()

Method Details

addListener

public void addListener(IoServiceListener listener)
Adds an IoServiceListener that listens any events related with this service.
Specified by:
addListener in interface IoService

getFilterChain

public DefaultIoFilterChainBuilder getFilterChain()
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

getFilterChainBuilder

public IoFilterChainBuilder getFilterChainBuilder()
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

getListeners

protected IoServiceListenerSupport getListeners()

getManagedServiceAddresses

public Set getManagedServiceAddresses()
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 Set getManagedSessions(SocketAddress serviceAddress)
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.

isManaged

public boolean isManaged(SocketAddress serviceAddress)
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

removeListener

public void removeListener(IoServiceListener listener)
Removed an existing IoServiceListener that listens any events related with this service.
Specified by:
removeListener in interface IoService

setFilterChainBuilder

public void setFilterChainBuilder(IoFilterChainBuilder builder)
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