|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.mina.core.service.AbstractIoService
public abstract class AbstractIoService
Base implementation of IoService
s.
An instance of IoService contains an Executor which will handle the incoming
events.
Nested Class Summary | |
---|---|
protected static class |
AbstractIoService.ServiceOperationFuture
|
Field Summary | |
---|---|
protected Object |
disposalLock
A lock object which must be acquired when related resources are destroyed. |
Constructor Summary | |
---|---|
protected |
AbstractIoService(IoSessionConfig sessionConfig,
Executor executor)
Constructor for AbstractIoService . |
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 IoSession s
managed by this service. |
void |
dispose()
Releases any resources allocated by this service. |
protected abstract IoFuture |
dispose0()
Implement this method to release any acquired resources. |
protected void |
executeWorker(Runnable worker)
|
protected void |
executeWorker(Runnable worker,
String suffix)
|
protected void |
finishSessionInitialization(IoSession session,
IoFuture future,
IoSessionInitializer sessionInitializer)
|
protected void |
finishSessionInitialization0(IoSession session,
IoFuture future)
Implement this method to perform additional tasks required for session initialization. |
long |
getActivationTime()
Returns the time when this service was activated. |
DefaultIoFilterChainBuilder |
getFilterChain()
A shortcut for ( ( DefaultIoFilterChainBuilder ) IoService.getFilterChainBuilder() ). |
IoFilterChainBuilder |
getFilterChainBuilder()
Returns the IoFilterChainBuilder which will build the
IoFilterChain of all IoSession s which is created
by this service. |
IoHandler |
getHandler()
Returns the handler which will handle all connections managed by this service. |
IoServiceIdleState |
getIdleState()
Returns the IoServiceIdleState for this service. |
protected IdleStatusChecker |
getIdleStatusChecker()
|
IoServiceListenerSupport |
getListeners()
|
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 IoSession s
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. |
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 IoService.dispose() method has
been called. |
void |
notifyIdleness(long currentTime)
TODO |
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 IoSession s 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. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface org.apache.mina.core.service.IoService |
---|
getTransportMetadata |
Field Detail |
---|
protected final Object disposalLock
Constructor Detail |
---|
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()
.
sessionConfig
- the default configuration for the managed IoSession
executor
- the Executor
used for handling execution of I/O
events. Can be null
.Method Detail |
---|
public final IoFilterChainBuilder getFilterChainBuilder()
IoFilterChainBuilder
which will build the
IoFilterChain
of all IoSession
s which is created
by this service.
The default value is an empty DefaultIoFilterChainBuilder
.
getFilterChainBuilder
in interface IoService
public final void setFilterChainBuilder(IoFilterChainBuilder builder)
IoFilterChainBuilder
which will build the
IoFilterChain
of all IoSession
s which is created
by this service.
If you specify null this property will be set to
an empty DefaultIoFilterChainBuilder
.
setFilterChainBuilder
in interface IoService
public final DefaultIoFilterChainBuilder getFilterChain()
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 IoSession
s at all, because
IoFilterChainBuilder
s affect only newly created IoSession
s.
getFilterChain
in interface IoService
public final void addListener(IoServiceListener listener)
IoServiceListener
that listens any events related with
this service.
addListener
in interface IoService
public final void removeListener(IoServiceListener listener)
IoServiceListener
that listens any events
related with this service.
removeListener
in interface IoService
public final boolean isActive()
isActive
in interface IoService
public final boolean isDisposing()
IoService.dispose()
method has
been called. Please note that this method will return true
even after all the related resources are released.
isDisposing
in interface IoService
public final boolean isDisposed()
isDisposed
in interface IoService
public final void dispose()
dispose
in interface IoService
protected abstract IoFuture dispose0() throws Exception
dispose()
.
Exception
public final Map<Long,IoSession> getManagedSessions()
ID
of the
session.
getManagedSessions
in interface IoService
public final int getManagedSessionCount()
getManagedSessionCount
in interface IoService
public final IoHandler getHandler()
getHandler
in interface IoService
public final void setHandler(IoHandler handler)
setHandler
in interface IoService
public IoSessionConfig getSessionConfig()
IoSession
s
created by this service.
getSessionConfig
in interface IoService
public final IoSessionDataStructureFactory getSessionDataStructureFactory()
IoSessionDataStructureFactory
that provides
related data structures for a new session created by this service.
getSessionDataStructureFactory
in interface IoService
public final void setSessionDataStructureFactory(IoSessionDataStructureFactory sessionDataStructureFactory)
IoSessionDataStructureFactory
that provides
related data structures for a new session created by this service.
setSessionDataStructureFactory
in interface IoService
public IoServiceIdleState getIdleState()
getIdleState
in interface IoService
public IoServiceStatistics getStatistics()
getStatistics
in interface IoService
public final long getActivationTime()
getActivationTime
in interface IoService
System.currentTimeMillis()
public final Set<WriteFuture> broadcast(Object message)
message
to all the IoSession
s
managed by this service. This method is a convenience shortcut for
IoUtil.broadcast(Object, Collection)
.
broadcast
in interface IoService
public final IoServiceListenerSupport getListeners()
protected final IdleStatusChecker getIdleStatusChecker()
protected final void executeWorker(Runnable worker)
protected final void executeWorker(Runnable worker, String suffix)
protected final void finishSessionInitialization(IoSession session, IoFuture future, IoSessionInitializer sessionInitializer)
protected void finishSessionInitialization0(IoSession session, IoFuture future)
finishSessionInitialization(IoSession, IoFuture, IoSessionInitializer)
will call
this method instead.
public int getScheduledWriteBytes()
getScheduledWriteBytes
in interface IoService
public int getScheduledWriteMessages()
getScheduledWriteMessages
in interface IoService
public void notifyIdleness(long currentTime)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |