當前位置: 首頁>>代碼示例>>Java>>正文


Java IoSession.getService方法代碼示例

本文整理匯總了Java中org.apache.mina.core.session.IoSession.getService方法的典型用法代碼示例。如果您正苦於以下問題:Java IoSession.getService方法的具體用法?Java IoSession.getService怎麽用?Java IoSession.getService使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.mina.core.session.IoSession的用法示例。


在下文中一共展示了IoSession.getService方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: StringBuilder

import org.apache.mina.core.session.IoSession; //導入方法依賴的package包/類
/**
 * An extended toString() method for sessions. If the SSL handshake
 * is not yet completed, we will print (ssl) in small caps. Once it's
 * completed, we will use SSL capitalized.
 */
/* no qualifier */String getSessionInfo(IoSession session) {
    StringBuilder sb = new StringBuilder();

    if (session.getService() instanceof IoAcceptor) {
        sb.append("Session Server");

    } else {
        sb.append("Session Client");
    }

    sb.append('[').append(session.getId()).append(']');

    SslHandler handler = (SslHandler) session.getAttribute(SSL_HANDLER);

    if (handler == null) {
        sb.append("(no sslEngine)");
    } else if (isSslStarted(session)) {
        if (handler.isHandshakeComplete()) {
            sb.append("(SSL)");
        } else {
            sb.append("(ssl...)");
        }
    }

    return sb.toString();
}
 
開發者ID:eclipse,項目名稱:neoscada,代碼行數:32,代碼來源:SslFilter.java

示例2: fireSessionDestroyed

import org.apache.mina.core.session.IoSession; //導入方法依賴的package包/類
/**
 * Calls {@link IoServiceListener#sessionDestroyed(IoSession)} for all registered listeners.
 * 
 * @param session The session which has been destroyed
 */
public void fireSessionDestroyed(IoSession session) {
    // Try to remove the remaining empty session set after removal.
    if (managedSessions.remove(session.getId()) == null) {
        return;
    }

    // Fire session events.
    session.getFilterChain().fireSessionClosed();

    // Fire listener events.
    try {
        for (IoServiceListener l : listeners) {
            try {
                l.sessionDestroyed(session);
            } catch (Throwable e) {
                ExceptionMonitor.getInstance().exceptionCaught(e);
            }
        }
    } finally {
        // Fire a virtual service deactivation event for the last session of the connector.
        if (session.getService() instanceof IoConnector) {
            boolean lastSession = false;

            synchronized (managedSessions) {
                lastSession = managedSessions.isEmpty();
            }

            if (lastSession) {
                fireServiceDeactivated();
            }
        }
    }
}
 
開發者ID:eclipse,項目名稱:neoscada,代碼行數:39,代碼來源:IoServiceListenerSupport.java

示例3: fireSessionCreated

import org.apache.mina.core.session.IoSession; //導入方法依賴的package包/類
/**
 * Calls {@link IoServiceListener#sessionCreated(IoSession)} for all registered listeners.
 * 
 * @param session The session which has been created
 */
public void fireSessionCreated(IoSession session) {
    boolean firstSession = false;

    if (session.getService() instanceof IoConnector) {
        synchronized (managedSessions) {
            firstSession = managedSessions.isEmpty();
        }
    }

    // If already registered, ignore.
    if (managedSessions.putIfAbsent(session.getId(), session) != null) {
        return;
    }

    // If the first connector session, fire a virtual service activation event.
    if (firstSession) {
        fireServiceActivated();
    }

    // Fire session events.
    IoFilterChain filterChain = session.getFilterChain();
    filterChain.fireSessionCreated();
    filterChain.fireSessionOpened();

    int managedSessionCount = managedSessions.size();

    if (managedSessionCount > largestManagedSessionCount) {
        largestManagedSessionCount = managedSessionCount;
    }

    cumulativeManagedSessionCount++;

    // Fire listener events.
    for (IoServiceListener l : listeners) {
        try {
            l.sessionCreated(session);
        } catch (Throwable e) {
            ExceptionMonitor.getInstance().exceptionCaught(e);
        }
    }
}
 
開發者ID:eclipse,項目名稱:neoscada,代碼行數:47,代碼來源:IoServiceListenerSupport.java


注:本文中的org.apache.mina.core.session.IoSession.getService方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。