?? connectionadapter.java
字號(hào):
package com.ll.smsbeans;
import java.io.Serializable;
import java.util.logging.Logger;
/**
*
* 這個(gè)類是ConnectionListener接口的一個(gè)簡(jiǎn)單實(shí)現(xiàn)。
* 這個(gè)類對(duì)連接事件進(jìn)行了簡(jiǎn)單的處理。
* 可以通過(guò)繼承這個(gè)類的方法容易的實(shí)現(xiàn)對(duì)連接事件的處理,而不用關(guān)注后臺(tái)的情況。
*
*<p>
* @author listlike <a href="mailto:listlike@hotmail.com">
* <i><listlike@hotmail.com></i></a>
*
*/
public class ConnectionAdapter implements ConnectionListener, Serializable
{
static Logger _log;
/**
* <code>connectionChanged</code> 接收連接狀態(tài)的改變事件,將事件及時(shí)轉(zhuǎn)發(fā)到響應(yīng)的方法
*
* @param evt a <code>ConnectionEvent</code> 連接事件
*/
public void connectionChanged(ConnectionEvent evt)
{
switch (evt.getState().getValue())
{
case ConnectionEvent.EState.DISCONNECTED :
if (evt.getOldState() == ConnectionEvent.STATE_CONNECTING)
connectFailed(evt);
else
disconnected(evt);
break;
case ConnectionEvent.EState.CONNECTING :
connecting(evt);
break;
case ConnectionEvent.EState.CONNECTED :
connected(evt);
break;
default :
throw new RuntimeException("Illegal Connection state imput to ConnectionAdapter");
}
}
/** @deprecated 代替 {@link #connectionChanged(ConnectionEvent)},
*/
public void connected(ConnectionEvent evt)
{
connected();
;
}
/** @deprecated 代替 {@link #connectionChanged(ConnectionEvent)},
*/
public void disconnected(ConnectionEvent evt)
{
disconnected();
}
/** @deprecated 代替 {@link #connectionChanged(ConnectionEvent)},
*/
public void connecting(ConnectionEvent evt)
{
connecting();
}
/** @deprecated 代替 {@link #connectionChanged(ConnectionEvent)},
*/
public void connectFailed(ConnectionEvent evt)
{
connectFailed();
};
/** @deprecated 代替 {@link #connectionChanged(ConnectionEvent)},
*/
public void connected()
{
_log.info("與服務(wù)器成功連接!!!");
}
/** @deprecated 代替 {@link #connectionChanged(ConnectionEvent)},
*/
public void disconnected()
{
_log.info("與服務(wù)器連接已斷開!!!");
}
/** @deprecated 代替 {@link #connectionChanged(ConnectionEvent)},
*/
public void connecting()
{
_log.info("正在連接服務(wù)器!!!");
}
/** @deprecated 代替 {@link #connectionChanged(ConnectionEvent)},
*/
public void connectFailed()
{
_log.info("與服務(wù)器連接失敗!!!");
}
static {
_log = Logger.getLogger("com.ll.smsbeans.ConnectionAdapter");
}
}
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -