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

📄 aprioprocessor.html

📁 MINA+API 关于MINA的API
💻 HTML
📖 第 1 页 / 共 3 页
字号:
<a name="247" href="#247">247</a>     }<a name="248" href="#248">248</a> <a name="249" href="#249">249</a>     @Override<a name="250" href="#250">250</a>     <strong class="jxr_keyword">protected</strong> <strong class="jxr_keyword">boolean</strong> isReadable(<a href="../../../../../../org/apache/mina/transport/socket/apr/AprSession.html">AprSession</a> session) {<a name="251" href="#251">251</a>         <strong class="jxr_keyword">return</strong> session.isReadable();<a name="252" href="#252">252</a>     }<a name="253" href="#253">253</a> <a name="254" href="#254">254</a>     @Override<a name="255" href="#255">255</a>     <strong class="jxr_keyword">protected</strong> <strong class="jxr_keyword">boolean</strong> isWritable(<a href="../../../../../../org/apache/mina/transport/socket/apr/AprSession.html">AprSession</a> session) {<a name="256" href="#256">256</a>         <strong class="jxr_keyword">return</strong> session.isWritable();<a name="257" href="#257">257</a>     }<a name="258" href="#258">258</a> <a name="259" href="#259">259</a>     @Override<a name="260" href="#260">260</a>     <strong class="jxr_keyword">protected</strong> <strong class="jxr_keyword">boolean</strong> isInterestedInRead(<a href="../../../../../../org/apache/mina/transport/socket/apr/AprSession.html">AprSession</a> session) {<a name="261" href="#261">261</a>         <strong class="jxr_keyword">return</strong> session.isInterestedInRead();<a name="262" href="#262">262</a>     }<a name="263" href="#263">263</a> <a name="264" href="#264">264</a>     @Override<a name="265" href="#265">265</a>     <strong class="jxr_keyword">protected</strong> <strong class="jxr_keyword">boolean</strong> isInterestedInWrite(<a href="../../../../../../org/apache/mina/transport/socket/apr/AprSession.html">AprSession</a> session) {<a name="266" href="#266">266</a>         <strong class="jxr_keyword">return</strong> session.isInterestedInWrite();<a name="267" href="#267">267</a>     }<a name="268" href="#268">268</a> <a name="269" href="#269">269</a>     @Override<a name="270" href="#270">270</a>     <strong class="jxr_keyword">protected</strong> <strong class="jxr_keyword">void</strong> setInterestedInRead(<a href="../../../../../../org/apache/mina/transport/socket/apr/AprSession.html">AprSession</a> session, <strong class="jxr_keyword">boolean</strong> value) <strong class="jxr_keyword">throws</strong> Exception {<a name="271" href="#271">271</a>         <strong class="jxr_keyword">int</strong> rv = Poll.remove(pollset, session.getDescriptor());<a name="272" href="#272">272</a>         <strong class="jxr_keyword">if</strong> (rv != Status.APR_SUCCESS) {<a name="273" href="#273">273</a>             throwException(rv);<a name="274" href="#274">274</a>         }<a name="275" href="#275">275</a> <a name="276" href="#276">276</a>         <strong class="jxr_keyword">int</strong> flags = (value ? Poll.APR_POLLIN : 0)<a name="277" href="#277">277</a>                 | (session.isInterestedInWrite() ? Poll.APR_POLLOUT : 0);<a name="278" href="#278">278</a> <a name="279" href="#279">279</a>         rv = Poll.add(pollset, session.getDescriptor(), flags);<a name="280" href="#280">280</a>         <strong class="jxr_keyword">if</strong> (rv == Status.APR_SUCCESS) {<a name="281" href="#281">281</a>             session.setInterestedInRead(value);<a name="282" href="#282">282</a>         } <strong class="jxr_keyword">else</strong> {<a name="283" href="#283">283</a>             throwException(rv);<a name="284" href="#284">284</a>         }<a name="285" href="#285">285</a>     }<a name="286" href="#286">286</a> <a name="287" href="#287">287</a>     @Override<a name="288" href="#288">288</a>     <strong class="jxr_keyword">protected</strong> <strong class="jxr_keyword">void</strong> setInterestedInWrite(<a href="../../../../../../org/apache/mina/transport/socket/apr/AprSession.html">AprSession</a> session, <strong class="jxr_keyword">boolean</strong> value) <strong class="jxr_keyword">throws</strong> Exception {<a name="289" href="#289">289</a>         <strong class="jxr_keyword">int</strong> rv = Poll.remove(pollset, session.getDescriptor());<a name="290" href="#290">290</a>         <strong class="jxr_keyword">if</strong> (rv != Status.APR_SUCCESS) {<a name="291" href="#291">291</a>             throwException(rv);<a name="292" href="#292">292</a>         }<a name="293" href="#293">293</a> <a name="294" href="#294">294</a>         <strong class="jxr_keyword">int</strong> flags = (session.isInterestedInRead() ? Poll.APR_POLLIN : 0)<a name="295" href="#295">295</a>                 | (value ? Poll.APR_POLLOUT : 0);<a name="296" href="#296">296</a> <a name="297" href="#297">297</a>         rv = Poll.add(pollset, session.getDescriptor(), flags);<a name="298" href="#298">298</a>         <strong class="jxr_keyword">if</strong> (rv == Status.APR_SUCCESS) {<a name="299" href="#299">299</a>             session.setInterestedInWrite(value);<a name="300" href="#300">300</a>         } <strong class="jxr_keyword">else</strong> {<a name="301" href="#301">301</a>             throwException(rv);<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>     @Override<a name="306" href="#306">306</a>     <strong class="jxr_keyword">protected</strong> <strong class="jxr_keyword">int</strong> read(<a href="../../../../../../org/apache/mina/transport/socket/apr/AprSession.html">AprSession</a> session, <a href="../../../../../../org/apache/mina/common/IoBuffer.html">IoBuffer</a> buffer) <strong class="jxr_keyword">throws</strong> Exception {<a name="307" href="#307">307</a>         <strong class="jxr_keyword">int</strong> bytes;<a name="308" href="#308">308</a>         <em class="jxr_comment">// Using Socket.recv() directly causes memory leak. :-(</em><a name="309" href="#309">309</a>         ByteBuffer b = Pool.alloc(bufferPool, buffer.remaining());<a name="310" href="#310">310</a>         <strong class="jxr_keyword">try</strong> {<a name="311" href="#311">311</a>             bytes = Socket.recvb(<a name="312" href="#312">312</a>                     session.getDescriptor(), b, 0, b.remaining());<a name="313" href="#313">313</a>             <strong class="jxr_keyword">if</strong> (bytes &gt; 0) {<a name="314" href="#314">314</a>                 b.position(0);<a name="315" href="#315">315</a>                 b.limit(bytes);<a name="316" href="#316">316</a>                 buffer.put(b);<a name="317" href="#317">317</a>             } <strong class="jxr_keyword">else</strong> <strong class="jxr_keyword">if</strong> (bytes &lt; 0) {<a name="318" href="#318">318</a>                 <strong class="jxr_keyword">if</strong> (Status.APR_STATUS_IS_EOF(-bytes)) {<a name="319" href="#319">319</a>                     bytes = -1;<a name="320" href="#320">320</a>                 } <strong class="jxr_keyword">else</strong> <strong class="jxr_keyword">if</strong> (Status.APR_STATUS_IS_EAGAIN(-bytes)) {<a name="321" href="#321">321</a>                     bytes = 0;<a name="322" href="#322">322</a>                 } <strong class="jxr_keyword">else</strong> {<a name="323" href="#323">323</a>                     throwException(bytes);<a name="324" href="#324">324</a>                 }<a name="325" href="#325">325</a>             }<a name="326" href="#326">326</a>         } <strong class="jxr_keyword">finally</strong> {<a name="327" href="#327">327</a>             Pool.clear(bufferPool);<a name="328" href="#328">328</a>         }<a name="329" href="#329">329</a>         <strong class="jxr_keyword">return</strong> bytes;<a name="330" href="#330">330</a>     }<a name="331" href="#331">331</a> <a name="332" href="#332">332</a>     @Override<a name="333" href="#333">333</a>     <strong class="jxr_keyword">protected</strong> <strong class="jxr_keyword">int</strong> write(<a href="../../../../../../org/apache/mina/transport/socket/apr/AprSession.html">AprSession</a> session, <a href="../../../../../../org/apache/mina/common/IoBuffer.html">IoBuffer</a> buf, <strong class="jxr_keyword">int</strong> length) <strong class="jxr_keyword">throws</strong> Exception {<a name="334" href="#334">334</a>         <strong class="jxr_keyword">int</strong> writtenBytes;<a name="335" href="#335">335</a>         <strong class="jxr_keyword">if</strong> (buf.isDirect()) {<a name="336" href="#336">336</a>             writtenBytes = Socket.sendb(<a name="337" href="#337">337</a>                     session.getDescriptor(), buf.buf(), buf.position(), length);<a name="338" href="#338">338</a>         } <strong class="jxr_keyword">else</strong> {<a name="339" href="#339">339</a>             writtenBytes = Socket.send(<a name="340" href="#340">340</a>                     session.getDescriptor(), buf.array(), buf.position(), length);<a name="341" href="#341">341</a>             <strong class="jxr_keyword">if</strong> (writtenBytes &gt; 0) {<a name="342" href="#342">342</a>                 buf.skip(writtenBytes);<a name="343" href="#343">343</a>             }<a name="344" href="#344">344</a>         }<a name="345" href="#345">345</a>         <a name="346" href="#346">346</a>         <strong class="jxr_keyword">if</strong> (writtenBytes &lt; 0) {<a name="347" href="#347">347</a>             <strong class="jxr_keyword">if</strong> (Status.APR_STATUS_IS_EAGAIN(-writtenBytes)) {<a name="348" href="#348">348</a>                 writtenBytes = 0;<a name="349" href="#349">349</a>             } <strong class="jxr_keyword">else</strong> <strong class="jxr_keyword">if</strong> (Status.APR_STATUS_IS_EOF(-writtenBytes)) {<a name="350" href="#350">350</a>                 writtenBytes = 0;<a name="351" href="#351">351</a>             } <strong class="jxr_keyword">else</strong> {<a name="352" href="#352">352</a>                 throwException(writtenBytes);<a name="353" href="#353">353</a>             }<a name="354" href="#354">354</a>         }<a name="355" href="#355">355</a>         <strong class="jxr_keyword">return</strong> writtenBytes;<a name="356" href="#356">356</a>     }<a name="357" href="#357">357</a> <a name="358" href="#358">358</a>     @Override<a name="359" href="#359">359</a>     <strong class="jxr_keyword">protected</strong> <strong class="jxr_keyword">int</strong> transferFile(<a href="../../../../../../org/apache/mina/transport/socket/apr/AprSession.html">AprSession</a> session, <a href="../../../../../../org/apache/mina/common/FileRegion.html">FileRegion</a> region, <strong class="jxr_keyword">int</strong> length)<a name="360" href="#360">360</a>             <strong class="jxr_keyword">throws</strong> Exception {<a name="361" href="#361">361</a>         <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> UnsupportedOperationException();<a name="362" href="#362">362</a>     }<a name="363" href="#363">363</a> <a name="364" href="#364">364</a>     <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">void</strong> throwException(<strong class="jxr_keyword">int</strong> code) <strong class="jxr_keyword">throws</strong> IOException {<a name="365" href="#365">365</a>         <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> IOException(<a name="366" href="#366">366</a>                 org.apache.tomcat.jni.Error.strerror(-code) +<a name="367" href="#367">367</a>                 <span class="jxr_string">" (code: "</span> + code + <span class="jxr_string">")"</span>);<a name="368" href="#368">368</a>     }<a name="369" href="#369">369</a> }</pre><hr/><div id="footer">This page was automatically generated by <a href="http://maven.apache.org/">Maven</a></div></body></html>

⌨️ 快捷键说明

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