📄 abstractioconnector.html
字号:
<a name="102" href="#102">102</a> SocketAddress localAddress) {<a name="103" href="#103">103</a> <strong class="jxr_keyword">return</strong> connect(remoteAddress, localAddress, <strong class="jxr_keyword">null</strong>);<a name="104" href="#104">104</a> }<a name="105" href="#105">105</a> <a name="106" href="#106">106</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">final</strong> <a href="../../../../org/apache/mina/common/ConnectFuture.html">ConnectFuture</a> connect(SocketAddress remoteAddress,<a name="107" href="#107">107</a> SocketAddress localAddress, IoSessionInitializer<? <strong class="jxr_keyword">extends</strong> ConnectFuture> sessionInitializer) {<a name="108" href="#108">108</a> <strong class="jxr_keyword">if</strong> (isDisposing()) {<a name="109" href="#109">109</a> <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> IllegalStateException(<span class="jxr_string">"Already disposed."</span>);<a name="110" href="#110">110</a> }<a name="111" href="#111">111</a> <a name="112" href="#112">112</a> <strong class="jxr_keyword">if</strong> (remoteAddress == <strong class="jxr_keyword">null</strong>) {<a name="113" href="#113">113</a> <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> NullPointerException(<span class="jxr_string">"remoteAddress"</span>);<a name="114" href="#114">114</a> }<a name="115" href="#115">115</a> <a name="116" href="#116">116</a> <strong class="jxr_keyword">if</strong> (!getTransportMetadata().getAddressType().isAssignableFrom(<a name="117" href="#117">117</a> remoteAddress.getClass())) {<a name="118" href="#118">118</a> <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> IllegalArgumentException(<span class="jxr_string">"remoteAddress type: "</span><a name="119" href="#119">119</a> + remoteAddress.getClass() + <span class="jxr_string">" (expected: "</span><a name="120" href="#120">120</a> + getTransportMetadata().getAddressType() + <span class="jxr_string">")"</span>);<a name="121" href="#121">121</a> }<a name="122" href="#122">122</a> <a name="123" href="#123">123</a> <strong class="jxr_keyword">if</strong> (localAddress != <strong class="jxr_keyword">null</strong><a name="124" href="#124">124</a> && !getTransportMetadata().getAddressType().isAssignableFrom(<a name="125" href="#125">125</a> localAddress.getClass())) {<a name="126" href="#126">126</a> <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> IllegalArgumentException(<span class="jxr_string">"localAddress type: "</span><a name="127" href="#127">127</a> + localAddress.getClass() + <span class="jxr_string">" (expected: "</span><a name="128" href="#128">128</a> + getTransportMetadata().getAddressType() + <span class="jxr_string">")"</span>);<a name="129" href="#129">129</a> }<a name="130" href="#130">130</a> <a name="131" href="#131">131</a> <strong class="jxr_keyword">if</strong> (getHandler() == <strong class="jxr_keyword">null</strong>) {<a name="132" href="#132">132</a> <strong class="jxr_keyword">if</strong> (getSessionConfig().isUseReadOperation()) {<a name="133" href="#133">133</a> setHandler(<strong class="jxr_keyword">new</strong> <a href="../../../../org/apache/mina/common/IoHandler.html">IoHandler</a>() {<a name="134" href="#134">134</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">void</strong> exceptionCaught(<a href="../../../../org/apache/mina/common/IoSession.html">IoSession</a> session,<a name="135" href="#135">135</a> Throwable cause) <strong class="jxr_keyword">throws</strong> Exception {<a name="136" href="#136">136</a> }<a name="137" href="#137">137</a> <a name="138" href="#138">138</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">void</strong> messageReceived(<a href="../../../../org/apache/mina/common/IoSession.html">IoSession</a> session,<a name="139" href="#139">139</a> Object message) <strong class="jxr_keyword">throws</strong> Exception {<a name="140" href="#140">140</a> }<a name="141" href="#141">141</a> <a name="142" href="#142">142</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">void</strong> messageSent(<a href="../../../../org/apache/mina/common/IoSession.html">IoSession</a> session, Object message)<a name="143" href="#143">143</a> <strong class="jxr_keyword">throws</strong> Exception {<a name="144" href="#144">144</a> }<a name="145" href="#145">145</a> <a name="146" href="#146">146</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">void</strong> sessionClosed(<a href="../../../../org/apache/mina/common/IoSession.html">IoSession</a> session)<a name="147" href="#147">147</a> <strong class="jxr_keyword">throws</strong> Exception {<a name="148" href="#148">148</a> }<a name="149" href="#149">149</a> <a name="150" href="#150">150</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">void</strong> sessionCreated(<a href="../../../../org/apache/mina/common/IoSession.html">IoSession</a> session)<a name="151" href="#151">151</a> <strong class="jxr_keyword">throws</strong> Exception {<a name="152" href="#152">152</a> }<a name="153" href="#153">153</a> <a name="154" href="#154">154</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">void</strong> sessionIdle(<a href="../../../../org/apache/mina/common/IoSession.html">IoSession</a> session, <a href="../../../../org/apache/mina/common/IdleStatus.html">IdleStatus</a> status)<a name="155" href="#155">155</a> <strong class="jxr_keyword">throws</strong> Exception {<a name="156" href="#156">156</a> }<a name="157" href="#157">157</a> <a name="158" href="#158">158</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">void</strong> sessionOpened(<a href="../../../../org/apache/mina/common/IoSession.html">IoSession</a> session)<a name="159" href="#159">159</a> <strong class="jxr_keyword">throws</strong> Exception {<a name="160" href="#160">160</a> }<a name="161" href="#161">161</a> });<a name="162" href="#162">162</a> } <strong class="jxr_keyword">else</strong> {<a name="163" href="#163">163</a> <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> IllegalStateException(<span class="jxr_string">"handler is not set."</span>);<a name="164" href="#164">164</a> }<a name="165" href="#165">165</a> }<a name="166" href="#166">166</a> <a name="167" href="#167">167</a> <strong class="jxr_keyword">return</strong> connect0(remoteAddress, localAddress, sessionInitializer);<a name="168" href="#168">168</a> }<a name="169" href="#169">169</a> <a name="170" href="#170">170</a> <em class="jxr_javadoccomment">/**</em><a name="171" href="#171">171</a> <em class="jxr_javadoccomment"> * Implement this method to perform the actual connect operation.</em><a name="172" href="#172">172</a> <em class="jxr_javadoccomment"> *</em><a name="173" href="#173">173</a> <em class="jxr_javadoccomment"> * @param localAddress <tt>null</tt> if no local address is specified</em><a name="174" href="#174">174</a> <em class="jxr_javadoccomment"> */</em><a name="175" href="#175">175</a> <strong class="jxr_keyword">protected</strong> <strong class="jxr_keyword">abstract</strong> <a href="../../../../org/apache/mina/common/ConnectFuture.html">ConnectFuture</a> connect0(SocketAddress remoteAddress,<a name="176" href="#176">176</a> SocketAddress localAddress, IoSessionInitializer<? <strong class="jxr_keyword">extends</strong> ConnectFuture> sessionInitializer);<a name="177" href="#177">177</a> <a name="178" href="#178">178</a> <em class="jxr_javadoccomment">/**</em><a name="179" href="#179">179</a> <em class="jxr_javadoccomment"> * Adds required internal attributes and {@link IoFutureListener}s</em><a name="180" href="#180">180</a> <em class="jxr_javadoccomment"> * related with event notifications to the specified {@code session}</em><a name="181" href="#181">181</a> <em class="jxr_javadoccomment"> * and {@code future}. Do not call this method directly;</em><a name="182" href="#182">182</a> <em class="jxr_javadoccomment"> * {@link #finishSessionInitialization(IoSession, IoFuture, IoSessionInitializer)}</em><a name="183" href="#183">183</a> <em class="jxr_javadoccomment"> * will call this method instead.</em><a name="184" href="#184">184</a> <em class="jxr_javadoccomment"> */</em><a name="185" href="#185">185</a> @Override<a name="186" href="#186">186</a> <strong class="jxr_keyword">protected</strong> <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">void</strong> finishSessionInitialization0(<a name="187" href="#187">187</a> <strong class="jxr_keyword">final</strong> <a href="../../../../org/apache/mina/common/IoSession.html">IoSession</a> session, <a href="../../../../org/apache/mina/common/IoFuture.html">IoFuture</a> future) {<a name="188" href="#188">188</a> <em class="jxr_comment">// In case that ConnectFuture.cancel() is invoked before</em><a name="189" href="#189">189</a> <em class="jxr_comment">// setSession() is invoked, add a listener that closes the</em><a name="190" href="#190">190</a> <em class="jxr_comment">// connection immediately on cancellation.</em><a name="191" href="#191">191</a> future.addListener(<strong class="jxr_keyword">new</strong> IoFutureListener<ConnectFuture>() {<a name="192" href="#192">192</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">void</strong> operationComplete(<a href="../../../../org/apache/mina/common/ConnectFuture.html">ConnectFuture</a> future) {<a name="193" href="#193">193</a> <strong class="jxr_keyword">if</strong> (future.isCanceled()) {<a name="194" href="#194">194</a> session.close();<a name="195" href="#195">195</a> }<a name="196" href="#196">196</a> }<a name="197" href="#197">197</a> });<a name="198" href="#198">198</a> }<a name="199" href="#199">199</a> <a name="200" href="#200">200</a> @Override<a name="201" href="#201">201</a> <strong class="jxr_keyword">public</strong> String toString() {<a name="202" href="#202">202</a> <a href="../../../../org/apache/mina/common/TransportMetadata.html">TransportMetadata</a> m = getTransportMetadata();<a name="203" href="#203">203</a> <strong class="jxr_keyword">return</strong> '(' + m.getProviderName() + ' ' + m.getName() + <span class="jxr_string">" connector: "</span> + <a name="204" href="#204">204</a> <span class="jxr_string">"managedSessionCount: "</span> + getManagedSessionCount() + ')'; <a name="205" href="#205">205</a> }<a name="206" href="#206">206</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 + -