|
||||||||||
| 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 IoServices.
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 IoSessions
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 |
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 IoSessions which is created
by this service. |
IoHandler |
getHandler()
Returns the handler which will handle all connections managed by this service. |
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 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. |
protected void |
initSession(IoSession session,
IoFuture future,
IoSessionInitializer sessionInitializer)
|
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 |
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. |
| 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 IoSessionexecutor - 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 IoSessions which is created
by this service.
The default value is an empty DefaultIoFilterChainBuilder.
getFilterChainBuilder in interface IoServicepublic 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 IoServicepublic 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 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 IoServicepublic final void removeListener(IoServiceListener listener)
IoServiceListener that listens any events
related with this service.
removeListener in interface IoServicepublic final boolean isActive()
isActive in interface IoServicepublic 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 IoServicepublic final boolean isDisposed()
isDisposed in interface IoServicepublic final void dispose()
dispose in interface IoService
protected abstract IoFuture dispose0()
throws Exception
dispose().
Exceptionpublic final Map<Long,IoSession> getManagedSessions()
ID of the
session.
getManagedSessions in interface IoServicepublic final int getManagedSessionCount()
getManagedSessionCount in interface IoServicepublic final IoHandler getHandler()
getHandler in interface IoServicepublic final void setHandler(IoHandler handler)
setHandler in interface IoServicepublic IoSessionConfig getSessionConfig()
IoSessions
created by this service.
getSessionConfig in interface IoServicepublic final IoSessionDataStructureFactory getSessionDataStructureFactory()
IoSessionDataStructureFactory that provides
related data structures for a new session created by this service.
getSessionDataStructureFactory in interface IoServicepublic final void setSessionDataStructureFactory(IoSessionDataStructureFactory sessionDataStructureFactory)
IoSessionDataStructureFactory that provides
related data structures for a new session created by this service.
setSessionDataStructureFactory in interface IoServicepublic IoServiceStatistics getStatistics()
getStatistics in interface IoServicepublic final long getActivationTime()
getActivationTime in interface IoServiceSystem.currentTimeMillis()public 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).
broadcast in interface IoServicepublic final IoServiceListenerSupport getListeners()
protected final void executeWorker(Runnable worker)
protected final void executeWorker(Runnable worker,
String suffix)
protected final void initSession(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 IoServicepublic int getScheduledWriteMessages()
getScheduledWriteMessages in interface IoService
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||