org.apache.mina.core.service
Interface IoService

All Known Subinterfaces:
DatagramAcceptor, DatagramConnector, IoAcceptor, IoConnector, SocketAcceptor, SocketConnector
All Known Implementing Classes:
AbstractIoAcceptor, AbstractIoConnector, AbstractIoService, AbstractPollingConnectionlessIoAcceptor, AbstractPollingIoAcceptor, AbstractPollingIoConnector, AprSocketAcceptor, AprSocketConnector, NioDatagramAcceptor, NioDatagramConnector, NioSocketAcceptor, NioSocketConnector, ProxyConnector, SerialConnector, VmPipeAcceptor, VmPipeConnector

public interface IoService

Base interface for all IoAcceptors and IoConnectors that provide I/O service and manage IoSessions.

Author:
Apache MINA Project

Method Summary
 void addListener(IoServiceListener listener)
          Adds an IoServiceListener that listens any events related with this service.
 Set<WriteFuture> broadcast(Object message)
          Writes the specified message to all the IoSessions managed by this service.
 void dispose()
          Releases any resources allocated by this service.
 void dispose(boolean awaitTermination)
          Releases any resources allocated by this service.
 long getActivationTime()
          Returns the time when this service was activated.
 DefaultIoFilterChainBuilder getFilterChain()
          A shortcut for ( ( DefaultIoFilterChainBuilder ) getFilterChainBuilder() ).
 IoFilterChainBuilder getFilterChainBuilder()
          Returns the IoFilterChainBuilder which will build the IoFilterChain of all IoSessions which is created by this service.
 IoHandler getHandler()
          Returns the handler which will handle all connections managed by this service.
 int getManagedSessionCount()
          Returns the number of all sessions which are currently managed by this service.
 Map<Long,IoSession> getManagedSessions()
          Returns the map of all sessions which are currently managed by this service.
 int getScheduledWriteBytes()
          Returns the number of bytes scheduled to be written
 int getScheduledWriteMessages()
          Returns the number of messages scheduled to be written
 IoSessionConfig getSessionConfig()
          Returns the default configuration of the new IoSessions created by this service.
 IoSessionDataStructureFactory getSessionDataStructureFactory()
          Returns the IoSessionDataStructureFactory that provides related data structures for a new session created by this service.
 IoServiceStatistics getStatistics()
          Returns the IoServiceStatistics object for this service.
 TransportMetadata getTransportMetadata()
          Returns the TransportMetadata that this service runs on.
 boolean isActive()
          Returns a value of whether or not this service is active
 boolean isDisposed()
          Returns true if and if only all resources of this processor have been disposed.
 boolean isDisposing()
          Returns true if and if only dispose() method has been called.
 void removeListener(IoServiceListener listener)
          Removed an existing IoServiceListener that listens any events related with this service.
 void setFilterChainBuilder(IoFilterChainBuilder builder)
          Sets the IoFilterChainBuilder which will build the IoFilterChain of all IoSessions which is created by this service.
 void setHandler(IoHandler handler)
          Sets the handler which will handle all connections managed by this service.
 void setSessionDataStructureFactory(IoSessionDataStructureFactory sessionDataStructureFactory)
          Sets the IoSessionDataStructureFactory that provides related data structures for a new session created by this service.
 

Method Detail

getTransportMetadata

TransportMetadata getTransportMetadata()
Returns the TransportMetadata that this service runs on.


addListener

void addListener(IoServiceListener listener)
Adds an IoServiceListener that listens any events related with this service.


removeListener

void removeListener(IoServiceListener listener)
Removed an existing IoServiceListener that listens any events related with this service.


isDisposing

boolean isDisposing()
Returns true if and if only dispose() method has been called. Please note that this method will return true even after all the related resources are released.


isDisposed

boolean isDisposed()
Returns true if and if only all resources of this processor have been disposed.


dispose

void dispose()
Releases any resources allocated by this service. Please note that this method might block as long as there are any sessions managed by this service.


dispose

void dispose(boolean awaitTermination)
Releases any resources allocated by this service. Please note that this method might block as long as there are any sessions managed by this service. Warning : calling this method from a IoFutureListener with awaitTermination = true will probably lead to a deadlock.

Parameters:
awaitTermination - When true this method will block until the underlying ExecutorService is terminated

getHandler

IoHandler getHandler()
Returns the handler which will handle all connections managed by this service.


setHandler

void setHandler(IoHandler handler)
Sets the handler which will handle all connections managed by this service.


getManagedSessions

Map<Long,IoSession> getManagedSessions()
Returns the map of all sessions which are currently managed by this service. The key of map is the ID of the session.

Returns:
the sessions. An empty collection if there's no session.

getManagedSessionCount

int getManagedSessionCount()
Returns the number of all sessions which are currently managed by this service.


getSessionConfig

IoSessionConfig getSessionConfig()
Returns the default configuration of the new IoSessions created by this service.


getFilterChainBuilder

IoFilterChainBuilder getFilterChainBuilder()
Returns the IoFilterChainBuilder which will build the IoFilterChain of all IoSessions which is created by this service. The default value is an empty DefaultIoFilterChainBuilder.


setFilterChainBuilder

void setFilterChainBuilder(IoFilterChainBuilder builder)
Sets the IoFilterChainBuilder which will build the IoFilterChain of all IoSessions which is created by this service. If you specify null this property will be set to an empty DefaultIoFilterChainBuilder.


getFilterChain

DefaultIoFilterChainBuilder getFilterChain()
A shortcut for ( ( DefaultIoFilterChainBuilder ) 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.

Throws:
IllegalStateException - if the current IoFilterChainBuilder is not a DefaultIoFilterChainBuilder

isActive

boolean isActive()
Returns a value of whether or not this service is active

Returns:
whether of not the service is active.

getActivationTime

long getActivationTime()
Returns the time when this service was activated. It returns the last time when this service was activated if the service is not active now.

Returns:
The time by using System.currentTimeMillis()

broadcast

Set<WriteFuture> broadcast(Object message)
Writes the specified message to all the IoSessions managed by this service. This method is a convenience shortcut for IoUtil.broadcast(Object, Collection).


getSessionDataStructureFactory

IoSessionDataStructureFactory getSessionDataStructureFactory()
Returns the IoSessionDataStructureFactory that provides related data structures for a new session created by this service.


setSessionDataStructureFactory

void setSessionDataStructureFactory(IoSessionDataStructureFactory sessionDataStructureFactory)
Sets the IoSessionDataStructureFactory that provides related data structures for a new session created by this service.


getScheduledWriteBytes

int getScheduledWriteBytes()
Returns the number of bytes scheduled to be written

Returns:
The number of bytes scheduled to be written

getScheduledWriteMessages

int getScheduledWriteMessages()
Returns the number of messages scheduled to be written

Returns:
The number of messages scheduled to be written

getStatistics

IoServiceStatistics getStatistics()
Returns the IoServiceStatistics object for this service.

Returns:
The statistics object for this service.


Copyright © 2004-2011 Apache MINA Project. All Rights Reserved.