⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 executorfilter.html

📁 MINA+API 关于MINA的API
💻 HTML
📖 第 1 页 / 共 4 页
字号:
<a name="209" href="#209">209</a>     }<a name="210" href="#210">210</a>     <a name="211" href="#211">211</a>     <em class="jxr_javadoccomment">/**</em><a name="212" href="#212">212</a> <em class="jxr_javadoccomment">     * (Convenience constructor) Creates a new instance with a new</em><a name="213" href="#213">213</a> <em class="jxr_javadoccomment">     * {@link OrderedThreadPoolExecutor}.</em><a name="214" href="#214">214</a> <em class="jxr_javadoccomment">     */</em><a name="215" href="#215">215</a>     <strong class="jxr_keyword">public</strong> <a href="../../../../../org/apache/mina/filter/executor/ExecutorFilter.html">ExecutorFilter</a>(<a name="216" href="#216">216</a>             <strong class="jxr_keyword">int</strong> corePoolSize, <strong class="jxr_keyword">int</strong> maximumPoolSize, <strong class="jxr_keyword">long</strong> keepAliveTime, TimeUnit unit, IoEventType... eventTypes) {<a name="217" href="#217">217</a>         <strong class="jxr_keyword">this</strong>(corePoolSize, maximumPoolSize, keepAliveTime, unit, Executors.defaultThreadFactory(), eventTypes);<a name="218" href="#218">218</a>     }<a name="219" href="#219">219</a>     <a name="220" href="#220">220</a>     <em class="jxr_javadoccomment">/**</em><a name="221" href="#221">221</a> <em class="jxr_javadoccomment">     * (Convenience constructor) Creates a new instance with a new</em><a name="222" href="#222">222</a> <em class="jxr_javadoccomment">     * {@link OrderedThreadPoolExecutor}.</em><a name="223" href="#223">223</a> <em class="jxr_javadoccomment">     */</em><a name="224" href="#224">224</a>     <strong class="jxr_keyword">public</strong> <a href="../../../../../org/apache/mina/filter/executor/ExecutorFilter.html">ExecutorFilter</a>(<a name="225" href="#225">225</a>             <strong class="jxr_keyword">int</strong> corePoolSize, <strong class="jxr_keyword">int</strong> maximumPoolSize, <a name="226" href="#226">226</a>             <strong class="jxr_keyword">long</strong> keepAliveTime, TimeUnit unit,<a name="227" href="#227">227</a>             <a href="../../../../../org/apache/mina/filter/executor/IoEventQueueHandler.html">IoEventQueueHandler</a> queueHandler, IoEventType... eventTypes) {<a name="228" href="#228">228</a>         <strong class="jxr_keyword">this</strong>(corePoolSize, maximumPoolSize, keepAliveTime, unit, Executors.defaultThreadFactory(), queueHandler, eventTypes);<a name="229" href="#229">229</a>     }<a name="230" href="#230">230</a> <a name="231" href="#231">231</a>     <em class="jxr_javadoccomment">/**</em><a name="232" href="#232">232</a> <em class="jxr_javadoccomment">     * (Convenience constructor) Creates a new instance with a new</em><a name="233" href="#233">233</a> <em class="jxr_javadoccomment">     * {@link OrderedThreadPoolExecutor}.</em><a name="234" href="#234">234</a> <em class="jxr_javadoccomment">     */</em><a name="235" href="#235">235</a>     <strong class="jxr_keyword">public</strong> <a href="../../../../../org/apache/mina/filter/executor/ExecutorFilter.html">ExecutorFilter</a>(<a name="236" href="#236">236</a>             <strong class="jxr_keyword">int</strong> corePoolSize, <strong class="jxr_keyword">int</strong> maximumPoolSize, <a name="237" href="#237">237</a>             <strong class="jxr_keyword">long</strong> keepAliveTime, TimeUnit unit,<a name="238" href="#238">238</a>             ThreadFactory threadFactory, IoEventType... eventTypes) {<a name="239" href="#239">239</a>         <strong class="jxr_keyword">this</strong>(corePoolSize, maximumPoolSize, keepAliveTime, unit, threadFactory, <strong class="jxr_keyword">null</strong>, eventTypes);<a name="240" href="#240">240</a>     }<a name="241" href="#241">241</a> <a name="242" href="#242">242</a>     <em class="jxr_javadoccomment">/**</em><a name="243" href="#243">243</a> <em class="jxr_javadoccomment">     * (Convenience constructor) Creates a new instance with a new</em><a name="244" href="#244">244</a> <em class="jxr_javadoccomment">     * {@link OrderedThreadPoolExecutor}.</em><a name="245" href="#245">245</a> <em class="jxr_javadoccomment">     */</em><a name="246" href="#246">246</a>     <strong class="jxr_keyword">public</strong> <a href="../../../../../org/apache/mina/filter/executor/ExecutorFilter.html">ExecutorFilter</a>(<a name="247" href="#247">247</a>             <strong class="jxr_keyword">int</strong> corePoolSize, <strong class="jxr_keyword">int</strong> maximumPoolSize, <a name="248" href="#248">248</a>             <strong class="jxr_keyword">long</strong> keepAliveTime, TimeUnit unit,<a name="249" href="#249">249</a>             ThreadFactory threadFactory, <a href="../../../../../org/apache/mina/filter/executor/IoEventQueueHandler.html">IoEventQueueHandler</a> queueHandler, IoEventType... eventTypes) {<a name="250" href="#250">250</a>         <strong class="jxr_keyword">this</strong>(<strong class="jxr_keyword">new</strong> <a href="../../../../../org/apache/mina/filter/executor/OrderedThreadPoolExecutor.html">OrderedThreadPoolExecutor</a>(corePoolSize, maximumPoolSize, keepAliveTime, unit, threadFactory, queueHandler), <strong class="jxr_keyword">true</strong>, eventTypes);<a name="251" href="#251">251</a>     }<a name="252" href="#252">252</a>     <a name="253" href="#253">253</a>     <em class="jxr_javadoccomment">/**</em><a name="254" href="#254">254</a> <em class="jxr_javadoccomment">     * Creates a new instance with the specified {@link Executor}.</em><a name="255" href="#255">255</a> <em class="jxr_javadoccomment">     */</em><a name="256" href="#256">256</a>     <strong class="jxr_keyword">public</strong> <a href="../../../../../org/apache/mina/filter/executor/ExecutorFilter.html">ExecutorFilter</a>(Executor executor) {<a name="257" href="#257">257</a>         <strong class="jxr_keyword">this</strong>(executor, false, (IoEventType[]) <strong class="jxr_keyword">null</strong>);<a name="258" href="#258">258</a>     }<a name="259" href="#259">259</a> <a name="260" href="#260">260</a>     <em class="jxr_javadoccomment">/**</em><a name="261" href="#261">261</a> <em class="jxr_javadoccomment">     * Creates a new instance with the specified {@link Executor}.</em><a name="262" href="#262">262</a> <em class="jxr_javadoccomment">     */</em><a name="263" href="#263">263</a>     <strong class="jxr_keyword">public</strong> <a href="../../../../../org/apache/mina/filter/executor/ExecutorFilter.html">ExecutorFilter</a>(Executor executor, IoEventType... eventTypes) {<a name="264" href="#264">264</a>         <strong class="jxr_keyword">this</strong>(executor, false, eventTypes);<a name="265" href="#265">265</a>     }<a name="266" href="#266">266</a> <a name="267" href="#267">267</a>     <strong class="jxr_keyword">private</strong> <a href="../../../../../org/apache/mina/filter/executor/ExecutorFilter.html">ExecutorFilter</a>(Executor executor, <strong class="jxr_keyword">boolean</strong> createdExecutor, IoEventType... eventTypes) {<a name="268" href="#268">268</a>         <strong class="jxr_keyword">if</strong> (executor == <strong class="jxr_keyword">null</strong>) {<a name="269" href="#269">269</a>             <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> NullPointerException(<span class="jxr_string">"executor"</span>);<a name="270" href="#270">270</a>         }<a name="271" href="#271">271</a>         <strong class="jxr_keyword">if</strong> (eventTypes == <strong class="jxr_keyword">null</strong> || eventTypes.length == 0) {<a name="272" href="#272">272</a>             eventTypes = <strong class="jxr_keyword">new</strong> <a href="../../../../../org/apache/mina/common/IoEventType.html">IoEventType</a>[] { IoEventType.EXCEPTION_CAUGHT,<a name="273" href="#273">273</a>                     IoEventType.MESSAGE_RECEIVED, IoEventType.MESSAGE_SENT,<a name="274" href="#274">274</a>                     IoEventType.SESSION_CLOSED, IoEventType.SESSION_IDLE,<a name="275" href="#275">275</a>                     IoEventType.SESSION_OPENED, };<a name="276" href="#276">276</a>         }<a name="277" href="#277">277</a> <a name="278" href="#278">278</a>         <strong class="jxr_keyword">for</strong> (IoEventType t : eventTypes) {<a name="279" href="#279">279</a>             <strong class="jxr_keyword">if</strong> (t == IoEventType.SESSION_CREATED) {<a name="280" href="#280">280</a>                 <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> IllegalArgumentException(IoEventType.SESSION_CREATED<a name="281" href="#281">281</a>                         + <span class="jxr_string">" is not allowed."</span>);<a name="282" href="#282">282</a>             }<a name="283" href="#283">283</a>         }<a name="284" href="#284">284</a> <a name="285" href="#285">285</a>         <strong class="jxr_keyword">this</strong>.executor = executor;<a name="286" href="#286">286</a>         <strong class="jxr_keyword">this</strong>.createdExecutor = createdExecutor;<a name="287" href="#287">287</a> <a name="288" href="#288">288</a>         Collection&lt;IoEventType&gt; eventTypeCollection = <strong class="jxr_keyword">new</strong> ArrayList&lt;IoEventType&gt;(<a name="289" href="#289">289</a>                 eventTypes.length);<a name="290" href="#290">290</a>         Collections.addAll(eventTypeCollection, eventTypes);<a name="291" href="#291">291</a>         <strong class="jxr_keyword">this</strong>.eventTypes = EnumSet.copyOf(eventTypeCollection);<a name="292" href="#292">292</a>     }<a name="293" href="#293">293</a>     <a name="294" href="#294">294</a>     <em class="jxr_javadoccomment">/**</em><a name="295" href="#295">295</a> <em class="jxr_javadoccomment">     * Shuts down the underlying executor if this filter is creates via</em><a name="296" href="#296">296</a> <em class="jxr_javadoccomment">     * a convenience constructor.</em><a name="297" href="#297">297</a> <em class="jxr_javadoccomment">     */</em><a name="298" href="#298">298</a>     @Override<a name="299" href="#299">299</a>     <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">void</strong> destroy() {<a name="300" href="#300">300</a>         <strong class="jxr_keyword">if</strong> (createdExecutor) {<a name="301" href="#301">301</a>             ((ExecutorService) executor).shutdown();<a name="302" href="#302">302</a>         }<a name="303" href="#303">303</a>     }<a name="304" href="#304">304</a> <a name="305" href="#305">305</a>     <em class="jxr_javadoccomment">/**</em><a name="306" href="#306">306</a> <em class="jxr_javadoccomment">     * Returns the underlying {@link Executor} instance this filter uses.</em><a name="307" href="#307">307</a> <em class="jxr_javadoccomment">     */</em><a name="308" href="#308">308</a>     <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">final</strong> Executor getExecutor() {<a name="309" href="#309">309</a>         <strong class="jxr_keyword">return</strong> executor;<a name="310" href="#310">310</a>     }<a name="311" href="#311">311</a> <a name="312" href="#312">312</a>     <em class="jxr_javadoccomment">/**</em><a name="313" href="#313">313</a> <em class="jxr_javadoccomment">     * Fires the specified event through the underlying executor.</em><a name="314" href="#314">314</a> <em class="jxr_javadoccomment">     */</em><a name="315" href="#315">315</a>     <strong class="jxr_keyword">protected</strong> <strong class="jxr_keyword">void</strong> fireEvent(<a href="../../../../../org/apache/mina/common/IoFilterEvent.html">IoFilterEvent</a> event) {<a name="316" href="#316">316</a>         getExecutor().execute(event);<a name="317" href="#317">317</a>     }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -