public abstract class AbstractIoService extends Object implements IoService
IoServices.
An instance of IoService contains an Executor which will handle the incoming
events.| Modifier and Type | Class and Description |
|---|---|
protected static class |
AbstractIoService.ServiceOperationFuture
A
IoFuture dedicated class for |
| Modifier and Type | Field and Description |
|---|---|
protected Object |
disposalLock
A lock object which must be acquired when related resources are
destroyed.
|
protected static org.slf4j.Logger |
LOGGER |
protected IoSessionConfig |
sessionConfig
The default
IoSessionConfig which will be used to configure new sessions. |
| Modifier | Constructor and Description |
|---|---|
protected |
AbstractIoService(IoSessionConfig sessionConfig,
Executor executor)
Constructor for
AbstractIoService. |
| Modifier and Type | Method and Description |
|---|---|
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.
|
protected abstract void |
dispose0()
Implement this method to release any acquired resources.
|
protected void |
executeWorker(Runnable worker) |
protected void |
executeWorker(Runnable worker,
String suffix) |
protected void |
finishSessionInitialization0(IoSession session,
IoFuture future)
Implement this method to perform additional tasks required for session
initialization.
|
long |
getActivationTime() |
DefaultIoFilterChainBuilder |
getFilterChain()
|
IoFilterChainBuilder |
getFilterChainBuilder() |
IoHandler |
getHandler() |
IoServiceListenerSupport |
getListeners() |
int |
getManagedSessionCount() |
Map<Long,IoSession> |
getManagedSessions() |
int |
getScheduledWriteBytes() |
int |
getScheduledWriteMessages() |
IoSessionDataStructureFactory |
getSessionDataStructureFactory() |
IoServiceStatistics |
getStatistics() |
protected void |
initSession(IoSession session,
IoFuture future,
IoSessionInitializer sessionInitializer) |
boolean |
isActive() |
boolean |
isDisposed() |
boolean |
isDisposing() |
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. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetSessionConfig, getTransportMetadataprotected static final org.slf4j.Logger LOGGER
protected final IoSessionConfig sessionConfig
IoSessionConfig which will be used to configure new sessions.protected final Object disposalLock
protected AbstractIoService(IoSessionConfig sessionConfig, Executor executor)
AbstractIoService. You need to provide a default
session configuration and an Executor for handling I/O events. If
a null Executor is provided, a default one will be created using
Executors.newCachedThreadPool().public final IoFilterChainBuilder getFilterChainBuilder()
getFilterChainBuilder in interface IoServiceIoFilterChainBuilder which will build the
IoFilterChain of all IoSessions which is created
by this service.
The default value is an empty DefaultIoFilterChainBuilder.public final void setFilterChainBuilder(IoFilterChainBuilder builder)
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.setFilterChainBuilder in interface IoServicebuilder - The filter chain builder to usepublic final DefaultIoFilterChainBuilder getFilterChain()
( ( 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.getFilterChain in interface IoServicepublic final void addListener(IoServiceListener listener)
IoServiceListener that listens any events related with
this service.addListener in interface IoServicelistener - The listener to addpublic final void removeListener(IoServiceListener listener)
IoServiceListener that listens any events
related with this service.removeListener in interface IoServicelistener - The listener to usepublic final boolean isActive()
public final boolean isDisposing()
isDisposing in interface IoServicetrue if and if only IoService.dispose() method has
been called. Please note that this method will return true
even after all the related resources are released.public final boolean isDisposed()
isDisposed in interface IoServicetrue if and if only all resources of this processor
have been disposed.public final void dispose()
public final void dispose(boolean awaitTermination)
awaitTermination = true
will probably lead to a deadlock.protected abstract void dispose0()
throws Exception
dispose().Exception - If the dispose failedpublic final Map<Long,IoSession> getManagedSessions()
getManagedSessions in interface IoServiceID of the
session. An empty collection if there's no session.public final int getManagedSessionCount()
getManagedSessionCount in interface IoServicepublic final IoHandler getHandler()
getHandler in interface IoServicepublic final void setHandler(IoHandler handler)
setHandler in interface IoServicehandler - The IoHandler to usepublic final IoSessionDataStructureFactory getSessionDataStructureFactory()
getSessionDataStructureFactory in interface IoServiceIoSessionDataStructureFactory that provides
related data structures for a new session created by this service.public final void setSessionDataStructureFactory(IoSessionDataStructureFactory sessionDataStructureFactory)
IoSessionDataStructureFactory that provides
related data structures for a new session created by this service.setSessionDataStructureFactory in interface IoServicesessionDataStructureFactory - The factory to usepublic IoServiceStatistics getStatistics()
getStatistics in interface IoServicepublic final long getActivationTime()
getActivationTime in interface IoServicepublic final Set<WriteFuture> broadcast(Object message)
message to all the IoSessions
managed by this service. This method is a convenience shortcut for
IoUtil.broadcast(Object, Collection).public final IoServiceListenerSupport getListeners()
IoServiceListenerSupport attached to this serviceprotected final void executeWorker(Runnable worker)
protected final void initSession(IoSession session, IoFuture future, IoSessionInitializer sessionInitializer)
protected void finishSessionInitialization0(IoSession session, IoFuture future)
initSession(IoSession, IoFuture, IoSessionInitializer) will call
this method instead.session - The session to initializefuture - The Future to usepublic int getScheduledWriteBytes()
getScheduledWriteBytes in interface IoServicepublic int getScheduledWriteMessages()
getScheduledWriteMessages in interface IoServiceCopyright © 2004–2024 Apache MINA Project. All rights reserved.