|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.mina.common.IoFilterAdapter
org.apache.mina.filter.ThreadPoolFilter
public class ThreadPoolFilter
A Thread-pooling filter. This filter forwards IoHandler
events
to its thread pool.
This is an implementation of Leader/Followers thread pool by Douglas C. Schmidt et al.
Use the start()
and stop()
methods to force this filter
to start/stop processing events. Alternatively, start()
will be
called automatically the first time an instance of this filter is added
to a filter chain. Calling stop()
is not required either since
all workers are daemon threads which means that any workers still alive
when the JVM terminates will die automatically.
Nested Class Summary | |
---|---|
protected static class |
ThreadPoolFilter.Event
|
protected static class |
ThreadPoolFilter.EventType
|
protected static class |
ThreadPoolFilter.SessionBuffer
|
Nested classes/interfaces inherited from interface org.apache.mina.common.IoFilter |
---|
IoFilter.NextFilter, IoFilter.WriteRequest |
Field Summary | |
---|---|
static int |
DEFAULT_KEEP_ALIVE_TIME
Default keep-alive time of thread pool (1 min). |
static int |
DEFAULT_MAXIMUM_POOL_SIZE
Default maximum size of thread pool (16). |
Constructor Summary | |
---|---|
ThreadPoolFilter()
Creates a new instance of this filter with default thread pool settings. |
|
ThreadPoolFilter(String threadNamePrefix)
Creates a new instance of this filter with the specified thread name prefix and other default settings. |
Methods inherited from class org.apache.mina.common.IoFilterAdapter |
---|
destroy, init, onPostAdd, onPostRemove, onPreRemove |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int DEFAULT_MAXIMUM_POOL_SIZE
public static final int DEFAULT_KEEP_ALIVE_TIME
Constructor Detail |
---|
public ThreadPoolFilter()
public ThreadPoolFilter(String threadNamePrefix)
threadNamePrefix
- the prefix of the thread names this pool will create.Method Detail |
---|
public String getThreadNamePrefix()
public void setThreadNamePrefix(String threadNamePrefix)
public int getPoolSize()
public int getMaximumPoolSize()
public int getKeepAliveTime()
public void setMaximumPoolSize(int maximumPoolSize)
public void setKeepAliveTime(int keepAliveTime)
public void onPreAdd(IoFilterChain parent, String name, IoFilter.NextFilter nextFilter) throws Exception
IoFilter
IoFilter.init()
is invoked.
onPreAdd
in interface IoFilter
onPreAdd
in class IoFilterAdapter
parent
- the parent who called this methodname
- the name assigned to this filternextFilter
- the IoFilter.NextFilter
for this filter. You can reuse
this object until this filter is removed from the chain.
Exception
public void start()
public void stop()
protected ThreadPoolFilter.SessionBuffer fetchSessionBuffer(Queue unfetchedSessionBuffers)
ThreadPoolFilter.SessionBuffer
from
the given unfetchedSessionBuffers. The default implementation
simply pops the buffer from it. You could prioritize the fetch order.
ThreadPoolFilter.SessionBuffer
public void sessionCreated(IoFilter.NextFilter nextFilter, IoSession session)
IoFilter
IoHandler.sessionCreated(IoSession)
event.
sessionCreated
in interface IoFilter
sessionCreated
in class IoFilterAdapter
public void sessionOpened(IoFilter.NextFilter nextFilter, IoSession session)
IoFilter
IoHandler.sessionOpened(IoSession)
event.
sessionOpened
in interface IoFilter
sessionOpened
in class IoFilterAdapter
public void sessionClosed(IoFilter.NextFilter nextFilter, IoSession session)
IoFilter
IoHandler.sessionClosed(IoSession)
event.
sessionClosed
in interface IoFilter
sessionClosed
in class IoFilterAdapter
public void sessionIdle(IoFilter.NextFilter nextFilter, IoSession session, IdleStatus status)
IoFilter
IoHandler.sessionIdle(IoSession,IdleStatus)
event.
sessionIdle
in interface IoFilter
sessionIdle
in class IoFilterAdapter
public void exceptionCaught(IoFilter.NextFilter nextFilter, IoSession session, Throwable cause)
IoFilter
IoHandler.exceptionCaught(IoSession,Throwable)
event.
exceptionCaught
in interface IoFilter
exceptionCaught
in class IoFilterAdapter
public void messageReceived(IoFilter.NextFilter nextFilter, IoSession session, Object message)
IoFilter
IoHandler.messageReceived(IoSession,Object)
event.
messageReceived
in interface IoFilter
messageReceived
in class IoFilterAdapter
public void messageSent(IoFilter.NextFilter nextFilter, IoSession session, Object message)
IoFilter
IoHandler.messageSent(IoSession,Object)
event.
messageSent
in interface IoFilter
messageSent
in class IoFilterAdapter
protected void processEvent(IoFilter.NextFilter nextFilter, IoSession session, ThreadPoolFilter.EventType type, Object data)
public void filterWrite(IoFilter.NextFilter nextFilter, IoSession session, IoFilter.WriteRequest writeRequest)
IoFilter
IoSession.write(Object)
method invocation.
filterWrite
in interface IoFilter
filterWrite
in class IoFilterAdapter
public void filterClose(IoFilter.NextFilter nextFilter, IoSession session) throws Exception
IoFilter
IoSession.close()
method invocation.
filterClose
in interface IoFilter
filterClose
in class IoFilterAdapter
Exception
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |