本文整理匯總了Java中org.apache.mina.core.session.IoSession.setAttributeIfAbsent方法的典型用法代碼示例。如果您正苦於以下問題:Java IoSession.setAttributeIfAbsent方法的具體用法?Java IoSession.setAttributeIfAbsent怎麽用?Java IoSession.setAttributeIfAbsent使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.mina.core.session.IoSession
的用法示例。
在下文中一共展示了IoSession.setAttributeIfAbsent方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getState
import org.apache.mina.core.session.IoSession; //導入方法依賴的package包/類
private State getState(IoSession session) throws Exception {
State state = (State) session.getAttribute(STATE);
if (state == null) {
state = new State();
State oldState = (State) session.setAttributeIfAbsent(STATE, state);
if (oldState != null) {
state = oldState;
}
}
return state;
}
示例2: getState
import org.apache.mina.core.session.IoSession; //導入方法依賴的package包/類
private State getState(IoSession session) throws Exception {
State state = (State) session.getAttribute(STATE);
if (state == null) {
state = new State();
State oldState = (State) session.setAttributeIfAbsent(STATE, state);
if (oldState != null) {
state = oldState;
}
}
return state;
}
示例3: getSessionTasksQueue
import org.apache.mina.core.session.IoSession; //導入方法依賴的package包/類
/**
* Get the session's tasks queue.
*/
private SessionTasksQueue getSessionTasksQueue(IoSession session) {
SessionTasksQueue queue = (SessionTasksQueue) session.getAttribute(TASKS_QUEUE);
if (queue == null) {
queue = new SessionTasksQueue();
SessionTasksQueue oldQueue = (SessionTasksQueue) session.setAttributeIfAbsent(TASKS_QUEUE, queue);
if (oldQueue != null) {
queue = oldQueue;
}
}
return queue;
}
示例4: sessionCreated
import org.apache.mina.core.session.IoSession; //導入方法依賴的package包/類
@Override
public void sessionCreated(IoSession session) {
System.out.println(session.getRemoteAddress().toString());
session.setAttributeIfAbsent(SessionProperties.DISTRIBUTE_KEY,
SessionManager.INSTANCE.getNextDistributeKey());
}