?? executorfilter.html
字號:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><!--NewPage--><HTML><HEAD><!-- Generated by javadoc (build 1.6.0_04) on Tue Feb 19 10:50:44 MST 2008 --><META http-equiv="Content-Type" content="text/html; charset=UTF-8"><TITLE>ExecutorFilter (Apache MINA 2.0.0-M1 API Documentation)</TITLE><META NAME="date" CONTENT="2008-02-19"><LINK REL ="stylesheet" TYPE="text/css" HREF="../../../../../stylesheet.css" TITLE="Style"><SCRIPT type="text/javascript">function windowTitle(){ if (location.href.indexOf('is-external=true') == -1) { parent.document.title="ExecutorFilter (Apache MINA 2.0.0-M1 API Documentation)"; }}</SCRIPT><NOSCRIPT></NOSCRIPT></HEAD><BODY BGCOLOR="white" onload="windowTitle();"><HR><!-- ========= START OF TOP NAVBAR ======= --><A NAME="navbar_top"><!-- --></A><A HREF="#skip-navbar_top" title="Skip navigation links"></A><TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY=""><TR><TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1"><A NAME="navbar_top_firstrow"><!-- --></A><TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY=""> <TR ALIGN="center" VALIGN="top"> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A> </TD> <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> <FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="class-use/ExecutorFilter.html"><FONT CLASS="NavBarFont1"><B>Use</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A> </TD> </TR></TABLE></TD><TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM></EM></TD></TR><TR><TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> <A HREF="../../../../../org/apache/mina/filter/executor/DefaultIoEventSizeEstimator.html" title="class in org.apache.mina.filter.executor"><B>PREV CLASS</B></A> <A HREF="../../../../../org/apache/mina/filter/executor/IoEventQueueHandler.html" title="interface in org.apache.mina.filter.executor"><B>NEXT CLASS</B></A></FONT></TD><TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> <A HREF="../../../../../index.html?org/apache/mina/filter/executor/ExecutorFilter.html" target="_top"><B>FRAMES</B></A> <A HREF="ExecutorFilter.html" target="_top"><B>NO FRAMES</B></A> <SCRIPT type="text/javascript"> <!-- if(window==top) { document.writeln('<A HREF="../../../../../allclasses-noframe.html"><B>All Classes</B></A>'); } //--></SCRIPT><NOSCRIPT> <A HREF="../../../../../allclasses-noframe.html"><B>All Classes</B></A></NOSCRIPT></FONT></TD></TR><TR><TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2"> SUMMARY: NESTED | FIELD | <A HREF="#constructor_summary">CONSTR</A> | <A HREF="#method_summary">METHOD</A></FONT></TD><TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">DETAIL: FIELD | <A HREF="#constructor_detail">CONSTR</A> | <A HREF="#method_detail">METHOD</A></FONT></TD></TR></TABLE><A NAME="skip-navbar_top"></A><!-- ========= END OF TOP NAVBAR ========= --><HR><!-- ======== START OF CLASS DATA ======== --><H2><FONT SIZE="-1">org.apache.mina.filter.executor</FONT><BR>Class ExecutorFilter</H2><PRE><A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">java.lang.Object</A> <IMG SRC="../../../../../resources/inherit.gif" ALT="extended by "><A HREF="../../../../../org/apache/mina/common/IoFilterAdapter.html" title="class in org.apache.mina.common">org.apache.mina.common.IoFilterAdapter</A> <IMG SRC="../../../../../resources/inherit.gif" ALT="extended by "><B>org.apache.mina.filter.executor.ExecutorFilter</B></PRE><DL><DT><B>All Implemented Interfaces:</B> <DD><A HREF="../../../../../org/apache/mina/common/IoFilter.html" title="interface in org.apache.mina.common">IoFilter</A></DD></DL><HR><DL><DT><PRE>public class <B>ExecutorFilter</B><DT>extends <A HREF="../../../../../org/apache/mina/common/IoFilterAdapter.html" title="class in org.apache.mina.common">IoFilterAdapter</A></DL></PRE><P>A filter that forwards I/O events to <A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/util/concurrent/Executor.html?is-external=true" title="class or interface in java.util.concurrent"><CODE>Executor</CODE></A> to enforce a certain thread model while allowing the events per session to be processed simultaneously. You can apply various thread model by inserting this filter to a <A HREF="../../../../../org/apache/mina/common/IoFilterChain.html" title="interface in org.apache.mina.common"><CODE>IoFilterChain</CODE></A>. <h2>Life Cycle Management</h2> Please note that this filter doesn't manage the life cycle of the <A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/util/concurrent/Executor.html?is-external=true" title="class or interface in java.util.concurrent"><CODE>Executor</CODE></A>. If you created this filter using <A HREF="../../../../../org/apache/mina/filter/executor/ExecutorFilter.html#ExecutorFilter(java.util.concurrent.Executor)"><CODE>ExecutorFilter(Executor)</CODE></A> or similar constructor that accepts an <A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/util/concurrent/Executor.html?is-external=true" title="class or interface in java.util.concurrent"><CODE>Executor</CODE></A> that you've instantiated, you have full control and responsibility of managing its life cycle (e.g. calling <A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/util/concurrent/ExecutorService.html?is-external=true#shutdown()" title="class or interface in java.util.concurrent"><CODE>ExecutorService.shutdown()</CODE></A>. <p> If you created this filter using convenience constructors like <A HREF="../../../../../org/apache/mina/filter/executor/ExecutorFilter.html#ExecutorFilter(int)"><CODE>ExecutorFilter(int)</CODE></A>, then you can shut down the executor by calling <A HREF="../../../../../org/apache/mina/filter/executor/ExecutorFilter.html#destroy()"><CODE>destroy()</CODE></A> explicitly. <h2>Event Ordering</h2> All convenience constructors of this filter creates a new <A HREF="../../../../../org/apache/mina/filter/executor/OrderedThreadPoolExecutor.html" title="class in org.apache.mina.filter.executor"><CODE>OrderedThreadPoolExecutor</CODE></A> instance. Therefore, the order of event is maintained like the following: <ul> <li>All event handler methods are called exclusively. (e.g. messageReceived and messageSent can't be invoked at the same time.)</li> <li>The event order is never mixed up. (e.g. messageReceived is always invoked before sessionClosed or messageSent.)</li> </ul> However, if you specified other <A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/util/concurrent/Executor.html?is-external=true" title="class or interface in java.util.concurrent"><CODE>Executor</CODE></A> instance in the constructor, the order of events are not maintained at all. This means more than one event handler methods can be invoked at the same time with mixed order. For example, let's assume that messageReceived, messageSent, and sessionClosed events are fired. <ul> <li>All event handler methods can be called simultaneously. (e.g. messageReceived and messageSent can be invoked at the same time.)</li> <li>The event order can be mixed up. (e.g. sessionClosed or messageSent can be invoked before messageReceived is invoked.)</li> </ul> If you need to maintain the order of events per session, please specify an <A HREF="../../../../../org/apache/mina/filter/executor/OrderedThreadPoolExecutor.html" title="class in org.apache.mina.filter.executor"><CODE>OrderedThreadPoolExecutor</CODE></A> instance or use the convenience constructors. <h2>Selective Filtering</h2> By default, all event types but <tt>sessionCreated</tt>, <tt>filterWrite</tt>, <tt>filterClose</tt> and <tt>filterSetTrafficMask</tt> are submitted to the underlying executor, which is most common setting. <p> If you want to submit only a certain set of event types, you can specify them in the constructor. For example, you could configure a thread pool for write operation for the maximum performance: <pre><code> IoService service = ...; DefaultIoFilterChainBuilder chain = service.getFilterChain(); chain.addLast("codec", new ProtocolCodecFilter(...)); // Use one thread pool for most events. chain.addLast("executor1", new ExecutorFilter()); // and another dedicated thread pool for 'filterWrite' events. chain.addLast("executor2", new ExecutorFilter(IoEventType.WRITE)); </code></pre> <h2>Preventing <A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/OutOfMemoryError.html?is-external=true" title="class or interface in java.lang"><CODE>OutOfMemoryError</CODE></A></h2> Please refer to <A HREF="../../../../../org/apache/mina/filter/executor/IoEventQueueThrottle.html" title="class in org.apache.mina.filter.executor"><CODE>IoEventQueueThrottle</CODE></A>, which is specified as a parameter of the convenience constructors.
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -