Interface IoService
- All Known Subinterfaces:
DatagramAcceptor, DatagramConnector, IoAcceptor, IoConnector, SocketAcceptor, SocketConnector
- All Known Implementing Classes:
AbstractIoAcceptor, AbstractIoConnector, AbstractIoService, AbstractPollingIoAcceptor, AbstractPollingIoConnector, AprSocketAcceptor, AprSocketConnector, NioDatagramAcceptor, NioDatagramConnector, NioSocketAcceptor, NioSocketConnector, ProxyConnector, VmPipeAcceptor, VmPipeConnector
public interface IoService
-
Method Summary
Modifier and TypeMethodDescriptionvoidaddListener(IoServiceListener listener) Adds anIoServiceListenerthat listens any events related with this service.Writes the specifiedmessageto all theIoSessions managed by this service.voiddispose()Releases any resources allocated by this service.voiddispose(boolean awaitTermination) Releases any resources allocated by this service.longintintintbooleanisActive()booleanbooleanvoidremoveListener(IoServiceListener listener) Removed an existingIoServiceListenerthat listens any events related with this service.voidSets theIoFilterChainBuilderwhich will build theIoFilterChainof allIoSessions which is created by this service.voidsetHandler(IoHandler handler) Sets the handler which will handle all connections managed by this service.voidsetSessionDataStructureFactory(IoSessionDataStructureFactory sessionDataStructureFactory) Sets theIoSessionDataStructureFactorythat provides related data structures for a new session created by this service.
-
Method Details
-
getTransportMetadata
TransportMetadata getTransportMetadata()- Returns:
- the
TransportMetadatathat this service runs on.
-
addListener
Adds anIoServiceListenerthat listens any events related with this service.- Parameters:
listener- The listener to add
-
removeListener
Removed an existingIoServiceListenerthat listens any events related with this service.- Parameters:
listener- The listener to use
-
isDisposing
boolean isDisposing()- Returns:
trueif and if onlydispose()method has been called. Please note that this method will returntrueeven after all the related resources are released.
-
isDisposed
boolean isDisposed()- Returns:
trueif 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 withawaitTermination= 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
Sets the handler which will handle all connections managed by this service.- Parameters:
handler- The IoHandler to use
-
getManagedSessions
-
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
IoFilterChainBuilderwhich will build theIoFilterChainof allIoSessions which is created by this service. The default value is an emptyDefaultIoFilterChainBuilder.
-
setFilterChainBuilder
Sets theIoFilterChainBuilderwhich will build theIoFilterChainof allIoSessions which is created by this service. If you specifynullthis property will be set to an emptyDefaultIoFilterChainBuilder.- Parameters:
builder- The filter chain builder to use
-
getFilterChain
DefaultIoFilterChainBuilder getFilterChain()A shortcut for( ( DefaultIoFilterChainBuilder )getFilterChainBuilder()). Please note that the returned object is not a realIoFilterChainbut aDefaultIoFilterChainBuilder. Modifying the returned builder won't affect the existingIoSessions at all, becauseIoFilterChainBuilders affect only newly createdIoSessions.- Returns:
- The filter chain in use
- Throws:
IllegalStateException- if the currentIoFilterChainBuilderis not aDefaultIoFilterChainBuilder
-
isActive
boolean isActive()- Returns:
- a value of whether or not this 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.
-
broadcast
Writes the specifiedmessageto all theIoSessions managed by this service. This method is a convenience shortcut forIoUtil.broadcast(Object, Collection).- Parameters:
message- the message to broadcast- Returns:
- The set of WriteFuture associated to the message being broadcasted
-
getSessionDataStructureFactory
IoSessionDataStructureFactory getSessionDataStructureFactory()- Returns:
- the
IoSessionDataStructureFactorythat provides related data structures for a new session created by this service.
-
setSessionDataStructureFactory
Sets theIoSessionDataStructureFactorythat provides related data structures for a new session created by this service.- Parameters:
sessionDataStructureFactory- The factory to use
-
getScheduledWriteBytes
int getScheduledWriteBytes()- Returns:
- The number of bytes scheduled to be written
-
getScheduledWriteMessages
int getScheduledWriteMessages()- Returns:
- The number of messages scheduled to be written
-
getStatistics
IoServiceStatistics getStatistics()- Returns:
- The statistics object for this service.
-